webdevRefinery Forum: The Awesome IRC Bot v2 Bot Framework - webdevRefinery Forum

Jump to content

  • 3 Pages +
  • 1
  • 2
  • 3
  • You cannot start a new topic
  • You cannot reply to this topic

Rate Topic: -----

User is online AwesomezGuy 

  • Certified Asshole™
  • Group: Members
  • Posts: 1245
  • Joined: 08-March 10
  • LocationIreland
  • Expertise:HTML,CSS,PHP,Javascript,SQL

Posted 10 February 2011 - 10:15 AM (#1)

The Awesome IRC Bot v2 Bot Framework


Completely awesome
Awesome IRC Bot v2

Awesome IRC Bot v2 is a massive improvement on my original bot. The new one takes advantage of my new module system, it allows developers to create a fully functional set of modules, distribute them to users a single drag-and-drop install folder, and then allows users to dynamically turn them on and off from IRC.

The project is fully functional and stable, I just want to add a few more touches before v1.0. For now, either grab the latest copy of the source from http://github.com/Aw...y/AwesomeIRCBot
Or, if you need something slightly more stable, download v0.2.0 as a .zip from here:
https://github.com/A.../zipball/v0.2.0

Take a look at the Wiki article on creating modules and have a go at making one.
https://github.com/A...some-IRC-Bot-v2

If you do make one, send me a PM with a download link for the folder, and I'll add it to modules-extras. :)

Comments and suggestions are welcome!
0


User is offline gibbonweb 

  • 兄ヨハネス
  • Group: Members
  • Posts: 2062
  • Joined: 23-June 10
  • LocationMunich(DE)
  • Expertise:HTML,CSS,PHP,Javascript,Python,SQL,Graphics

Posted 10 February 2011 - 10:26 AM (#2)

Maybe I just don't get the concept, but is php really a good language for an irc bot? Do you run the script on the command line? How do you interact with it at runtime (by mapTrigger commands via irc only?)

I'm just asking because I don't know if php has implemented stuff like non-busy waiting, which you'll definitely want to use if that thing is supposed to run for hours...?

/slap me with a trout if this is nonsense I'm writing ;)
0


User is online AwesomezGuy 

  • Certified Asshole™
  • Group: Members
  • Posts: 1245
  • Joined: 08-March 10
  • LocationIreland
  • Expertise:HTML,CSS,PHP,Javascript,SQL

Posted 10 February 2011 - 10:32 AM (#3)

View Postgibbonweb, on 10 February 2011 - 10:26 AM, said:

Maybe I just don't get the concept, but is php really a good language for an irc bot? Do you run the script on the command line? How do you interact with it at runtime (by mapTrigger commands via irc only?)

I'm just asking because I don't know if php has implemented stuff like non-busy waiting, which you'll definitely want to use if that thing is supposed to run for hours...?

/slap me with a trout if this is nonsense I'm writing ;)

This is a CLI based PHP app.
PHP is a crap language for an IRC bot in general, but it has a lot of powerful commands that can be used, which allow advanced integration.
Generally you modify the bot before running it, and then you can edit stuff on the go through IRC by talking to the bot.

But honestly, it's fine to use this as your language. Ruby was not designed for the web, where is it now? The Web.
Any language can be used for any task with enough imagination.

If I knew Java, or had the time to learn it, I would happily use it for the bot, but I don't, so PHP is what I'll be usin'.
0


User is offline gibbonweb 

  • 兄ヨハネス
  • Group: Members
  • Posts: 2062
  • Joined: 23-June 10
  • LocationMunich(DE)
  • Expertise:HTML,CSS,PHP,Javascript,Python,SQL,Graphics

Posted 10 February 2011 - 10:40 AM (#4)

View PostAwesomezGuy, on 10 February 2011 - 10:32 AM, said:

This is a CLI based PHP app.
PHP is a crap language for an IRC bot in general, but it has a lot of powerful commands that can be used, which allow advanced integration.
Generally you modify the bot before running it, and then you can edit stuff on the go through IRC by talking to the bot.

But honestly, it's fine to use this as your language. Ruby was not designed for the web, where is it now? The Web.
Any language can be used for any task with enough imagination.

If I knew Java, or had the time to learn it, I would happily use it for the bot, but I don't, so PHP is what I'll be usin'.

ok, now i get it :)
well, there are things you could do with other languages which you can't do in php. like:
- control the program interactively from the CLI while it is running
- have it run as a daemon in the background
- multithreading
- message queues
- ...

;)
0


User is offline Loopy 

  • Group: Members
  • Posts: 35
  • Joined: 07-February 11

Posted 10 February 2011 - 10:41 AM (#5)

Python can be used for making IRC bots, it's really simple :P
0


User is offline gibbonweb 

  • 兄ヨハネス
  • Group: Members
  • Posts: 2062
  • Joined: 23-June 10
  • LocationMunich(DE)
  • Expertise:HTML,CSS,PHP,Javascript,Python,SQL,Graphics

Posted 10 February 2011 - 10:49 AM (#6)

does fgets() (in Server::getNextLine()) have a default timeout? or could it technically wait for hours....
Just wondering.
Your code looks very clean btw!
0


User is online AwesomezGuy 

  • Certified Asshole™
  • Group: Members
  • Posts: 1245
  • Joined: 08-March 10
  • LocationIreland
  • Expertise:HTML,CSS,PHP,Javascript,SQL

Posted 10 February 2011 - 10:49 AM (#7)

View Postgibbonweb, on 10 February 2011 - 10:40 AM, said:

ok, now i get it :)
well, there are things you could do with other languages which you can't do in php. like:
- control the program interactively from the CLI while it is running
- have it run as a daemon in the background
- multithreading
- message queues
- ...

;)


Why would you want to control it from the CLI? :P
You can easily run PHP as a daemon with screen
Multithreading isn't really needed
Message queues are very much so possible
0


User is offline gibbonweb 

  • 兄ヨハネス
  • Group: Members
  • Posts: 2062
  • Joined: 23-June 10
  • LocationMunich(DE)
  • Expertise:HTML,CSS,PHP,Javascript,Python,SQL,Graphics

Posted 10 February 2011 - 10:49 AM (#8)

View PostLoopy, on 10 February 2011 - 10:41 AM, said:

Python can be used for making IRC bots, it's really simple :P

Python can actually even make you breakfast. true story.
0


User is online AwesomezGuy 

  • Certified Asshole™
  • Group: Members
  • Posts: 1245
  • Joined: 08-March 10
  • LocationIreland
  • Expertise:HTML,CSS,PHP,Javascript,SQL

Posted 10 February 2011 - 10:50 AM (#9)

View Postgibbonweb, on 10 February 2011 - 10:49 AM, said:

does fgets() (in Server::getNextLine()) have a default timeout? or could it technically wait for hours....
Just wondering.
Your code looks very clean btw!

It could wait for as long as is needed :)
However IRC servers ping at a rate of under 2 minutes according the IRC RFC 1459
0


User is offline gibbonweb 

  • 兄ヨハネス
  • Group: Members
  • Posts: 2062
  • Joined: 23-June 10
  • LocationMunich(DE)
  • Expertise:HTML,CSS,PHP,Javascript,Python,SQL,Graphics

Posted 10 February 2011 - 10:52 AM (#10)

View PostAwesomezGuy, on 10 February 2011 - 10:49 AM, said:

Why would you want to control it from the CLI? :P
You can easily run PHP as a daemon with screen
Multithreading isn't really needed
Message queues are very much so possible

You obviously don't need to control it from the CLI. But you *could* technically ;)
Multithreading is nice as soon as your bot wants to join multiple channels. So for now it's definitely not needed I guess.
MessageQueues (in the POSIX) sense are only necessary in a multithread environment anyway, so... okay :rolleyes:
0


User is online AwesomezGuy 

  • Certified Asshole™
  • Group: Members
  • Posts: 1245
  • Joined: 08-March 10
  • LocationIreland
  • Expertise:HTML,CSS,PHP,Javascript,SQL

Posted 10 February 2011 - 10:56 AM (#11)

View Postgibbonweb, on 10 February 2011 - 10:52 AM, said:

You obviously don't need to control it from the CLI. But you *could* technically ;)
Multithreading is nice as soon as your bot wants to join multiple channels. So for now it's definitely not needed I guess.
MessageQueues (in the POSIX) sense are only necessary in a multithread environment anyway, so... okay :rolleyes:

This can join multiple channels :P
Remember, IRC servers send lines to you for every piece ofd activity going on regarding you on the network, once you've joined a second channel you'll receive messages from there too, you don't need to spawn multiple connections to deal with each channel.

Edit: #600 post! :D
0


User is offline gibbonweb 

  • 兄ヨハネス
  • Group: Members
  • Posts: 2062
  • Joined: 23-June 10
  • LocationMunich(DE)
  • Expertise:HTML,CSS,PHP,Javascript,Python,SQL,Graphics

Posted 10 February 2011 - 11:13 AM (#12)

View PostAwesomezGuy, on 10 February 2011 - 10:56 AM, said:

This can join multiple channels :P
Remember, IRC servers send lines to you for every piece ofd activity going on regarding you on the network, once you've joined a second channel you'll receive messages from there too, you don't need to spawn multiple connections to deal with each channel.

Edit: #600 post! :D

ah, that's neat, I didn't know that. Well, then... for connecting to different servers AND letting the bot "know about activity onboth servers at the same time" you would need multithreading. B)
0


User is online AwesomezGuy 

  • Certified Asshole™
  • Group: Members
  • Posts: 1245
  • Joined: 08-March 10
  • LocationIreland
  • Expertise:HTML,CSS,PHP,Javascript,SQL

Posted 10 February 2011 - 11:16 AM (#13)

View Postgibbonweb, on 10 February 2011 - 11:13 AM, said:

ah, that's neat, I didn't know that. Well, then... for connecting to different servers AND letting the bot "know about activity onboth servers at the same time" you would need multithreading. B)

I don't think so :)
Connect to both servers and process one line from each server at a time. Bingo!
0


User is offline gibbonweb 

  • 兄ヨハネス
  • Group: Members
  • Posts: 2062
  • Joined: 23-June 10
  • LocationMunich(DE)
  • Expertise:HTML,CSS,PHP,Javascript,Python,SQL,Graphics

Posted 10 February 2011 - 11:20 AM (#14)

View PostAwesomezGuy, on 10 February 2011 - 11:16 AM, said:

I don't think so :)
Connect to both servers and process one line from each server at a time. Bingo!

and if you're in the execution of getNextLine of a completely idle server/channel for half an hour while they are spamming like hell on a second one you would listen to AFTER this one (but neverending) execution of getNextLine?

Hope I'm not annoying you too much, I'm just trying to make you find points for further improvement (which is kinda hard until now ;)) :lol:
0


User is offline Kyek 

  • Founder of wdR
  • Group: Administrators
  • Posts: 5078
  • Joined: 20-February 10
  • LocationPhiladelphia, PA, USA
  • Expertise:HTML,CSS,PHP,Java,Javascript,Node.js,SQL

Posted 10 February 2011 - 11:40 AM (#15)

PHP doesn't have traditional threading, but it DOES have process forking. That would definitely be the way to handle multiple servers, and also a command-line interface if you wanted one ;-)
0


User is offline gibbonweb 

  • 兄ヨハネス
  • Group: Members
  • Posts: 2062
  • Joined: 23-June 10
  • LocationMunich(DE)
  • Expertise:HTML,CSS,PHP,Javascript,Python,SQL,Graphics

Posted 10 February 2011 - 11:49 AM (#16)

View PostKyek, on 10 February 2011 - 11:40 AM, said:

PHP doesn't have traditional threading, but it DOES have process forking. That would definitely be the way to handle multiple servers, and also a command-line interface if you wanted one ;-)

a quick googling gives me

Quote

What actually happens when you call the pcntl_fork() function is that a child process is spawned which is exactly the same as the parent process and continues processing from the line below the function call.

Excuse me, but that is just horrible compared to C pThread.h. :(
0


User is offline Kyek 

  • Founder of wdR
  • Group: Administrators
  • Posts: 5078
  • Joined: 20-February 10
  • LocationPhiladelphia, PA, USA
  • Expertise:HTML,CSS,PHP,Java,Javascript,Node.js,SQL

Posted 10 February 2011 - 12:09 PM (#17)

View Postgibbonweb, on 10 February 2011 - 11:49 AM, said:

a quick googling gives me

Excuse me, but that is just horrible compared to C pThread.h. :(

Oh, agreed -- PHP's is a direct implementation of C's fork(). You look at the process's PID, then you fork, then you check the PID again. If it's the same, you're the parent process, and if it's different, you're the child. You just set up the instructions for what the parent should do and what the child should do before you fork, then each can do what they need to do. It's nowhere *near* the power that threading would give you, but if you're set on using PHP, it's the only thing in your toolbox ;-).

IRC botting would be a killer way to get familiar with Node.js though. Fully evented platform with asynchronous IO? It would handle your threads FOR you without you even asking for them!
0


User is online AwesomezGuy 

  • Certified Asshole™
  • Group: Members
  • Posts: 1245
  • Joined: 08-March 10
  • LocationIreland
  • Expertise:HTML,CSS,PHP,Javascript,SQL

Posted 10 February 2011 - 03:58 PM (#18)

Would using pcntl_fork() allow you to fork the process into the background so it runs forever?
0


User is offline Kyek 

  • Founder of wdR
  • Group: Administrators
  • Posts: 5078
  • Joined: 20-February 10
  • LocationPhiladelphia, PA, USA
  • Expertise:HTML,CSS,PHP,Java,Javascript,Node.js,SQL

Posted 10 February 2011 - 04:38 PM (#19)

View PostAwesomezGuy, on 10 February 2011 - 03:58 PM, said:

Would using pcntl_fork() allow you to fork the process into the background so it runs forever?

To be honest, I'm not sure. It depends which execution layer it forks to. If it stays a child of your ssh session, no, but it may not. You could write a simple script that checks for the PID, forks, and if the PID is the same, quits. Then use:

ps ax | grep php

To make sure it's still running, disconnect, reconnect, then run that command again :)
0


User is offline gibbonweb 

  • 兄ヨハネス
  • Group: Members
  • Posts: 2062
  • Joined: 23-June 10
  • LocationMunich(DE)
  • Expertise:HTML,CSS,PHP,Javascript,Python,SQL,Graphics

Posted 10 February 2011 - 04:46 PM (#20)

View PostKyek, on 10 February 2011 - 04:38 PM, said:

To be honest, I'm not sure. It depends which execution layer it forks to. If it stays a child of your ssh session, no, but it may not. You could write a simple script that checks for the PID, forks, and if the PID is the same, quits. Then use:

ps ax | grep php

To make sure it's still running, disconnect, reconnect, then run that command again :)

If it was just about letting the thing run even after having closed the shell, you could just execute it in a screen. (right?)
0


Share this topic:


  • 3 Pages +
  • 1
  • 2
  • 3
  • You cannot start a new topic
  • You cannot reply to this topic

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users


Enter your sign in name and password


Sign in options
  Or sign in with these services