X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=lib%2Fbtr%2Firc.php;fp=lib%2Fbtr%2Firc.php;h=8af22098e1e5d6f878b89b3fc129590410fb9842;hb=f5fd15396636986e7447993a66b8a4084a93dabb;hp=0000000000000000000000000000000000000000;hpb=5735fce9818606a36ff3ebbbf902030bcd46c506;p=m6w6%2Fbtr diff --git a/lib/btr/irc.php b/lib/btr/irc.php new file mode 100755 index 0000000..8af2209 --- /dev/null +++ b/lib/btr/irc.php @@ -0,0 +1,88 @@ +session = $session = new irc\client\Session( + $url["user"], + $url["user"], + $url["user"] + ); + + @list($this->channel, $this->keyword) = + explode(" ", $url["fragment"]); + + $session->onConnect = $session->onPart = function($origin, array $args) { + $this->joined = false; + $this->session->doJoin("#".$this->channel, $this->keyword); + }; + $session->onJoin = function($origin, array $args) use ($onJoin) { + $this->joined = true; + $onJoin($this, $origin, $args); + }; + $session->doConnect(false, $url["host"], @$url["port"]?:6667, @$url["pass"]); + } + + function send($message = null) { + if (isset($message)) { + $this->queue[] = $message; + } + + if ($this->joined) { + while ($this->queue) { + $this->session->doMsg("#".$this->channel, array_shift($this->queue)); + } + } + } + + function getSession() { + return $this->session; + } +} + +if (!extension_loaded("ircclient")) { + fatal("ext/ircclient not loaded"); +} + +# vim: noet