This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

PHP IRC Bot

Website and forum-related announcements and discussion, and anything else that doesn't fit in the above forums.
Post Reply
p
phpinfo
Voice
Posts: 4
Joined: Wed Aug 30, 2006 10:11 am

PHP IRC Bot

Post 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
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

viral marketing campaign

Post 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:
Have you ever read "The Manual"?
p
phpinfo
Voice
Posts: 4
Joined: Wed Aug 30, 2006 10:11 am

Post 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.
User avatar
KrzychuG
Master
Posts: 306
Joined: Sat Aug 16, 2003 2:51 pm
Location: Torun, Poland
Contact:

Post 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 :)
Que?
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post 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.
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
p
phpinfo
Voice
Posts: 4
Joined: Wed Aug 30, 2006 10:11 am

Post 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
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post 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.
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
p
phpinfo
Voice
Posts: 4
Joined: Wed Aug 30, 2006 10:11 am

Post 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. :)
M
Manick
Voice
Posts: 1
Joined: Fri Sep 22, 2006 3:09 pm

Post 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
User avatar
sKy
Op
Posts: 194
Joined: Thu Apr 14, 2005 5:58 pm
Location: Germany

Post 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.
socketapi | Code less, create more.
W
W00dyW00d
Voice
Posts: 2
Joined: Mon Jun 11, 2007 8:40 pm

Post 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
User avatar
subzer0
Voice
Posts: 2
Joined: Thu Dec 06, 2007 12:51 pm

Post 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.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

As far as I know, a hash is a one-way encryption (it means it cannot be decrypted).
User avatar
subzer0
Voice
Posts: 2
Joined: Thu Dec 06, 2007 12:51 pm

Post 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.
Last edited by subzer0 on Sat Dec 08, 2007 5:15 pm, edited 2 times in total.
t
tsukeh
Voice
Posts: 31
Joined: Thu Jan 20, 2005 6:22 am

Post by tsukeh »

Post Reply