Emotions and actions greatly enrich the fun of chatting. Generally, two methods are used in chatting rooms to send buttons. (1) the button menu is selected in a fixed drop-down menu, find your satisfied expression, select it, and press the send button to send it (2) manually enter the code such as NetEase's manual input // hello represents a welcome action, it is represented by // bye, which greatly enriches the fun of chatting. Generally, the chat room is sent in two ways.
(1) button menu method
Select from a fixed drop-down menu, find your satisfied expression, select it, and press the send button to send it.
(2) manually enter the code
For example, NetEase's manual input // hello represents a welcome action, and // bye represents a goodbye action.
Here we will introduce the specific implementation of the menu. do not introduce manual input! Haha! Unless you cannot remember those...
1. select the implementation of emoticons from the drop-down menu.
For the convenience of expansion, we have created a data file for emojis, which will be very convenient for future expansion.
The format of the emoticon action file is as follows ($ split represents the delimiter ):
// 1234 $ split "1234567, where are my friends? 1234 !!!!!"
//? $ Split looks at the object with doubts...
//?? $ Split: Yes, I have broken my head and I have not come up with a solution.
//??? $ Split what's going on? What the hell is going on?
The previous // 1234 represents the emoticon action code. the separator represents the emoticon action displayed. Note that the two words of the object will be replaced with the name of the Speaker during display.
This code is used to write the corresponding emoticon code selected from the menu to the sending bar.
Script
Function changemote ($ newemote)
{
Document. inputform. msg. value = $ newemote
}
Script
This code generates a dynamic menu
Action $ Emotemsg = file ($ emotefilename );For ($ I = 0; $ I{$ Msg = split ($ split, $ emotemsg [$ I], 99 );Print ("$ Msg [1]");}?>
In this way, the process of selecting an action expression from the menu is completed.
2. processing of emoticon actions in the speech processing program
Messagesend. php
// Read the emoticons file
$ Emote3 = file ($ emotefilename );
$ Emote3number = count ($ emote3 );
For ($ kk = 0; $ kk <$ emote3number; $ kk ++)
{
// Separate each emotion
$ Emote = split ($ split, chop ($ emote3 [$ kk]), 99 );
// If the speech content is equal to the emoticons
If ($ message = $ emote [0])
{
// Replace the object in the emoticon action with the actual chat object name
$ Emote [1] = ereg_replace ("object", "$ talkto", $ emote [1]);
// Change the speech content to the action expression content
$ Message = "$ name> ". $ Emote [1];
Break;
}
}
?>
In this way, we can implement expressions and actions. if we do a program function that automatically adds emotices, it will increase the entertainment of chat!
Original Author: howtodo
Source: php2000.com