Created
April 7, 2011 14:54
-
-
Save ryanjones/907921 to your computer and use it in GitHub Desktop.
Convore + IRC + cinchrb
This file contains 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
## Setting up the actual bot | |
require 'cinch' | |
require_relative 'monitore' | |
#create bot for IRC monitoring | |
bot = Cinch::Bot.new do | |
configure do |c| | |
c.server = "localhost" | |
c.channels = ["#cinch-bots"] | |
c.verbose = "false" | |
c.plugins.plugins = [Monitore] | |
end | |
end | |
bot.start | |
##Actual plugin | |
require 'cinch' | |
require 'convore' | |
class Monitore | |
include Cinch::Plugin | |
def initialize(*args) | |
@convore_api = Convore::Client.new | |
@convore_api.username = 'Login' | |
@convore_api.password = 'Pass' | |
@convore_api.listen | |
super | |
end | |
#Match all strings without "!" | |
#change this to a regex that picks up everything | |
match "hello", :use_prefix => false | |
def execute(m) | |
m.reply "Hello, #{m.user.nick}" | |
while true do | |
@convore_api.poll | |
while cm = @convore_api.stream.pop do | |
case cm | |
when Convore::Topic then | |
puts "#{cm.group}: Topic '#{cm.name}' created by #{cm.user.username}" | |
when Convore::Message then | |
puts "#{cm.group}: [##{cm.topic.name}] <#{cm.user.username}> #{cm.text}" | |
#paste to IRC if something is posted | |
m.reply "#{cm.group}: [##{cm.topic.name}] <#{cm.user.username}> #{cm.text}" | |
when Convore::Star then | |
puts "* #{cm.user.username} has #{cm.star? ? 'stared' : 'unstared'} '#{cm.message.text}' by #{cm.message.user.username}" | |
else | |
puts "UNKNOWN MESSAGE: #{cm.inspect}" | |
end | |
end | |
sleep(1) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment