-
-
Save anonymous/0b2b9c5bd89d6e1e5fec to your computer and use it in GitHub Desktop.
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
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