I am using the a SmartIRC library for this. What I need to be able to do is have the bot running and accepting commands from users, and also listening on a UDP socket. I get data sent through the UDP socket that I need to analyze, sort into MySQL tables and such. I need that UDP data to be available to my BOT.
So the problem is, whenever I open a UDP socket it listens to all the data in a 'while' loop. So it means that the IRC bot itself is un-functional until the loop is over and closed. I thought about using some kind of a multi-threading solution, but I am not sure how. I need to find some way to spawn a new thread of the UDP socket, and send that data to my currently running bot. ah, no clue.
Any ideas? Hopefully I explained it enough so you guys can understand what the hell I want.
Thanks!
I'm not sure why you're listening for data in a while loop. When I have used SmartIRC in the past I use $irc->registerActionhandler()
for the user commands and then call $irc->listen( )
, that way the library handles it all for you.
Some good examples of using SmartIRC can be found here , hopefully they will help you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.