Skip to content

Instantly share code, notes, and snippets.

/bot.rb Secret

Created October 8, 2012 05:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/0b2b9c5bd89d6e1e5fec to your computer and use it in GitHub Desktop.
Save anonymous/0b2b9c5bd89d6e1e5fec to your computer and use it in GitHub Desktop.
require 'cinch'
$admin = ["shammancer", "dannick"]
class Monitor
include Cinch::Plugin
listen_to :connect, method: :on_connect
listen_to :online, method: :on_online
listen_to :offline, method: :on_offline
def on_connect(m)
User("dannick").monitor
User("shammancer").monitor
end
def on_online(m, user)
user.send "Hello master. \n I am ready to serve."
end
def on_offline(m, user)
@bot.loggers.info "I miss my master #{user} he is not online. :("
end
end
bot = Cinch::Bot.new do
configure do |c|
c.server = "localhost"
c.channels = ["#test"]
c.nick = "shambot"
c.realname = "Shammancer's Bot"
c.user = "BotShammancer"
c.plugins.plugins = [Monitor]
end
on :message, "hello" do |m|
m.reply "Hello, #{m.user.nick}"
end
on :message, "shambot kill" do |m|
if m.user.nick == @admin.any
bot.quit "Must leave."
info "Stoping bot"
end
end
on :message do |m|
if $admin.include? m.user.nick
info "He has spoken to us!"
end
end
end
bot.loggers << Cinch::Logger::FormattedLogger.new(File.open("/home/dannick/shambot.log", "a"))
bot.loggers.first.level = :log
bot.start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment