Class: Cinch::Plugins::Toolbox

Inherits:
Object
  • Object
show all
Includes:
Admin, Cinch::Plugin
Defined in:
lib/cinch/plugins/toolbox.rb

Constant Summary

Constants included from Admin

Admin::TYPES

Instance Method Summary collapse

Methods included from Admin

#add_admin, #add_trusted, #delete_admin, #delete_trusted, #each_controlchannel, #each_online_admin, #each_online_trusted, #get_admins, #get_trusted, #is_admin?, #is_trusted?, #no_admins?

Methods included from Helpers

#check_user, #is_channel_disabled?, table_format

Constructor Details

#initialize(*args) ⇒ Toolbox

Returns a new instance of Toolbox


16
17
18
19
# File 'lib/cinch/plugins/toolbox.rb', line 16

def initialize(*args)
  super
  Kernel.trap('INT') { @bot.quit("assimilated into the borg.") }
end

Instance Method Details

#boteval(m, s) ⇒ Object


58
59
60
61
62
63
# File 'lib/cinch/plugins/toolbox.rb', line 58

def boteval(m, s)
  return unless is_admin?(m.user)
  eval(s)
rescue => e
  m.user.msg "eval error: %s\n- %s (%s)" % [s, e.message, e.class.name]
end

#join(m, channel) ⇒ Object


22
23
24
25
26
27
28
# File 'lib/cinch/plugins/toolbox.rb', line 22

def join(m, channel)
  return unless is_admin?(m.user)
  channel.split(", ").each {|ch|
    Channel(ch).join
    @bot.handlers.dispatch :admin, m, "Attempt to join #{ch.split[0]} by #{m.user.nick}...", m.target
  }
end

#nick(m, nick) ⇒ Object


49
50
51
52
53
54
55
# File 'lib/cinch/plugins/toolbox.rb', line 49

def nick(m, nick)
  return unless is_admin?(m.user)
  bot.nick = nick
  synchronize(:nickchange) do
    @bot.handlers.dispatch :admin, m, "My nick got changed from #{@bot.last_nick} to #{@bot.nick} by #{m.user.nick}", m.target
  end
end

#part(m, channel = nil, msg = nil) ⇒ Object


31
32
33
34
35
36
37
# File 'lib/cinch/plugins/toolbox.rb', line 31

def part(m, channel=nil, msg=nil)
  return unless is_admin?(m.user)
  channel ||= m.channel.name
  msg ||= m.user.nick
  Channel(channel).part(msg) if channel
  @bot.handlers.dispatch :admin, m, "Parted #{channel}#{" - #{msg}" unless msg.nil?}", m.target
end

#quit(m, msg = nil) ⇒ Object


40
41
42
43
44
45
46
# File 'lib/cinch/plugins/toolbox.rb', line 40

def quit(m, msg=nil)
  return unless is_admin?(m.user)
  msg ||= m.user.nick
  @bot.handlers.dispatch :admin, m, "I am being shut down NOW!#{" - Reason: " + msg unless msg.nil?}", m.target
  sleep 2
  bot.quit(msg)
end