rendered paste bodyinclude XChatRubyclass Recuperator < XChatRubyPlugin def initialize puts "URLs Recuperator loaded" hook_command("start_recup", XCHAT_PRI_NORM, method(:start_recup), "Usage: /start_recup") hook_command("stop_recup", XCHAT_PRI_NORM, method(:stop_recup), "Usage: /stop_recup") @recup_is_started = false end def start_recup(words, words_eol, data) if not @recup_is_started puts_fmt "![b]URLs Recuperator started." hook_print("Channel Message", XCHAT_PRI_NORM, method(:get_url)) @urls_file = File.open "/home/gardel/irc/urls", "a" @recup_is_started = true else puts_fmt "![b]URLs Recuperator has been started yet !" end end def stop_recup(words, words_eol, data) if @recup_is_started @urls_file.close @recup_is_started = false puts_fmt "![b]URLs Recuperator stopped." else puts_fmt "![b]URLs Recuperator has not been started yet !" end end def get_url(words, data) url = words[1].match(/http:\/\/[^ ]+/) @urls_file.puts url.to_s if not url.nil? endend