示例#1
0
// <dogmode>
void LLChatBar::sendChat( EChatType type )
{
	if (mInputEditor)
	{
		LLWString text = mInputEditor->getConvertedText();
		if (!text.empty())
		{
			// store sent line in history, duplicates will get filtered
			if (mInputEditor) mInputEditor->updateHistory();

			S32 channel = 0;
			stripChannelNumber(text, &channel);
			
			std::string utf8text = wstring_to_utf8str(text);//+" and read is "+llformat("%f",readChan)+" and undone is "+llformat("%d",undoneChan)+" but actualy channel is "+llformat("%d",channel);
			// Try to trigger a gesture, if not chat to a script.
			std::string utf8_revised_text;
			if (0 == channel)
			{
				convert_roleplay_text(utf8text);
				// discard returned "found" boolean
				LLGestureMgr::instance().triggerAndReviseString(utf8text, &utf8_revised_text);
			}
			else
			{
				utf8_revised_text = utf8text;
			}

			utf8_revised_text = utf8str_trim(utf8_revised_text);
			EChatType nType(type == CHAT_TYPE_OOC ? CHAT_TYPE_NORMAL : type);
			if (!utf8_revised_text.empty() && cmd_line_chat(utf8_revised_text, nType))
			{
				// Chat with animation
#if SHY_MOD //Command handler
				if(!SHCommandHandler::handleCommand(true, utf8_revised_text, gAgentID, (LLViewerObject*)gAgentAvatarp))//returns true if handled
#endif //shy_mod
				sendChatFromViewer(utf8_revised_text, nType, TRUE);
			}
		}
	}

	childSetValue("Chat Editor", LLStringUtil::null);

	gAgent.stopTyping();

	// If the user wants to stop chatting on hitting return, lose focus
	// and go out of chat mode.
	if (gChatBar == this && gSavedSettings.getBOOL("CloseChatOnReturn"))
	{
		stopChat();
	}
}
示例#2
0
// private
void LLViewerGesture::doTrigger( BOOL send_chat )
{
    if (mSoundItemID != LLUUID::null)
    {
        LLViewerInventoryItem *item;
        item = gInventory.getItem(mSoundItemID);
        if (item)
        {
            send_sound_trigger(item->getAssetUUID(), SOUND_VOLUME);
        }
    }

    if (!mAnimation.empty())
    {
        // AFK animations trigger the special "away" state, which
        // includes agent control settings. JC
        if (mAnimation == "enter_away_from_keyboard_state" || mAnimation == "away")
        {
            gAgent.setAFK();
        }
        else
        {
            LLUUID anim_id = gAnimLibrary.stringToAnimState(mAnimation);
            gAgent.sendAnimationRequest(anim_id, ANIM_REQUEST_START);
        }
    }

    bool handled = !cmd_line_chat(mOutputString, CHAT_TYPE_NORMAL);
#if SHY_MOD //Command handler
    handled = handled || SHCommandHandler::handleCommand(true, mOutputString, gAgentID, gAgentAvatarp);
#endif //shy_mod
    if (!handled && send_chat && !mOutputString.empty())
    {
        // Don't play nodding animation, since that might not blend
        // with the gesture animation.
        gChatBar->sendChatFromViewer(mOutputString, CHAT_TYPE_NORMAL, FALSE);
    }
}
void LLGestureMgr::runStep(LLMultiGesture* gesture, LLGestureStep* step)
{
	switch(step->getType())
	{
	case STEP_ANIMATION:
		{
			LLGestureStepAnimation* anim_step = (LLGestureStepAnimation*)step;
			if (anim_step->mAnimAssetID.isNull())
			{
				gesture->mCurrentStep++;
			}

			if (anim_step->mFlags & ANIM_FLAG_STOP)
			{
				if (gesture->mLocal)
				{
					gAgentAvatarp->stopMotion(anim_step->mAnimAssetID);
				}
				else
				{
					gAgent.sendAnimationRequest(anim_step->mAnimAssetID, ANIM_REQUEST_STOP);
					// remove it from our request set in case we just requested it
					std::set<LLUUID>::iterator set_it = gesture->mRequestedAnimIDs.find(anim_step->mAnimAssetID);
					if (set_it != gesture->mRequestedAnimIDs.end())
					{
						gesture->mRequestedAnimIDs.erase(set_it);
					}
				}
			}
			else
			{
				if (gesture->mLocal)
				{
					gAgentAvatarp->startMotion(anim_step->mAnimAssetID);
					// Indicate we're playing this animation now.
					gesture->mPlayingAnimIDs.insert(anim_step->mAnimAssetID);
				}
				else
				{
					gAgent.sendAnimationRequest(anim_step->mAnimAssetID, ANIM_REQUEST_START);
					// Indicate that we've requested this animation to play as
					// part of this gesture (but it won't start playing for at
					// least one round-trip to simulator).
					gesture->mRequestedAnimIDs.insert(anim_step->mAnimAssetID);
				}
			}
			gesture->mCurrentStep++;
			break;
		}
	case STEP_SOUND:
		{
			LLGestureStepSound* sound_step = (LLGestureStepSound*)step;
			const LLUUID& sound_id = sound_step->mSoundAssetID;
			const F32 volume = 1.f;
			if (gesture->mLocal)
				gAudiop->triggerSound(sound_id, gAgentID, volume, LLAudioEngine::AUDIO_TYPE_UI, gAgent.getPositionGlobal());
			else
				send_sound_trigger(sound_id, volume);
			gesture->mCurrentStep++;
			break;
		}
	case STEP_CHAT:
		{
			LLGestureStepChat* chat_step = (LLGestureStepChat*)step;
			std::string chat_text = chat_step->mChatText;
			// Don't animate the nodding, as this might not blend with
			// other playing animations.
			const BOOL animate = FALSE;

			if ( cmd_line_chat(chat_text, CHAT_TYPE_NORMAL))
			{
#if SHY_MOD //Command handler
				if(!SHCommandHandler::handleCommand(true, chat_text, gAgentID, gAgentAvatarp))//returns true if handled
#endif //shy_mod
				gesture->mLocal ? fake_local_chat(chat_text) : gChatBar->sendChatFromViewer(chat_text, CHAT_TYPE_NORMAL, animate);
			}
			gesture->mCurrentStep++;
			break;
		}
	case STEP_WAIT:
		{
			LLGestureStepWait* wait_step = (LLGestureStepWait*)step;
			if (wait_step->mFlags & WAIT_FLAG_TIME)
			{
				gesture->mWaitingTimer = TRUE;
				gesture->mWaitTimer.reset();
			}
			else if (wait_step->mFlags & WAIT_FLAG_ALL_ANIM)
			{
				gesture->mWaitingAnimations = TRUE;
				// Use the wait timer as a deadlock breaker for animation
				// waits.
				gesture->mWaitTimer.reset();
			}
			else
			{
				gesture->mCurrentStep++;
			}
			// Don't increment instruction pointer until wait is complete.
			break;
		}
	default:
		{
			break;
		}
	}
}
void LLNearbyChatBar::sendChat( EChatType type )
{
	if (mChatBox)
	{
		LLWString text = mChatBox->getConvertedText();
		if (!text.empty())
		{
			if(type == CHAT_TYPE_OOC)
			{
				std::string tempText = mChatBox->getText();
				tempText = gSavedSettings.getString("PhoenixOOCPrefix") + " " + tempText + " " + gSavedSettings.getString("PhoenixOOCPostfix");
				mChatBox->setText(tempText);
				text = utf8str_to_wstring(tempText);
			}

			// store sent line in history, duplicates will get filtered
			mChatBox->updateHistory();
			// Check if this is destined for another channel
			S32 channel = 0;
			stripChannelNumber(text, &channel);
			
			std::string utf8text = wstring_to_utf8str(text);
			// Try to trigger a gesture, if not chat to a script.
			std::string utf8_revised_text;
			if (0 == channel)
			{
//-TT Satomi Ahn - Patch MU_OOC	
				if (gSavedSettings.getBOOL("AutoCloseOOC"))
				{
					// Try to find any unclosed OOC chat (i.e. an opening
					// double parenthesis without a matching closing double
					// parenthesis.
					if (utf8text.find("(( ") != -1 && utf8text.find("))") == -1)
					{
						// add the missing closing double parenthesis.
						utf8text += " ))";
					}
					else if (utf8text.find("((") != -1 && utf8text.find("))") == -1)
					{
						if (utf8text.at(utf8text.length() - 1) == ')')
						{
							// cosmetic: add a space first to avoid a closing triple parenthesis
							utf8text += " ";
						}
						// add the missing closing double parenthesis.
						utf8text += "))";
					}
					else if (utf8text.find("[[ ") != -1 && utf8text.find("]]") == -1)
					{
						// add the missing closing double parenthesis.
						utf8text += " ]]";
					}
					else if (utf8text.find("[[") != -1 && utf8text.find("]]") == -1)
					{
						if (utf8text.at(utf8text.length() - 1) == ']')
						{
							// cosmetic: add a space first to avoid a closing triple parenthesis
							utf8text += " ";
						}
						// add the missing closing double parenthesis.
						utf8text += "]]";
					}
				}

				// Convert MU*s style poses into IRC emotes here.
				if (gSavedSettings.getBOOL("AllowMUpose") && utf8text.find(":") == 0 && utf8text.length() > 3)
				{
					if (utf8text.find(":'") == 0)
					{
						utf8text.replace(0, 1, "/me");
	 				}
					else if (isalpha(utf8text.at(1)))	// Do not prevent smileys and such.
					{
						utf8text.replace(0, 1, "/me ");
					}
				}				
//-TT Satomi Ahn - Patch MU_OOC	
				// discard returned "found" boolean
				LLGestureMgr::instance().triggerAndReviseString(utf8text, &utf8_revised_text);
			}
			else
			{
				utf8_revised_text = utf8text;
			}

			utf8_revised_text = utf8str_trim(utf8_revised_text);

			EChatType nType;
			if(type == CHAT_TYPE_OOC)
				nType = CHAT_TYPE_NORMAL;
			else
				nType = type;

			type = processChatTypeTriggers(nType, utf8_revised_text);

			if (!utf8_revised_text.empty() && cmd_line_chat(utf8_revised_text, type))
			{
				// Chat with animation
				sendChatFromViewer(utf8_revised_text, type, PhoenixPlayChatAnimation);
			}
		}

		mChatBox->setText(LLStringExplicit(""));
	}

	gAgent.stopTyping();

	// If the user wants to stop chatting on hitting return, lose focus
	// and go out of chat mode.
	if (gSavedSettings.getBOOL("CloseChatOnReturn"))
	{
		stopChat();
	}
}
示例#5
0
void LLChatBar::sendChat( EChatType type )
{
	if (mInputEditor)
	{
		LLWString text = mInputEditor->getConvertedText();
		if (!text.empty())
		{
			// store sent line in history, duplicates will get filtered
			if (mInputEditor) mInputEditor->updateHistory();
			// Check if this is destined for another channel
			S32 channel = mChanCtrlEnabled ? (S32)(mChannelControl->get()) : 0;

			stripChannelNumber(text, &channel);
			
			std::string utf8text = wstring_to_utf8str(text);
			// Try to trigger a gesture, if not chat to a script.
			std::string utf8_revised_text;
			if (0 == channel)
			{
				if (gSavedSettings.getBOOL("AutoCloseOOC"))
				{
					// Try to find any unclosed OOC chat (i.e. an opening
					// double parenthesis without a matching closing double
					// parenthesis.
					if (utf8text.find("((") != -1 && utf8text.find("))") == -1)
					{
						if (utf8text.at(utf8text.length() - 1) == ')')
						{
							// cosmetic: add a space first to avoid a closing triple parenthesis
							utf8text += " ";
						}
						// add the missing closing double parenthesis.
						utf8text += "))";
					}
				}

				// Convert MU*s style poses into IRC emotes here.
				if (gSavedSettings.getBOOL("AllowMUpose") && utf8text.find(":") == 0 && utf8text.length() > 3)
				{
					if (utf8text.find(":'") == 0)
					{
						utf8text.replace(0, 1, "/me");
	 				}
					else if (isalpha(utf8text.at(1)))	// Do not prevent smileys and such.
					{
						utf8text.replace(0, 1, "/me ");
					}
				}

				// discard returned "found" boolean
				gGestureManager.triggerAndReviseString(utf8text, &utf8_revised_text);
			}
			else
			{
				utf8_revised_text = utf8text;
			}

			utf8_revised_text = utf8str_trim(utf8_revised_text);

			if (!utf8_revised_text.empty())

			if (!utf8_revised_text.empty() && cmd_line_chat(utf8_revised_text, type))
			{
				// Chat with animation
				sendChatFromViewer(utf8_revised_text, type, TRUE);
			}
		}
	}

	childSetValue("Chat Editor", LLStringUtil::null);

	gAgent.stopTyping();

	// If the user wants to stop chatting on hitting return, lose focus
	// and go out of chat mode.
	if (gChatBar == this && gSavedSettings.getBOOL("CloseChatOnReturn"))
	{
		stopChat();
	}
}
示例#6
0
// <dogmode>
void LLChatBar::sendChat( EChatType type )
{
	if (mInputEditor)
	{
		LLWString text = mInputEditor->getConvertedText();
		if (!text.empty())
		{
			// store sent line in history, duplicates will get filtered
			if (mInputEditor) mInputEditor->updateHistory();

			S32 channel = 0;
			stripChannelNumber(text, &channel);
			
			std::string utf8text = wstring_to_utf8str(text);//+" and read is "+llformat("%f",readChan)+" and undone is "+llformat("%d",undoneChan)+" but actualy channel is "+llformat("%d",channel);
			// Try to trigger a gesture, if not chat to a script.
			std::string utf8_revised_text;
			if (0 == channel)
			{
				if (gSavedSettings.getBOOL("AscentAutoCloseOOC") && (utf8text.length() > 1))
				{
					// Chalice - OOC autoclosing patch based on code by Henri Beauchamp
					int needsClosingType=0;
					//Check if it needs the end-of-chat brackets -HgB
					if (utf8text.find("((") == 0 && utf8text.find("))") == -1)
					{
						if(utf8text.at(utf8text.length() - 1) == ')')
							utf8text+=" ";
						utf8text+="))";
					}
					else if(utf8text.find("[[") == 0 && utf8text.find("]]") == -1)
					{
						if(utf8text.at(utf8text.length() - 1) == ']')
							utf8text+=" ";
						utf8text+="]]";
					}
					//Check if it needs the start-of-chat brackets -HgB
					needsClosingType=0;
					if (utf8text.find("((") == -1 && utf8text.find("))") == (utf8text.length() - 2))
					{
						if(utf8text.at(0) == '(')
							utf8text.insert(0," ");
						utf8text.insert(0,"((");
					}
					else if (utf8text.find("[[") == -1 && utf8text.find("]]") == (utf8text.length() - 2))
					{
						if(utf8text.at(0) == '[')
							utf8text.insert(0," ");
						utf8text.insert(0,"[[");
					}
				}
				// Convert MU*s style poses into IRC emotes here.
				if (gSavedSettings.getBOOL("AscentAllowMUpose") && utf8text.find(":") == 0 && utf8text.length() > 3)
				{
					if (utf8text.find(":'") == 0)
					{
						utf8text.replace(0, 1, "/me");
	 				}
					else if (isalpha(utf8text.at(1)))	// Do not prevent smileys and such.
					{
						utf8text.replace(0, 1, "/me ");
					}
				}
				// discard returned "found" boolean
				LLGestureMgr::instance().triggerAndReviseString(utf8text, &utf8_revised_text);
			}
			else
			{
				utf8_revised_text = utf8text;
			}

			utf8_revised_text = utf8str_trim(utf8_revised_text);
			EChatType nType;
			if(type == CHAT_TYPE_OOC)
				nType=CHAT_TYPE_NORMAL;
			else
				nType=type;
			if (!utf8_revised_text.empty() && cmd_line_chat(utf8_revised_text, nType))
			{
				// Chat with animation
#if SHY_MOD //Command handler
				if(!SHCommandHandler::handleCommand(true, utf8_revised_text, gAgentID, (LLViewerObject*)gAgentAvatarp))//returns true if handled
#endif //shy_mod
				sendChatFromViewer(utf8_revised_text, nType, TRUE);
			}
		}
	}

	childSetValue("Chat Editor", LLStringUtil::null);

	gAgent.stopTyping();

	// If the user wants to stop chatting on hitting return, lose focus
	// and go out of chat mode.
	if (gChatBar == this && gSavedSettings.getBOOL("CloseChatOnReturn"))
	{
		stopChat();
	}
}
void FSNearbyChat::sendChat(LLWString text, EChatType type)
{
	LLWStringUtil::trim(text);

	if (!text.empty())
	{
		if (type == CHAT_TYPE_OOC)
		{
			std::string tempText = wstring_to_utf8str( text );
			tempText = gSavedSettings.getString("FSOOCPrefix") + " " + tempText + " " + gSavedSettings.getString("FSOOCPostfix");
			text = utf8str_to_wstring(tempText);
		}

		// Check if this is destined for another channel
		S32 channel = 0;
		bool is_set = false;
		stripChannelNumber(text, &channel, &sLastSpecialChatChannel, &is_set);
		// If "/<number>" is not specified, see if a channel has been set in
		//  the spinner.
		if (!is_set &&
			gSavedSettings.getBOOL("FSNearbyChatbar") &&
			gSavedSettings.getBOOL("FSShowChatChannel"))
		{
			channel = (S32)(FSFloaterNearbyChat::getInstance()->getChild<LLSpinCtrl>("ChatChannel")->get());
		}
		
		std::string utf8text = wstring_to_utf8str(text);
		// Try to trigger a gesture, if not chat to a script.
		std::string utf8_revised_text;
		if (0 == channel)
		{
			// Convert OOC and MU* style poses
			utf8text = applyAutoCloseOoc(utf8text);
			utf8text = applyMuPose(utf8text);

			// discard returned "found" boolean
			if(!LLGestureMgr::instance().triggerAndReviseString(utf8text, &utf8_revised_text))
			{
				utf8_revised_text = utf8text;
			}
		}
		else
		{
			utf8_revised_text = utf8text;
		}

		utf8_revised_text = utf8str_trim(utf8_revised_text);

		EChatType nType;
		if (type == CHAT_TYPE_OOC)
		{
			nType = CHAT_TYPE_NORMAL;
		}
		else
		{
			nType = type;
		}

		type = processChatTypeTriggers(nType, utf8_revised_text);

		if (!utf8_revised_text.empty() && cmd_line_chat(utf8_revised_text, type))
		{
			// Chat with animation
			sendChatFromViewer(utf8_revised_text, type, gSavedSettings.getBOOL("PlayChatAnim"));
		}
	}

	gAgent.stopTyping();
}
void FSFloaterNearbyChat::sendChat( EChatType type )
{
	if (mInputEditor)
	{
		LLWString text = mInputEditor->getWText();
		LLWStringUtil::trim(text);
		LLWStringUtil::replaceChar(text,182,'\n'); // Convert paragraph symbols back into newlines.
		if (!text.empty())
		{
			if(type == CHAT_TYPE_OOC)
			{
				std::string tempText = wstring_to_utf8str( text );
				tempText = gSavedSettings.getString("FSOOCPrefix") + " " + tempText + " " + gSavedSettings.getString("FSOOCPostfix");
				text = utf8str_to_wstring(tempText);
			}
			
			// Check if this is destined for another channel
			S32 channel = 0;
			stripChannelNumber(text, &channel);
			// If "/<number>" is not specified, see if a channel has been set in
			//  the spinner.
			if (gSavedSettings.getBOOL("FSNearbyChatbar") &&
				gSavedSettings.getBOOL("FSShowChatChannel") &&
				(channel == 0))
			{
				channel = (S32)(FSFloaterNearbyChat::getInstance()->getChild<LLSpinCtrl>("ChatChannel")->get());
			}
			
			std::string utf8text = wstring_to_utf8str(text);
			// Try to trigger a gesture, if not chat to a script.
			std::string utf8_revised_text;
			if (0 == channel)
			{
				// Convert OOC and MU* style poses
				utf8text = applyAutoCloseOoc(utf8text);
				utf8text = applyMuPose(utf8text);
				
				// discard returned "found" boolean
				LLGestureMgr::instance().triggerAndReviseString(utf8text, &utf8_revised_text);
			}
			else
			{
				utf8_revised_text = utf8text;
			}
			
			utf8_revised_text = utf8str_trim(utf8_revised_text);
			
			EChatType nType;
			if(type == CHAT_TYPE_OOC)
				nType = CHAT_TYPE_NORMAL;
			else
				nType = type;
			
			type = processChatTypeTriggers(nType, utf8_revised_text);
			
			if (!utf8_revised_text.empty() && cmd_line_chat(utf8_revised_text, type))
			{
				// Chat with animation
				sendChatFromViewer(utf8_revised_text, type, gSavedSettings.getBOOL("PlayChatAnim"));
			}
		}
		
		mInputEditor->setText(LLStringExplicit(""));
	}
	
	gAgent.stopTyping();
	
	// If the user wants to stop chatting on hitting return, lose focus
	// and go out of chat mode.
	if (gSavedSettings.getBOOL("CloseChatOnReturn") && gSavedSettings.getBOOL("FSUnfocusChatHistoryOnReturn"))
	{
		stopChat();
	}
}
示例#9
0
void LLGestureManager::runStep(LLMultiGesture* gesture, LLGestureStep* step)
{
	switch(step->getType())
	{
	case STEP_ANIMATION:
		{
			LLGestureStepAnimation* anim_step = (LLGestureStepAnimation*)step;
			if (anim_step->mAnimAssetID.isNull())
			{
				gesture->mCurrentStep++;
			}

			if (anim_step->mFlags & ANIM_FLAG_STOP)
			{
				gAgent.sendAnimationRequest(anim_step->mAnimAssetID, ANIM_REQUEST_STOP);
				// remove it from our request set in case we just requested it
				std::set<LLUUID>::iterator set_it = gesture->mRequestedAnimIDs.find(anim_step->mAnimAssetID);
				if (set_it != gesture->mRequestedAnimIDs.end())
				{
					gesture->mRequestedAnimIDs.erase(set_it);
				}
			}
			else
			{
				gAgent.sendAnimationRequest(anim_step->mAnimAssetID, ANIM_REQUEST_START);
				// Indicate that we've requested this animation to play as
				// part of this gesture (but it won't start playing for at
				// least one round-trip to simulator).
				gesture->mRequestedAnimIDs.insert(anim_step->mAnimAssetID);
			}
			gesture->mCurrentStep++;
			break;
		}
	case STEP_SOUND:
		{
			LLGestureStepSound* sound_step = (LLGestureStepSound*)step;
			const LLUUID& sound_id = sound_step->mSoundAssetID;
			const F32 volume = 1.f;
			send_sound_trigger(sound_id, volume);
			gesture->mCurrentStep++;
			break;
		}
	case STEP_CHAT:
		{
			LLGestureStepChat* chat_step = (LLGestureStepChat*)step;
			std::string chat_text = chat_step->mChatText;
			// Don't animate the nodding, as this might not blend with
			// other playing animations.
			const BOOL animate = FALSE;

			if ( cmd_line_chat(chat_text, CHAT_TYPE_NORMAL, true))
			{
				gChatBar->sendChatFromViewer(chat_text, CHAT_TYPE_NORMAL, animate);
			}
			gesture->mCurrentStep++;
			break;
		}
	case STEP_WAIT:
		{
			LLGestureStepWait* wait_step = (LLGestureStepWait*)step;
			if (wait_step->mFlags & WAIT_FLAG_TIME)
			{
				gesture->mWaitingTimer = TRUE;
				gesture->mWaitTimer.reset();
			}
			else if (wait_step->mFlags & WAIT_FLAG_ALL_ANIM)
			{
				gesture->mWaitingAnimations = TRUE;
				// Use the wait timer as a deadlock breaker for animation
				// waits.
				gesture->mWaitTimer.reset();
			}
			else
			{
				gesture->mCurrentStep++;
			}
			// Don't increment instruction pointer until wait is complete.
			break;
		}
	default:
		{
			break;
		}
	}
}
示例#10
0
void LLNearbyChat::sendChat(LLWString text,EChatType type)
{
	LLWStringUtil::trim(text);

	if (!text.empty())
	{
		if(type == CHAT_TYPE_OOC)
		{
			std::string tempText = wstring_to_utf8str( text );
			tempText = gSavedSettings.getString("FSOOCPrefix") + " " + tempText + " " + gSavedSettings.getString("FSOOCPostfix");
			text = utf8str_to_wstring(tempText);
		}

		// Check if this is destined for another channel
		S32 channel = 0;
		stripChannelNumber(text, &channel);
		// If "/<number>" is not specified, see if a channel has been set in
		//  the spinner.
		if (gSavedSettings.getBOOL("FSNearbyChatbar") &&
			gSavedSettings.getBOOL("FSShowChatChannel") &&
			(channel == 0))
		{
			channel = (S32)(LLFloaterNearbyChat::getInstance()->getChild<LLSpinCtrl>("ChatChannel")->get());
		}
		
		std::string utf8text = wstring_to_utf8str(text);
		// Try to trigger a gesture, if not chat to a script.
		std::string utf8_revised_text;
		if (0 == channel)
		{
//-TT Satomi Ahn - Patch MU_OOC	
			if (gSavedSettings.getBOOL("AutoCloseOOC"))
			{
				// Try to find any unclosed OOC chat (i.e. an opening
				// double parenthesis without a matching closing double
				// parenthesis.
				if (utf8text.find("(( ") != -1 && utf8text.find("))") == -1)
				{
					// add the missing closing double parenthesis.
					utf8text += " ))";
				}
				else if (utf8text.find("((") != -1 && utf8text.find("))") == -1)
				{
					if (utf8text.at(utf8text.length() - 1) == ')')
					{
						// cosmetic: add a space first to avoid a closing triple parenthesis
						utf8text += " ";
					}
					// add the missing closing double parenthesis.
					utf8text += "))";
				}
				else if (utf8text.find("[[ ") != -1 && utf8text.find("]]") == -1)
				{
					// add the missing closing double parenthesis.
					utf8text += " ]]";
				}
				else if (utf8text.find("[[") != -1 && utf8text.find("]]") == -1)
				{
					if (utf8text.at(utf8text.length() - 1) == ']')
					{
						// cosmetic: add a space first to avoid a closing triple parenthesis
						utf8text += " ";
					}
					// add the missing closing double parenthesis.
					utf8text += "]]";
				}
			}

			// Convert MU*s style poses into IRC emotes here.
			if (gSavedSettings.getBOOL("AllowMUpose") && utf8text.find(":") == 0 && utf8text.length() > 3)
			{
				if (utf8text.find(":'") == 0)
				{
					utf8text.replace(0, 1, "/me");
				}
				else if (!isdigit(utf8text.at(1)) && !ispunct(utf8text.at(1)) && !isspace(utf8text.at(1)))	// Do not prevent smileys and such.
				{
					utf8text.replace(0, 1, "/me ");
				}
			}				
//-TT Satomi Ahn - Patch MU_OOC	
			// discard returned "found" boolean
			LLGestureMgr::instance().triggerAndReviseString(utf8text, &utf8_revised_text);
		}
		else
		{
			utf8_revised_text = utf8text;
		}

		utf8_revised_text = utf8str_trim(utf8_revised_text);

		EChatType nType;
		if(type == CHAT_TYPE_OOC)
			nType = CHAT_TYPE_NORMAL;
		else
			nType = type;

		type = processChatTypeTriggers(nType, utf8_revised_text);

		if (!utf8_revised_text.empty() && cmd_line_chat(utf8_revised_text, type))
		{
			// Chat with animation
			sendChatFromViewer(utf8_revised_text, type, gSavedSettings.getBOOL("FSPlayChatAnimation"));
		}
	}

	gAgent.stopTyping();
}