collapse collapse
* User Info
 
 
Welcome, Guest. Please login or register.
* Search

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18365
  • stats Total Topics: 2500
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 1144

Author Topic: MSN module for BeBot  (Read 14269 times)

0 Members and 1 Guest are viewing this topic.

Offline DocJones

  • BeBot Rookie
  • *
  • Posts: 15
  • Karma: +0/-0
MSN module for BeBot
« 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

Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: MSN module for BeBot
« Reply #1 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.

Offline DocJones

  • BeBot Rookie
  • *
  • Posts: 15
  • Karma: +0/-0
Re: MSN module for BeBot
« Reply #2 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?


Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: MSN module for BeBot
« Reply #3 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.

Offline Temar

  • Contributor
  • *******
  • Posts: 1140
  • Karma: +0/-0
    • AoFiles
Re: MSN module for BeBot
« Reply #4 on: June 22, 2008, 09:04:14 pm »
are you unable to split what you get up?

Offline DocJones

  • BeBot Rookie
  • *
  • Posts: 15
  • Karma: +0/-0
Re: MSN module for BeBot
« Reply #5 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

Offline DocJones

  • BeBot Rookie
  • *
  • Posts: 15
  • Karma: +0/-0
Re: MSN module for BeBot
« Reply #6 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

Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: MSN module for BeBot
« Reply #7 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.

Offline DocJones

  • BeBot Rookie
  • *
  • Posts: 15
  • Karma: +0/-0
Re: MSN module for BeBot
« Reply #8 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


Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: MSN module for BeBot
« Reply #9 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;

 

* Recent Posts
0.8.x updates for AO by bitnykk
[June 23, 2024, 03:19:47 pm ]


0.8.x updates for AoC by bitnykk
[June 23, 2024, 03:19:44 pm ]


[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 pm ]


BeBot still alive & kicking ! by bitnykk
[December 17, 2023, 12:58:44 am ]


Bebot and Rasberry by bitnykk
[November 29, 2023, 11:04:14 pm ]

* Who's Online
  • Dot Guests: 190
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.
* Forum Staff
bitnykk admin bitnykk
Administrator
Khalem admin Khalem
Administrator
WeZoN gmod WeZoN
Global Moderator
SimplePortal 2.3.7 © 2008-2024, SimplePortal