Module: KAG::Common

Includes:
Cinch::Plugin
Included in:
Cinch::Commands::Help, Bans::Plugin, Bot::Plugin, Gather::Plugin, Help::Plugin, IRC::Plugin, Stats::Plugin, User::Plugin
Defined in:
lib/kag/common.rb

Instance Method Summary collapse

Instance Method Details

#_h(key, params = {}) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/kag/common.rb', line 35

def _h(key,params = {})
  if KAG::Help::Book.instance.key?(key.to_sym)
    text = KAG::Help::Book.instance[key.to_sym].to_s
    params.each do |k,v|
      text.gsub!("[[+"+k.to_s+"]]",v)
    end
    text
  else
    ""
  end
end

#debug(msg) ⇒ Object



23
24
25
26
27
# File 'lib/kag/common.rb', line 23

def debug(msg)
  if KAG::Config.instance[:debug]
    puts msg
  end
end

#is_admin(user) ⇒ Object



29
30
31
32
33
# File 'lib/kag/common.rb', line 29

def is_admin(user)
  user.refresh
  o = (KAG::Config.instance[:owners] or [])
  o.include?(user.authname)
end

#is_banned?(user) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/kag/common.rb', line 19

def is_banned?(user)
  KAG::Bans::Report.is_banned?(user)
end

#reply(message, text, colorize = true) ⇒ Object



7
8
9
10
# File 'lib/kag/common.rb', line 7

def reply(message,text,colorize = true)
  text = Format(:grey,text) if colorize
  message.reply text
end

#send_channels_msg(msg, colorize = true) ⇒ Object



12
13
14
15
16
17
# File 'lib/kag/common.rb', line 12

def send_channels_msg(msg,colorize = true)
  KAG::Config.instance[:channels].each do |c|
    msg = Format(:grey,msg) if colorize
    Channel(c).send(msg)
  end
end