This bot is perfect for anything where you need to easily build IRC channel notifications into an existing process. It’s simple, clean, and agnostic. Quite simply you connect to a TCP port, give it one line, the port closes, the line given shows up in the channel. eg: echo ‘hello’ | nc -q 1 bothost 22122
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
require 'socket' require 'thread' class Announcer < AutumnLeaf def handle_incoming(sock) Thread.new { line = sock.gets message line sock.close } end def did_start_up Thread.new { listener = TCPServer.new('',22122) while (new_socket = listener.accept) handle_incoming(new_socket) end } end end |