Skip to content

Instantly share code, notes, and snippets.

@violetyk
Last active December 18, 2015 16:49
Show Gist options
  • Save violetyk/5814266 to your computer and use it in GitHub Desktop.
Save violetyk/5814266 to your computer and use it in GitHub Desktop.
<?php
$host = 'localhost';
$port = 6667;
$nick = 'bot';
$password = 'password';
$channel = '#channel';
$message = '日本語でおk';
$fp = fsockopen($host, $port, $erno, $errstr, 30);
if(!$fp) die("connect error\r\n");
fwrite($fp, sprintf("NICK %s\r\n", $nick));
fwrite($fp, sprintf("PASS %s\r\n", $password));
fwrite($fp, sprintf("USER %s 0 * : %s \r\n ", $nick, $nick));
fwrite($fp, sprintf("JOIN %s\r\n", $channel));
@ob_flush; @flush();
fwrite($fp, sprintf("PRIVMSG %s : %s\r\n", $channel, $message));
fwrite($fp, "QUIT\r\n");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment