Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function read_socket($socket)
- {
- while($rawData = fgets($socket)) {
- $data .= $rawData;
- }
- return $data;
- }
- function send_message(string $channel, string $message)
- {
- global $irc;
- fprintf($irc, "PRIVMSG #%s :%s\n", $channel, $message);
- }
- $host = 'irc.freenode.net';
- $port = '6667';
- $nick = 'Menhera_bot';
- $param = 'USER Linux 127.0.0.1 localhost';
- $channel = 'BHSec';
- $irc = fsockopen($host, $port, $errno, $errstr, 30);
- stream_set_blocking($irc, 0);
- if($irc) {
- fprintf($irc, "USER %s\n", $param);
- sleep(5);
- fprintf($irc, "NICK %s\n", $nick);
- echo read_socket($irc);
- sleep(5);
- fprintf($irc, "JOIN #%s\n", $channel);
- echo read_socket($irc);
- sleep(5);
- while(1)
- {
- $msg = readline('IRC: ');
- $msg = trim($msg);
- if(empty($msg)) {
- echo read_socket($irc);
- } else {
- send_message($channel, $msg);
- }
- }
- }
- fclose($irc);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement