Created
June 26, 2012 10:20
-
-
Save bnagy/2994849 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require_relative "tabornok/irc" | |
require_relative "tabornok/logger" | |
require_relative "tabornok/console" | |
require "thread" | |
class Tabornok | |
def initialize | |
@logger = Logger.new | |
@logger.message "Tabornok IRC Bot and Framework" | |
@logger.message "Copyright (C) 2012 Jackneill" | |
@logger.message "This program comes with ABSOLUTELY NO WARRANTY; for details type see <http://www.gnu.org/licenses/>." | |
@logger.message "This is free software, and you are welcome to redistribute it" | |
@logger.message "under certain conditions; for details type see <http://www.gnu.org/licenses/>." | |
end | |
def connect | |
@irc = Irc.new | |
@irc.connect "irc.rizon.net", 6667 | |
@irc.auth "Tabornok" | |
@irc.joinchan "#hun_bot" | |
@irc.joinchan "#Tabornok" | |
rescue | |
@logger.message "Error in #{__method__}: #{$!}" | |
end | |
def run | |
@thread_read_irc = Thread.new { irc.read_irc } | |
@thread_pinger = Thread.new { irc.pinger } | |
@console = Console.new | |
@thread_read_console = Thread.new { console.read_console } | |
[@read_thread, @ping_thread, @console_thread].map(&:join) | |
rescue | |
@logger.message "Error in #{__method__}: #{$!}" | |
end | |
end | |
tabornok = Tabornok.new | |
tabornok.connect | |
tabornok.run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment