Shoutbox

Autotext + Name! - 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: Autotext + Name! (/showthread.php?tid=64887)

Autotext + Name! by Gropfi on 08-14-2006 at 03:59 AM

Hi,

is it possible to write a script that say

Auto text like "hi" and then the nickname of the user?

Like:

Wayne says:
Hi
Me says:
Hi Wayne

Barbie says
Hi
Me says
Hi Barbie

Just example names ;)
But is it possible anyway?


RE: Autotext + Name! by Felu on 08-14-2006 at 04:17 AM

Yes its possible [Image: msn_grin.gif]. Use the code below [Image: msn_tongue.gif].

code:
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind){ //When a Message is Recieved
    if (Origin != Messenger.MyName){ //If the Message is not send by me
        if (Message.substr(0,2) == 'Hi'){ //If the first two letters of the message are Hi
           ChatWnd.SendMessage('Hi '+Origin); //Send a Message Hi <Who said Hi>
           }
        }
    }


RE: Autotext + Name! by ddunk on 08-14-2006 at 04:19 AM

quote:
Originally posted by -!Felu!-
Yes its possible [Image: msn_grin.gif]. Use the code below [Image: msn_tongue.gif].
code:
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind){
if (Origin != Messenger.MyEmail){
    if (Message.substr(0,2) == 'Hi'){
       ChatWnd.SendMessage('Hi '+Origin);
       }
    }
}


Origin is the name, not the email.
code:
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind){
if (Origin != Messenger.MyName){
    if (Message.substr(0,2) == 'Hi'){
       ChatWnd.SendMessage('Hi '+Origin);
       }
    }
}

RE: Autotext + Name! by Gropfi on 08-14-2006 at 07:02 AM

He is still writing.. Hi +Origin
is it my failure?
just copyed it...


RE: Autotext + Name! by H-Des on 08-14-2006 at 12:11 PM

It is working correct here.

Only remind that if both users would use this script you will get in a loop which you can't end...


RE: RE: Autotext + Name! by RaceProUK on 08-14-2006 at 02:27 PM

code:
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind){
if (Origin != Messenger.MyName){
    if (Message.match("^[Hh][Ii]$"){
       ChatWnd.SendMessage('Hi '+Origin);
       }
    }
}
won't loop. And it's case insensitive.
RE: Autotext + Name! by Gropfi on 08-17-2006 at 07:02 AM

Ok iŽll try it again. THX
but only i am using the script... :D

with Hi it worked.. :)

but the script is stopped know...
what is wrong in this?

code:
*/   
var hi = 'Hi +Origin (:'
var on = '1'

function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind){
if (Origin != Messenger.MyName){
if (Message.substr(0,2) == 'Hi'){
ChatWnd.SendMessage('Hi '+Origin (: );
}
if (Message.substr(0,2) "Hallo")
{
ChatWnd.SendMessage('Hi '+Origin (: );
}
if (Message.substr(0,2) "hallo")
{
ChatWnd.SendMessage('Hi '+Origin (: );
}
if (Message.substr(0,2) "Hi@")
{
ChatWnd.SendMessage('Hi '+Origin (: );
}
if (Message.substr(0,2) "hi@")
{
ChatWnd.SendMessage('Hi '+Origin (: );
}
if (Message.substr(0,2) "Hello")
{
ChatWnd.SendMessage('Hi '+Origin (: );
}
if (Message.substr(0,2) "hello")
{
ChatWnd.SendMessage('Hi '+Origin (: );
}
if (Message.substr(0,2) "hi*")
{
ChatWnd.SendMessage('Hi '+Origin (: );
}
if (Message.substr(0,2) "Seas")
{
ChatWnd.SendMessage('Hi '+Origin (: );
}
if (Message.substr(0,2) "seas")
{
ChatWnd.SendMessage('Hi '+Origin (: );
}
if (Message.substr(0,2) "Zeas")
{
ChatWnd.SendMessage('Hi '+Origin (: );
}
if (Message.substr(0,2) "zeas")
{
ChatWnd.SendMessage('Hi '+Origin (: );
}
if (Message.substr(0,2) "huhu")
{
ChatWnd.SendMessage('Hi '+Origin (: );
}
if (Message.substr(0,2) "Huhu")
{
ChatWnd.SendMessage('Hi '+Origin (: );
}
if (Message.substr(0,2) "moin")
{
ChatWnd.SendMessage('Hi '+Origin (: );
}
if (Message.substr(0,2) "Moin")
{
ChatWnd.SendMessage('Hi '+Origin (: );
}
if (Message.substr(0,2) "morgen")
{
ChatWnd.SendMessage('Hi '+Origin (: );
}
if (Message.substr(0,2) "Morgen")
{
ChatWnd.SendMessage('Hi '+Origin (: );
}
if (Message.substr(0,2) "servus")
{
ChatWnd.SendMessage('Hi '+Origin (: );
}
if (Message.substr(0,2) "Servus")
{
ChatWnd.SendMessage('Hi '+Origin (: );
}
if (Message.substr(0,2) "tag")
{
ChatWnd.SendMessage('Hi '+Origin (: );
}
if (Message.substr(0,2) "Tag")
{
ChatWnd.SendMessage('Hi '+Origin (: );
}
if (Message.substr(0,2) "servas")
{
ChatWnd.SendMessage('Hi '+Origin (: );
}
if (Message.substr(0,2) "Servas")
{
ChatWnd.SendMessage('Hi '+Origin (: );
}
}
}
}

if (Message.substr(0,4) "hello")
{
ChatWnd.SendMessage('Hi '+Origin (: );
}


Something like this?
Im not a perfect coder so sry :/
Still a hobby ;)
RE: Autotext + Name! by RaceProUK on 08-17-2006 at 08:24 AM

quote:
Originally posted by Gropfi
'Hi '+Origin (:
should be
'Hi '+Origin + '(:'
RE: Autotext + Name! by Silentdragon on 08-17-2006 at 08:26 AM

If you like I could add this as an option in Answer Machine Plus.


RE: Autotext + Name! by Gropfi on 08-17-2006 at 09:37 AM

If you want ;)
But iŽll try it now by my own, with a little help ;)


Hmm the script is still Stopped...
Not working :/


RE: Autotext + Name! by markee on 08-17-2006 at 09:55 AM

Why don't you use a for statement and arrays. Rather than all those if statement you only need one and you can then use Array[i].length for the length of the string rather than specifying a number.

EDIT: I thought I might help you out by giving you an example of what I was trying to say incase you didn't understand.  I just fixed up the code that you had posted.

code:
*/
var hi = 'Hi +Origin (:'
var on = '1'
var Array = new Array('HI","HALLO","HI@","HELLO","SEAS","ZEAS","HUHU","MOIN,"MORGEN","SERVUS","TAG","SERVAS");
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind){
if (Origin != Messenger.MyName){
Message = Message.toUpperCase()
for(i=0;i<Array.length;i++){
if (Message.substr(0,Array[i].lenght-1) == Array[i]){
ChatWnd.SendMessage('Hi ' + Origin + " (:" );
}
}
}
}
This will make it easier to extend on the script easier and fix any problem that you come accross because it is smaller and easier to read.
RE: Autotext + Name! by Gropfi on 08-17-2006 at 10:26 AM

AhRR :D

Thx...
i think i should read more tuts and learn more ;)

thanks ;)


RE: Autotext + Name! by markee on 08-17-2006 at 10:29 AM

If you don't like looking up MSDN all the time you can download a copy of it too right here.  I hope this is as useful to you as it has been to me.


RE: Autotext + Name! by CookieRevised on 08-17-2006 at 10:43 AM

quote:
Originally posted by markee
If you don't like looking up MSDN all the time you can download a copy of it too right here.  I hope this is as useful to you as it has been to me.
It should be mandatory for anyone who script, alongside the Plus! scripting documentation tbh....
RE: RE: Autotext + Name! by Mike on 08-17-2006 at 11:52 AM

quote:
Originally posted by H-Des
It is working correct here.

Only remind that if both users would use this script you will get in a loop which you can't end...

No it won't.

MP!L has a flood protection on scripts ;)
RE: RE: RE: Autotext + Name! by H-Des on 08-17-2006 at 01:15 PM

quote:
Originally posted by Mike
No it won't.

MP!L has a flood protection on scripts ;)


Ok, if you say so ... ;)

It came in a loop when I tested it by using 2 msn accounts at the same pc. But I didn't test it on another pc. ;)
RE: Autotext + Name! by CookieRevised on 08-19-2006 at 09:37 AM

quote:
Originally posted by Gropfi
what is wrong in this?
code:
var hi = 'Hi +Origin (:'

var hi = 'Hi' +Origin + '(:' ;

Origin is a variable. The rest is text (and thus must be enclosed in parenthesis).
Also don't forget to end each line with ";".

quote:
Originally posted by Gropfi
code:
ChatWnd.SendMessage('Hi '+Origin (: );

ChatWnd.SendMessage('Hi '+ Origin + '(:');

same reason as above.

quote:
Originally posted by Gropfi
code:
if (Message.substr(0,2) "morgen") {
and similar lines

if (Message.substr(0,6) == "morgen") {

You make a comparisson, so you need a comparisson operator between the two.

substr() is a function which takes a substring out of a given string. The syntax is substr(start,end). Since the length of "morgen" is 6 characters you need to specify to get the first 6 characters in the substr function which is done by substr(0, 6).


quote:
Originally posted by H-Des
It came in a loop when I tested it by using 2 msn accounts at the same pc. But I didn't test it on another pc.
It should have exactly the same outcome.

To avoid looping use regular expressions like RacePROuk showed. And with regular expressions you can also do what markee showed using an array btw.

RE: Autotext + Name! by Sunshine on 08-19-2006 at 10:31 AM

quote:
Originally posted by Silentdragon
If you like I could add this as an option in Answer Machine Plus.
Psttt... it's already possible with your script....people forget about the Plus! tags like (!N) ;)

Received: hi
Answer: hi (!N)
This outputs: hi <contact's friendly name>