removing emotions? - Printable Version
-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: removing emotions? (/showthread.php?tid=72652)
removing emotions? by effection on 03-14-2007 at 09:01 PM
well im having trouble removing emotions from messages sent to me.
I have code that detects all the default emoticons and custom ones as well, i then call code: Message = Message.replace(data, " ");
which replaces the emoticon shortcut code in the incoming message fine when printed to the Debug output but in the actual chat window the emoticon is still there. Any ideas why this isn't working or why it maybe cant be done?
thanks.
RE: removing emotions? by xsylvain2 on 03-14-2007 at 09:54 PM
quote: Originally posted by effection
well im having trouble removing emotions from messages sent to me.
I have code that detects all the default emoticons and custom ones as well, i then call code: Message = Message.replace(data, " ");
which replaces the emoticon shortcut code in the incoming message fine when printed to the Debug output but in the actual chat window the emoticon is still there. Any ideas why this isn't working or why it maybe cant be done?
thanks.
To remove emoticon :
code: function RemoveEmoticons(Text) {
// very dodgy routine, this needs to be made better (and custom emoticons need to be included too )
var DefIcons = new Array(
'8o\\|', '8\\-\\)', ':[\\-]?D', ':[\\-]?O', ':[\\-]?P', ':[\\-]?S', ':[\\-]?\\$', ':[\\-]?\\(', ':[\\-]?\\)',
':[\\-]?\\@', ':[\\-]?\\[', ':[\\-]?\\|', ':\\-\\#', ':\\-\\*', ':\\^\\)', ':[\\-]?\\>', ':[\\-]?\\<',
'\\(AP\\)', '\\(AU\\)', '\\(A\\)', '\\(BAH\\)', '\\(BRB\\)', '\\(B\\)', '\\(CI\\)', '\\(CO\\)', '\\(C\\)',
'\\(D\\)', '\\(E\\)', '\\(F\\)', '\\(G\\)', '\\(H5\\)', '\\(H\\)', '\\(IP\\)', '\\(I\\)', '\\(K\\)',
'\\(LI\\)', '\\(L\\)', '\\(MO\\)', '\\(MP\\)', '\\(M\\)', '\\(N\\)', '\\(NAH\\)', '\\(O\\)', '\\(PI\\)',
'\\(PL\\)', '\\(P\\)', '\\(R\\)', '\\(SN\\)', '\\(SO\\)', '\\(ST\\)', '\\(S\\)', '\\(TU\\)', '\\(T\\)',
'\\(UM\\)', '\\(U\\)', '\\(W\\)', '\\(XX\\)', '\\(X\\)', '\\(YN\\)', '\\(Y\\)', '\\(Z\\)', '\\(\\&\\)',
'\\(\\*\\)', '\\(\\@\\)', '\\(\\^\\)', '\\(\\{\\)', '\\(\\}\\)', '\\(\\~\\)', '\\+o\\(', '\\^o\\)', '\\|\\-\\)');
for (var i in DefIcons) {
//Debug.Trace('Going through... ' + i + ' => ' + DefIcons[i]);
Text = Text.replace(eval('/' + DefIcons[i] + '/ig'), "");
}
return Text.replace(/\s{2}/ig, " ").replace(/^[\s|\n|\r\n|\t]+|[\s|\n|\r\n|\t]+$/g, "");
}
Like this:
Merlin.Speak(RemoveEmoticons(MsgPlus.RemoveFormatCodes(Contact.Name+Message+TimeD()))+"!")
This exemple was made whit Merlin, but it work. Change Merlin.Speak by other things
RE: removing emotions? by effection on 03-14-2007 at 10:10 PM
no if you read my first post i can do that (thanks anyway) but its when it comes to displaying it for example
code:
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind){
return RemoveEmoticons(Message);
}
if get a message for example like so "Hello "
i still get the same message "Hello " not "Hello"
RE: removing emotions? by Spunky on 03-15-2007 at 03:50 PM
code: var emotes = new Array( "","" ) //Array of emoticons
for(var i=0;i<=emotes.length;i++){
Message = Message.replace(/emotes[i]/g," ");
}
return Message;
As far as I can tell (without testing), that should work fine
RE: removing emotions? by effection on 03-15-2007 at 04:01 PM
but its not returning it to the screen right its still returning the actual original message
RE: removing emotions? by Matti on 03-15-2007 at 07:17 PM
Instead of guessing, try to check your codes!
@xsylvain2: eval() is evil, try to avoid using it.
@Spunky: The brackets will be recognized as a character set in a regular expression!
The correct way to use an array as replacement input, would look like:
code: var data = new Array(":)", ":("); //This should contain your captured emoticons
for(i=0; i<data.length; i++) //Or shorter: for(i in data)
{
Message = Message.replace(new RegExp(data[i], "gi"), " "); //WARNING: See further[/i]
}
A note here is that the captured emoticon codes should be escaped before you use them in the regular expression. If I have some time, I could write a function which escapes the right characters and eventually return a regular expression so you don't even need the new RegExp(), but simply can use something like EscapeRegExp(data[i]). Send me a PM if you want me to start work on it.
And, could you please give us the full code and show us what exactly is in the data array? So we can better understand the structure you use in the script?
RE: removing emotions? by vikke on 03-15-2007 at 08:59 PM
To remove custom emoticons you can use:
code: function RemoveCustomEmot(sString)
var Emoticons = Messenger.CustomEmoticons;
var e = new Enumerator(Emoticons);
for(; !e.atEnd(); e.moveNext())
{
var Emoticon = e.item();
sString.replace(Emoticon.Shortcut, 0);
}
return sString;
}
Please note that this wont work in MP!L versions older than Messenger Plus! Live 4.10.
vikke
RE: removing emotions? by effection on 03-15-2007 at 09:15 PM
okay, here is basically what my script is there's other things added to it but this most simplest version and it wont even work.
code: function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind){
var EmoCI = /((-?(\)|D|>|O|P|\(|<|@|S|\$|\||\[)|-(\*|#))|'\()|;-?\)|\([A-IK-PRTUW-Z068@&{}#%*~^]\))/ig
var EmoCS = /(8(o\||-\))|<\)|\+o\(|\((brb|pi|\|\||sn|bah|tu|pl|ip|li|st|um|co|mp|ap|au|so|ci|yn|h5|xx|mo)\))/g
if(Message == ""){Debug.trace("SMILE!!");Message = "replaced!";}
return Message;//Message.replace(EmoCI, "_emoticon removed_");
}
even this wont work if an emoticon was sent
code: function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind){
return "removed";
}
i have worked out though that if i sent a message "1234" and replaced it with "123456789" only "1234" would be displayed because msn must still remember the length of the sent message but even if i replace the emotion"" with a 2 character long replacement makes no difference
@vikke - that will only remove custom emoticons that you have, and not ones sent by the other contact (unless you also have the same emoticon with the same shortcut) but i can find custom emoticons sent fine i just need to get this replacement function working...
RE: removing emotions? by vikke on 03-16-2007 at 09:26 AM
Oh yeah, I got ya!
If you read in the scripting documentation, it says:
quote: A string containing the message to be displayed in the chat window instead of Message. If you do not want to modify the message, simply return Message without changing it. The new string will be parsed for possible format codes. It is important to remember that the new message cannot be longer than the original one (Message.length) and will be cut if necessary. Also, Messenger will not re-parse the message for emoticons codes.
That is your problem. It will only show the 4 first numbers of "123456789", which are "1234".
RE: removing emotions? by effection on 03-16-2007 at 04:01 PM
but that is not my problem i was just saying that it wasn't my problem, my problem is the fact that the emoticon images are still not being replaced
RE: removing emotions? by Matti on 03-16-2007 at 07:55 PM
Now we understand you!
If you don't want to see any emoticons, go in your Messenger settings to Messages and uncheck the "Show default emoticons" and "Show custom emoticons". I can't check this at this moment since I can't reach the Messenger servers for some reason... sigh...
|