Skip to content

Instantly share code, notes, and snippets.

@e2kaneko
Created September 16, 2012 09:44
Show Gist options
  • Save e2kaneko/3731792 to your computer and use it in GitHub Desktop.
Save e2kaneko/3731792 to your computer and use it in GitHub Desktop.
Net_SmartIRCのサンプル。微妙。
<?php
// (*´・ω・)(・ω・`*)< イマイチ!
include_once('Net/SmartIRC.php');
if(count($argv) != 4){
die("error! invalid argment [php xxx.php 'author' 'log' 'changes']");
}
class mybot
{
function irc_disconnect(&$irc)
{
global $saytime_once_id;
$irc->unregisterTimeid($saytime_once_id);
$irc->quit('bye');
}
}
$bot = &new mybot();
$irc = &new Net_SmartIRC();
$irc->setDebug(SMARTIRC_DEBUG_NOTICE);
//$irc->setDebug(SMARTIRC_DEBUG_ALL);
$irc->setUseSockets(TRUE);
$saytime_once_id = $irc->registerTimehandler(3000, $bot, 'irc_disconnect');
// チャンネルにjoin
$irc->connect('irc.server.host', 6667);
$irc->login('svn-bot', 'bot', 8, 'bot');
$irc->join(array('#sandbox'));
// メッセージ送信
$message = 'SVN Updated!' . " [" . $argv[1] . "][" . $argv[2] . "][" . $argv[3] . "]";
$irc->message(SMARTIRC_TYPE_CHANNEL, '#sandbox', $message);
$irc->listen();
$irc->disconnect();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment