Shoutbox

[Request] Bot? - 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: [Request] Bot? (/showthread.php?tid=61411)

[Request] Bot? by h-t on 06-25-2006 at 08:26 PM

Is it possible to make a bot using the scripts? I've tried some things but it didn't work.. Maybe can someone help me if it is possible..


RE: [Request] Bot? by L. Coyote on 06-25-2006 at 08:34 PM

Sure, you can.

The event you should look for is OnEvent_ChatWndReceiveMessage (be aware that it will detect your own messages in this event).

You can then do anything based on what is sent to you.

You can download the complete Scripting Documentation here. :)


RE: [Request] Bot? by h-t on 06-25-2006 at 08:38 PM

code:
[string] OnEvent_ChatWndReceiveMessage(
    [object] ChatWnd,
    [string] Origin,
    [string] Message,
    [enum] MessageKind
);

Its says but I don't understand this.. im new :P
RE: [Request] Bot? by -DRK-panoz on 06-25-2006 at 09:31 PM

I too want to make a bot and am not aware of what I'm doing wrong

code:
function OnEvent_ChatWndReceiveMessage("","","!ver",1)
{
    ChatWnd.SendMessage("This is v1.0.0a");
}

And then in the Debug I get
code:
Error: Expected identifier.
       Line: 1. Code: -2146827278.

Please help. Thanks :)
RE: [Request] Bot? by L. Coyote on 06-25-2006 at 09:38 PM

quote:
Originally posted by -DRK-panoz
code:
function OnEvent_ChatWndReceiveMessage("","","!ver",1)
{
ChatWnd.SendMessage("This is v1.0.0a");
}

No, because the values are passed to the function when it's executed. Thus, it really should be like this:

code:
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind) {
if(Message.substr(0, 4) == "!ver") {
ChatWnd.SendMessage("Version 1.0");
}
}

RE: RE: [Request] Bot? by Mike on 06-25-2006 at 09:41 PM

quote:
Originally posted by -DRK-panoz
I too want to make a bot and am not aware of what I'm doing wrong
code:
function OnEvent_ChatWndReceiveMessage("","","!ver",1)
{
    ChatWnd.SendMessage("This is v1.0.0a");
}

And then in the Debug I get
code:
Error: Expected identifier.
       Line: 1. Code: -2146827278.

Please help. Thanks :)

Your code should be something like:

code:
function OnEvent_ChatWndReceiveMessage(ChatWnd, sOrigin, sMessage, MessageKind)
{
if sMessage == "!ver" {
ChatWnd.SendMessage("This is v1.0.0a");
}
}
(haven't tried this)
RE: RE: [Request] Bot? by cooldude_i06 on 06-25-2006 at 09:45 PM

quote:
Originally posted by -DRK-panoz
I too want to make a bot and am not aware of what I'm doing wrong
code:
function OnEvent_ChatWndReceiveMessage("","","!ver",1)
{
    ChatWnd.SendMessage("This is v1.0.0a");
}

And then in the Debug I get
code:
Error: Expected identifier.
       Line: 1. Code: -2146827278.

Please help. Thanks :)


function OnEvent_ChatWndReceiveMessage("","","!ver",1)
{
ChatWnd.SendMessage("This is v1.0.0a");
}

-------------------------------------------------------------------------------
when you create that function you cant pass arguements, instead you receive parameters, it should be something like

function OnEvent_ChatWndReceiveMessage(objChatWnd, strUser, strMessage, numMessageType)
{
objChatWnd.SendMessage("This is v1.0.0a");
}

objChatWnd is the ChatWnd object that generated the event
strUser is the name of the user who send the text
strMessage is the message
numMessageType is a number corresponding to the type of message

you can use these variables in the function in if statements or something to do what you want

if you want to report the version number when !ver is typed, it should look like

function OnEvent_ChatWndReceiveMessage(objChatWnd, strUser, strMessage, numMessageType)
{
     if(strMessage == "!ver"){
          objChatWnd.SendMessage("This is v1.0.0a");
     }
}
RE: [Request] Bot? by h-t on 06-26-2006 at 11:27 AM

Thanx, it's working :)


RE: [Request] Bot? by Yomeh on 06-26-2006 at 11:58 AM

Here's an idea with that little sample up there break down the code like

quote:
objChatWnd.SendMessage(strUser + " " + strMessage + " " + numMessageType);


Then it shouldnt really be hard just an idea really :$
RE: [Request] Bot? by Yomeh on 06-26-2006 at 12:05 PM

This is what i've come with so far with breaking down the code

code:
function OnEvent_ChatWndReceiveMessage(objChatWnd, strUser, strMessage, numMessageType)
{
     if(strMessage == "Hi") {
     if(strUser != Messenger.MyName){
          objChatWnd.SendMessage("Hi [auto reply]");
     }
  }
}


It only replys to messages from your other contacts
can someone correct me if i'm wrong not really an expert lol!
RE: [Request] Bot? by mathieumg on 06-26-2006 at 12:16 PM

According to that line "if(strUser != Messenger.MyName)", it should, but I did not test it.


RE: [Request] Bot? by Yomeh on 06-26-2006 at 12:18 PM

Yeah it does work but can someone help me just wondering about the case select, because Case doesn't seem to work


RE: [Request] Bot? by Matti on 06-26-2006 at 12:52 PM

I made a small script, you can edit the OnEvent_ChatWndReceiveMessage() function and replace the texts with whatever you want. But keep in mind: I converted the Message to lower case first so HeLLo and heLlO will both be parsed. :)

Enjoy! :D


RE: [Request] Bot? by Matti on 06-26-2006 at 01:49 PM

Yes, I'm sorry for not explaining how to get it working.

  1. Open a conversation with the person you want to be the bot from.
  2. Type and send the command /startbot to start the bot feature.
  3. Now, if the person says e.g. "Hi there!", you automaticly reply with "Hey (user)!" where (user) is the person who send you "Hi there!". :)
  4. This also works with "How are you?" and "Wazzup?", you will reply with the message "I'm fine! :) And how are you?"
  5. To stop the bot for this person, just type /stopbot. This will disable the bot from sending messages to this person, but will still work on other persons. ;)
To add more automatic replies, add the following code:
code:
var gotThanks = msg.indexOf("thanks");
var gotThnx = msg.indexOf("thnx");
var gotThankyou = msg.indexOf("thank u");
if(gotThanks != -1 || gotThnx != -1 || gotThankyou) {
ChatWnd.SendMessage("No problem, " + User + "! ;)");
}
or something likely at this location:
code:
if(gotWhatsUp != -1 || gotWazzup != -1 || gotHowAreYou != -1) {
ChatWnd.SendMessage("I'm fine! :)\nAnd how are you?");   
}
//Here the new code :)
}
I also updated the attachment, I left a small bug behind... :$
RE: [Request] Bot? by Matti on 06-26-2006 at 02:02 PM

It seems like I forgot to place "= -1" behind some expression. :-/
Try to download the new file, it now contains a menu in the chat window! ;)


RE: [Request] Bot? by -dt- on 06-26-2006 at 02:22 PM

quote:
Originally posted by Mattike
var gotThanks = msg.indexOf("thanks");
var gotThnx = msg.indexOf("thnx");
var gotThankyou = msg.indexOf("thank u");
if(gotThanks != -1 || gotThnx != -1 || gotThankyou) {
ChatWnd.SendMessage("No problem, " + User + "! ;)");
}

thats got to be the worst code Ive ever seen , even segosa wouldnt do that :--o.

code:
if(msg.match(/thanks|thnx|thank u/)){
ChatWnd.SendMessage("No problem, " + User + "! ;)");
}


RE: RE: [Request] Bot? by segosa on 06-26-2006 at 02:35 PM

quote:
Originally posted by -dt-
quote:
Originally posted by Mattike
var gotThanks = msg.indexOf("thanks");
var gotThnx = msg.indexOf("thnx");
var gotThankyou = msg.indexOf("thank u");
if(gotThanks != -1 || gotThnx != -1 || gotThankyou) {
ChatWnd.SendMessage("No problem, " + User + "! ;)");
}

thats got to be the worst code Ive ever seen , even segosa wouldnt do that :--o.


* segosa slaps -dt-.

Anyway, I would even suggesdt making a txt file or something in the format

word1:word2:word3:wordN|reply

and parsing that, seeing if any of the words are in the msg and then replying with reply. (In fact that's the format I used for an autoresponder in mIRC script.)
RE: [Request] Bot? by Matti on 06-26-2006 at 02:37 PM

Hmm... never thought about that. Thnx -dt- and segosa! :D


RE: [Request] Bot? by novolo on 06-26-2006 at 04:35 PM

Instead of doing the msg.match thing like in here..

code:
if(msg.match(/thanks|thnx|thank u/)){
ChatWnd.SendMessage("No problem, " + User + "! ");
}

isn't there a way like:  msg.contains    or something like that?

because if we use msg.match,  me message recieved has to be exactly like that,  instead is it contains certain words we can gues what he's talkiing about and return something close...

any ideas?
RE: [Request] Bot? by Plik on 06-26-2006 at 05:09 PM

quote:
Originally posted by novolo
Instead of doing the msg.match thing like in here..
code:
if(msg.match(/thanks|thnx|thank u/)){
ChatWnd.SendMessage("No problem, " + User + "! ");
}

isn't there a way like:  msg.contains    or something like that?

because if we use msg.match,  me message recieved has to be exactly like that,  instead is it contains certain words we can gues what he's talkiing about and return something close...

any ideas?
Erm match does test if the message contains the words.
match is is a regexp function
RE: [Request] Bot? by Lou on 06-26-2006 at 06:01 PM

quote:
Originally posted by h-t
Is it possible to make a bot using the scripts? I've tried some things but it didn't work.. Maybe can someone help me if it is possible..
When I fully understand the gui, I'm going to be making A full bot script, where all you have to do is add stuff to the window, and the script will do the rest;) Stay tuned!

(I'm going to start working on this script tommorow and I hope it'll be done by next week or the week after:))
RE: [Request] Bot? by can16358p on 06-26-2006 at 06:32 PM

I'm developing a bot, and yes, I see that we can really develop bots with scripting. My bot has a super slang-talking (Turkish) engine :)


RE: RE: [Request] Bot? by can16358p on 06-26-2006 at 06:34 PM

quote:
Originally posted by novolo
Instead of doing the msg.match thing like in here..
code:
if(msg.match(/thanks|thnx|thank u/)){
ChatWnd.SendMessage("No problem, " + User + "! ");
}

isn't there a way like:  msg.contains    or something like that?

because if we use msg.match,  me message recieved has to be exactly like that,  instead is it contains certain words we can gues what he's talkiing about and return something close...

any ideas?


use
if(msg.indexOf(stringToSearch)!=-1)...
RE: RE: [Request] Bot? by can16358p on 06-26-2006 at 06:41 PM

quote:
Originally posted by Mr. G
ah! c'mon anyone plz finish ur bot soon I beg u :'(

Mr. G


Don't expect a super intelligent bot, or something like SmarterChild, from anyone, at least soon.

Building up bots require a lot of time.
I mean the Artificial Intelligence is really hard to develop.
RE: RE: RE: [Request] Bot? by JonnyT on 06-26-2006 at 06:45 PM

quote:
Originally posted by segosa

Anyway, I would even suggesdt making a txt file or something in the format

word1:word2:word3:wordN|reply

and parsing that, seeing if any of the words are in the msg and then replying with reply. (In fact that's the format I used for an autoresponder in mIRC script.)


how would we do somthing like that in javascript? i mean the read writeto the file and parsing it?

Thanks J