What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » removing emotions?

Pages: (2): « First [ 1 ] 2 » Last »
removing emotions?
Author: Message:
effection
Full Member
***

Destroy The Runner

Posts: 135
Reputation: 4
– / Male / Flag
Joined: Sep 2006
O.P. removing emotions?
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.
03-14-2007 09:01 PM
Profile E-Mail PM Find Quote Report
xsylvain2
Junior Member
**

Avatar
MsgPlus! For Evermore

Posts: 17
50 / Male / –
Joined: Feb 2007
RE: removing emotions?
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

This post was edited on 03-14-2007 at 10:16 PM by xsylvain2.
03-14-2007 09:54 PM
Profile PM Find Quote Report
effection
Full Member
***

Destroy The Runner

Posts: 135
Reputation: 4
– / Male / Flag
Joined: Sep 2006
O.P. RE: removing emotions?
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" :(
03-14-2007 10:10 PM
Profile E-Mail PM Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
36 / Male / Flag
Joined: Aug 2006
RE: removing emotions?
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



This post was edited on 03-15-2007 at 03:52 PM by Spunky.
<Eljay> "Problems encountered: shit blew up" :zippy:
03-15-2007 03:50 PM
Profile PM Find Quote Report
effection
Full Member
***

Destroy The Runner

Posts: 135
Reputation: 4
– / Male / Flag
Joined: Sep 2006
O.P. RE: removing emotions?
but its not returning it to the screen right its still returning the actual original message :(
03-15-2007 04:01 PM
Profile E-Mail PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: removing emotions?
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?
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
03-15-2007 07:17 PM
Profile E-Mail PM Web Find Quote Report
vikke
Senior Member
****

Avatar

Posts: 900
Reputation: 28
31 / Male / Flag
Joined: May 2006
RE: removing emotions?
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
4 8 15 16 23 42
03-15-2007 08:59 PM
Profile E-Mail PM Find Quote Report
effection
Full Member
***

Destroy The Runner

Posts: 135
Reputation: 4
– / Male / Flag
Joined: Sep 2006
O.P. RE: removing emotions?
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\)|\+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_");
}



:S

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...

This post was edited on 03-15-2007 at 09:17 PM by effection.
03-15-2007 09:15 PM
Profile E-Mail PM Find Quote Report
vikke
Senior Member
****

Avatar

Posts: 900
Reputation: 28
31 / Male / Flag
Joined: May 2006
RE: removing emotions?
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".
4 8 15 16 23 42
03-16-2007 09:26 AM
Profile E-Mail PM Find Quote Report
effection
Full Member
***

Destroy The Runner

Posts: 135
Reputation: 4
– / Male / Flag
Joined: Sep 2006
O.P. RE: removing emotions?
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
03-16-2007 04:01 PM
Profile E-Mail PM Find Quote Report
Pages: (2): « First [ 1 ] 2 » Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On