BeBot - An Anarchy Online and Age Of Conan chat automaton

Archive => Anarchy Online Archive => BeBot 0.4 support => Topic started by: DocJones on June 19, 2008, 01:50:34 pm

Title: MSN module for BeBot
Post by: DocJones on June 19, 2008, 01:50:34 pm
Heyas,

i am currently working on a MSN interconnection for BeBot to allow MSN Messenger chatting into the game. However, i am a little stuck with message handling:
I have a receive function that gets called via cron["1sec"] every second, but within that second, on the inbound buffer i can have more than one message. Unfortunately the messages are not seperated, so i cant handle them properly.
Is there a possibility to start a background thread from within the bot in any kind to allow a better polling of the connection? Or even a *gasp* event driven mechanism (to react only if there are data on the tcp socket)?

Any help appreciated.
/M
Title: Re: MSN module for BeBot
Post by: Alreadythere on June 22, 2008, 10:20:24 am
You could hook directly into the callback() function inside Main.php. Or the cron() function inside Bot.php. Both those functions are called whenever the chat class polls for new input from the chat-server.
Title: Re: MSN module for BeBot
Post by: DocJones on June 22, 2008, 08:35:52 pm
Currently i set up cron every second, but there are often more than one data packet arriving within one second. How does the callback function work?

Title: Re: MSN module for BeBot
Post by: Alreadythere on June 22, 2008, 08:52:26 pm
callback() is called every time the socket connection to the ao chat server is polled, which is several times each second from my experience.
Title: Re: MSN module for BeBot
Post by: Temar on June 22, 2008, 09:04:14 pm
are you unable to split what you get up?
Title: Re: MSN module for BeBot
Post by: DocJones on June 23, 2008, 08:10:55 am
No, not really. i found the basic msn module on the net and revamping it to fit into the structure. However, i am not that skilled php programmer and the code is quite undocumented. I think i need to get a debug environment to get a better understanding. Any hints on that?

regards
Title: Re: MSN module for BeBot
Post by: DocJones on June 23, 2008, 11:42:51 am
Heyas,

on a quick sidenote: my debugging output of a 1sec cron looks like this:
Code: [Select]
....
Invbot [2008-06-23 09:29:07]    [MSN]   [CRON]  RX
Invbot [2008-06-23 09:29:07]    [MSN]   [CRON]  TX
Invbot [2008-06-23 09:29:09]    [MSN]   [CRON]  RX
Invbot [2008-06-23 09:29:09]    [MSN]   [CRON]  TX
Invbot [2008-06-23 09:29:11]    [MSN]   [CRON]  RX
Invbot [2008-06-23 09:29:11]    [MSN]   [CRON]  TX
Invbot [2008-06-23 09:29:13]    [MSN]   [CRON]  RX
Invbot [2008-06-23 09:29:13]    [MSN]   [CRON]  TX
Invbot [2008-06-23 09:29:15]    [MSN]   [CRON]  RX
Invbot [2008-06-23 09:29:15]    [MSN]   [CRON]  TX
Invbot [2008-06-23 09:29:17]    [MSN]   [CRON]  RX
Invbot [2008-06-23 09:29:17]    [MSN]   [CRON]  TX
Invbot [2008-06-23 09:29:19]    [MSN]   [CRON]  RX
Invbot [2008-06-23 09:29:19]    [MSN]   [CRON]  TX
Invbot [2008-06-23 09:29:21]    [MSN]   [CRON]  RX
Invbot [2008-06-23 09:29:21]    [MSN]   [CRON]  TX
Invbot [2008-06-23 09:29:23]    [MSN]   [CRON]  RX
Invbot [2008-06-23 09:29:23]    [MSN]   [CRON]  TX
...

Anyone noticed, that the 1sec handler is acutally being called every 2 sec?

regards
/K
Title: Re: MSN module for BeBot
Post by: Alreadythere on June 23, 2008, 10:04:28 pm
Yes, can look like that. 1sec cron time only guarantees that at least one second is between two executions of the cron job, it doesn't guarantee any minimum interval if some other load is there.
Title: Re: MSN module for BeBot
Post by: DocJones on June 25, 2008, 04:01:42 pm
ooookkkkeeii,

got it working so far. Only problem is: i want to listen the Msn-class to all "/tell" commands (currently "/tell <botname> !msn <text>" works). I tried to set up $commands["tell"][] = &$msn; to hook upon all tells, but that doesn't work. The bot simply send me a "/tell <botname> !help" back. Any help, please?

regards

Title: Re: MSN module for BeBot
Post by: Alreadythere on June 25, 2008, 04:42:26 pm
The tells pseudo-channel should be what you are looking for. It hands all incoming tells that aren't commands over to registering modules. There you have to do any access checks yourself.

$commands["tells"][] = &$msn;
SimplePortal 2.3.7 © 2008-2024, SimplePortal