Page 1 of 1

PHP IRC Bot

Posted: Thu Aug 31, 2006 4:09 pm
by phpinfo
Eggdrop has been around for a while and I noticed recently someone came up with a PHP solution, curiously named Hotnsour. It's released under a BSD license so it's open source, and they claim that PHP scripts can be dynamically loaded... sounds pretty awesome considering all the SIGHUPing I've had to do with good ole eggy.

Plus I hate tcl, no matter how cute it tries to sound :x

Has anyone tried this? I'm going to as soon as I have time but it sounds pretty alluring.

http://www.redelmstudios.com/hotnsour

viral marketing campaign

Posted: Mon Sep 04, 2006 7:56 am
by user
This "someone" (you) has quite alot of work to do before that php thing can be compared to eggdrop. :lol:
And how can you hate Tcl and like php :shock:

Posted: Mon Sep 04, 2006 8:39 am
by phpinfo
Good research skills :).

I certainly do prefer PHP over tcl, and for example, something as simple as database integration is considerably more difficult to manage on a tcl platform than a PHP platform.

Also I laughed at your subject line. Very poignant.

Posted: Mon Sep 04, 2006 3:58 pm
by KrzychuG
It's not the first bot wrote in PHP. I rember Slavee project which looks and works preety nice. Too bad it's not developed anymore. I wish you good luck with that project. Maybe one day it'll something like tcldrop today :)

Posted: Tue Sep 05, 2006 8:21 am
by De Kus
That will be time when web providers will start banning it :D. Seriously. Web providers don't intent to offer IRC bots in their web hosting service and these would seriously eat up resources (not to mention execution time and memory limits might addionally make problems).

about the TCL:
TCL has anything you need which isn't a POSIX command which you can access via 'exec' or 'open |'. Addionally the eggdrop core in C will always be faster than your PHP code, if you dislike TCL so much then discard any scripts but the config file and code everything as a C or C++ module.

Posted: Wed Sep 06, 2006 9:07 am
by phpinfo
De Kus wrote:That will be time when web providers will start banning it :D. Seriously. Web providers don't intent to offer IRC bots in their web hosting service and these would seriously eat up resources (not to mention execution time and memory limits might addionally make problems).
Hotnsour requires two things: the PHP CLI engine, and the sockets extension. The attraction of Hotnsour is not meant to be an out-of-the-box, trick-your-webhost-provider solution where you open run.php and start running a botnet :wink:. The advantage, however, is in the accessibility to the scripter.
De Kus wrote:Addionally the eggdrop core in C will always be faster than your PHP code, if you dislike TCL so much then discard any scripts but the config file and code everything as a C or C++ module.
All good points; however IRC is a text-based, easy-to-parse protocol, and one does not require huge amounts of memory or number of clock cycles to run a client.

I've yet to run specific memory and performance tests between a PHP and Tcl implementation, but PHP has a notoriously good reputation with stability and resource management. Despite the school of thought which considers "compiled" scripting languages such as JSP and ASP a better choice for scalability, PHP has been shown to scale just as well when dealing with tons of server requests.

But again, the disparity between running a multilayered complex script system such as the one that powers forum.egghelp.org, versus a sole process keeping a connection or two alive with an IRC daemon is enough to strike down the notion that PHP is inefficient for the job (IRC). Memory hog? Perhaps. Unstable? Definitely not - I can personally attest to running a Hotnsour process for literally months without any (apparent) memory leak.

However - and this is a direct response to your comment about writing the modules in C/C++ - the key benefit of programming in PHP is native object oriented programming support, its string manipulation and ease-of-typecast variable handling; Tcl is inherently not OOP, as far as I understand. The inspiration comes from Perl scripts from the IRC client Irssi, which provides a layer of abstraction to the scripter, not unlike what Hotnsour has to offer:

Code: Select all

// Typical script using C-type argument vector ($argv).
// $argc is also available.  Certain variables are set
// prior to calling this script, such as $channel, $from,
// and $from_full.

  switch ($argv[0]) {
  case "!wz":
  case "!wzf":
    include 'scripts/weather.sc';
    break;
  case "!spam":
    $irc->privmsg("#eggdrop", "we rule!");
    break;
  case "!op":
    switch ($from) { // primitive whitelist
    case "hotnsour":
      $irc->op($channel, $from);
      break;
    default:
      $irc->privmsg($channel, "no way jose!");
      break;
    }
    break;
  default:
    break;
  }

(I would actually like to see the Tcl equivalent, if possible :wink:).

Hotnsour is friendly/friendlier to rapid development, although the best Tcl coder here could probably argue otherwise. The number of steps it could possibly take to reload/recode a script is as simple as changing the line and saving the script; the Hotnsour engine will detect a change and updates its code cache immediately. For an eggdrop, the HANGUP signal has to be sent so the bot rehashes. From what I imagine this cuts down on the efficiency of reworking scripts.

I appreciate the feedback, and KrzychuG, yes, it is certainly not the first incarnation of a PHP bot, but hopefully the most intuitive and comprehensive. :D

Posted: Fri Sep 08, 2006 11:50 am
by De Kus
phpinfo wrote:(I would actually like to see the Tcl equivalent, if possible :wink:).
here you go (including all splitting):

Code: Select all

namespace eval irc {
   proc tclscript {nick uhost hand chan arg} {
      switch -- [lindex [split $arg] 0] {
         !wz -
         !wzf {
            source scripts/weather.tcl
         }
         !spam {
            puthelp "PRIVMSG $chan :we rule!"
         }
         !op {
            if {$hand != "*" && ![isop $nick $chan]} {
               pushmode $chan +o $nick
            }
         }
         default {}
      }
      return 0
   }
}
bind pubm -|- * irc::tclscript
I have never really understood object orientated programming, but what I remember from my C++ manual you might want to look into "namespace"s from TCL, it looks similar. Don't believe just because TCL is diffrent, it's less. There are only very few things you can't do, which you could with other non-compiling Langauges (avoided the term "scripting language" here). And for complicated things you can still call an extern application or create a module. I for myself use the way to asyncrounly call to a compiled C program for the only thing TCL failed for my purpose.

Posted: Fri Sep 08, 2006 1:31 pm
by phpinfo
I appreciate the response, De Kus. Your snippet certainly puts Tcl in a good light, as the code is clean and relatively easy to understand.
De Kus wrote:Don't believe just because TCL is diffrent, it's less.
I would argue that PHP is more accessible to programmers with previous experience, especially if it is with C/C++/Java. It is closer to the family of C-syntax languages, and correct me if I'm wrong, has better library support than Tcl does (everything from string manipulation to MySQL database connection handlers).

However, I don't mean to say that Tcl is an inferior language. There are plenty of powerful languages out there that stray away or are radically different from the C family - Perl, Python, Tcl, Lisp - but fare very well for their applications. Lisp is a perfect example of a language that is syntactically different but is superb for certain applications, e.g. artificial intelligence.
De Kus wrote:There are only very few things you can't do, which you could with other non-compiling Langauges (avoided the term "scripting language" here).
I'm curious as to why you would make the distinction between a non-compiling language and a scripting language? I suppose the correct term would be an "interpreted" language. :)

Posted: Fri Sep 22, 2006 3:13 pm
by Manick
I noticed this topic and figured I might contribute a link to my open source project:

http://www.phpbots.org

It is an irc bot written in PHP 5 meant to be run from a console.

--Manick

Posted: Wed Nov 01, 2006 1:14 am
by sKy
This is an interesting topic.
I foubd this one. Java Irc Bot ( http://www.jibble.org/pircbot.php )

Is there any free webspace provider where you can host such a bot? I didn`t found any.

Posted: Tue Oct 30, 2007 6:34 pm
by W00dyW00d
I use IQ phpbot for a few bots. Its not worked on anymore but works great for what i need it for. Was very easy for me to get it to work and I was able to add blowfish channel encryption built in. Also getting imdb, weather, tvrage was easy too addin.


http://f0rked.com/projects/IQ

later

Posted: Thu Dec 06, 2007 3:12 pm
by subzer0
can any1 post blowfish script for phpbot ?
specifically one that can decrypt the the hash back to commands/triggers the bot can understand.

Posted: Thu Dec 06, 2007 4:05 pm
by Sir_Fz
As far as I know, a hash is a one-way encryption (it means it cannot be decrypted).

Posted: Fri Dec 07, 2007 6:59 am
by subzer0
i know that hash is one-way only.

however, i do know that eggdrop has blowfish tcl script support, so provide you have & set a key for chan, bot is able to "listen" on triggers even if it's encrypted chan. so it's logical to assume the blowfish isnt just one-way algo (like md5 hash), but must allow decryption of it as well.

EDIT: i've found implementation of blowfish encrypt/decrypt algorithm in php @ http://www.cyberphoria.org/projects/blow-4-php
will try to "play" around with it...

EDIT2: above blowfish algorithm on php extremly slow - can take from 4 to 12 seconds, depands on server loads and/or cpu speed.
also both php bots have no botnet support yet.
technology isnt right atm to move there yet, though it is tempting to create new bot "on the fly" during runtime, compared to tcl.

Posted: Fri Dec 07, 2007 8:43 am
by tsukeh