Class: KAG::Bot::Plugin

Inherits:
Object
  • Object
show all
Includes:
Cinch::Commands, Cinch::Plugin, Common
Defined in:
lib/kag/bot/plugin.rb

Instance Method Summary collapse

Methods included from Common

#_h, #debug, #is_admin, #is_banned?, #reply, #send_channels_msg

Methods included from Cinch::Commands

included

Instance Method Details

#bot_join(m, channel, password = nil) ⇒ Object



86
87
88
89
90
# File 'lib/kag/bot/plugin.rb', line 86

def bot_join(m,channel,password = nil)
  if is_admin(m.user)
    m.bot.join(channel,password)
  end
end

#bot_mode(m, mode) ⇒ Object



77
78
79
80
81
# File 'lib/kag/bot/plugin.rb', line 77

def bot_mode(m,mode)
  if is_admin(m.user)
    m.bot.set_mode(mode.to_s)
  end
end

#bot_part(m, channel, reason = nil) ⇒ Object



95
96
97
98
99
# File 'lib/kag/bot/plugin.rb', line 95

def bot_part(m,channel,reason = nil)
  if is_admin(m.user)
    m.bot.part(channel,reason)
  end
end

#is_an_admin(m, nick) ⇒ Object



45
46
47
48
49
50
51
52
# File 'lib/kag/bot/plugin.rb', line 45

def is_an_admin(m,nick)
  u = User(nick)
  if is_admin(u)
    reply m,"Yes, #{nick} is an admin!"
  else
    reply m,"No, #{nick} is not an admin."
  end
end

#on_connect(m) ⇒ Object



13
14
15
# File 'lib/kag/bot/plugin.rb', line 13

def on_connect(m)
  m.bot.set_mode("x")
end

#quit(m) ⇒ Object



20
21
22
23
24
# File 'lib/kag/bot/plugin.rb', line 20

def quit(m)
  if is_admin(m.user)
    m.bot.quit("Shutting down...")
  end
end

#reload_config(m) ⇒ Object



57
58
59
60
61
62
# File 'lib/kag/bot/plugin.rb', line 57

def reload_config(m)
  if is_admin(m.user)
    KAG::Config.instance.reload
    m.reply "Configuration reloaded."
  end
end

#restart(m) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/kag/bot/plugin.rb', line 29

def restart(m)
  if is_admin(m.user)
    cmd = (KAG::Config.instance[:restart_method] or "nohup sh gather.sh &")
    debug cmd
    pid = spawn cmd
    debug "Restarting bot, new process ID is #{pid.to_s} ..."
    if m.bot
      m.bot.quit "Restarting! Back in a second!"
    end
    sleep(0.5)
    exit
  end
end

#version(m) ⇒ Object



67
68
69
70
71
72
# File 'lib/kag/bot/plugin.rb', line 67

def version(m)
  if is_admin(m.user)
    require 'kag/version'
    m.reply "KAG Gather - version "+KAG::VERSION.to_s+" by splittingred - https://github.com/splittingred/kag-gather"
  end
end