2017 © Pedro Peláez
 

library irc

IRC Bot

image

datingvip/irc

IRC Bot

  • Wednesday, June 11, 2014
  • by kornrunner
  • Repository
  • 12 Watchers
  • 6 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

IRC

IRC for kittehs, and also PHP programmers ..., (*1)

We are going to have some IRC based collaboration tools (from the late 90's), we required a bot., (*2)

This repository contains a multithreaded PHP IRC bot ... because apparently I'm 15 again ..., (*3)

Codez

U can haz codez ..., (*4)

 %s\n", $line); }
    public function onReceive($line) { printf("irc = $irc;
        $this->msg = $msg;
    }
    
    public function __invoke() {
        /* we can do whatever we want here: 
            search docs, take as long as we want/need */
        $this->irc->msg(
            $this->msg->getNick(),
            $this->msg->getText());
        $this->irc->msg(
            $this->msg->getChannel(),
            sprintf(
                "%s said \"%s\" to %s",
                __CLASS__,
                $this->msg->getText(),
                $this->msg->getNick()));
    }
    
    protected $irc;
    protected $msg;
}

class Listen implements Listener {
    public function __construct($nick) {
        $this->nick = $nick;
    }
    
    public function onReceive(Connection $irc, Message $msg) {
        if ($msg->getType() == "PRIVMSG" &&
            $msg->getNick() == $this->nick) {
            /* returning a Task object 
                threads the work */
            return new Repeat($irc, $msg);
        }
    }
    
    protected $nick;
}

set_time_limit(0);

/* open connection to server */
$connection = new Connection("irc.efnet.org", 6667);

/* make sure we see all input/output */
$connection->setLogger(new Log());

/* create robot with default pool */
$robot = new Robot($connection, new Pool(4));

/* add listeners */
$robot->addListener(
    new Listen("test-user2"));

/* login, join channels and enter main loop */
$robot->login("bot")
    ->join("#devs")
    ->loop();
?>

The example code above shows how to use the Listener and Task interfaces to respond asynchronously to specific messages., (*5)

In addition, this package includes a Manager interface for the Robot, executed synchronously by the Robot during execution, it allows the programmer to perform administration that must be performed in the same context as the Robot., (*6)

setLogger(new Log());

/* create robot with default pool */
$robot = new Robot($connection, new Pool(4), new Manage());

/* add listeners */
$robot->addListener(
    new Listen("krakjoe"));

/* login, join channels and enter main loop */
$robot->login("bot")
    ->join("#devs")
    ->loop();
?>

The code above shows how to employ both the Listener and Manager functionality., (*7)

The Versions

11/06 2014

dev-master

9999999-dev https://github.com/DatingVIP/IRC

IRC Bot

  Sources   Download

LGPLv3

The Requires

  • php >=5.0.0
  • ext-pthreads >=2.0.0

 

irc

11/06 2014

v0.2.0

0.2.0.0 https://github.com/DatingVIP/IRC

IRC Bot

  Sources   Download

LGPLv3

The Requires

  • php >=5.0.0
  • ext-pthreads >=2.0.0

 

irc

30/05 2014

dev-xaero

dev-xaero https://github.com/DatingVIP/IRC

IRC Bot

  Sources   Download

LGPLv3

The Requires

  • php >=5.0.0
  • ext-pthreads >=2.0.0

 

irc

04/05 2014

v0.1.0

0.1.0.0 https://github.com/DatingVIP/IRC

IRC Bot

  Sources   Download

LGPLv3

The Requires

  • php >=5.0.0
  • ext-pthreads >=2.0.0

 

irc