Class: Cinch::Plugins::Attack

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

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Attack

Returns a new instance of Attack


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

def initialize(*args)
  @attackdict = []
  super
end

Instance Method Details

#execute(m, target = nil) ⇒ Object


22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/cinch/plugins/attack.rb', line 22

def execute(m, target=nil)
  target = m.user.nick if !target.nil? && target.match(/(\bmy\b|\b#{@bot.nick}\S*\b|\b\S*self\b)/i)
  target.gsub(/(\bmy\b|\b#{@bot.nick}\S*\b|\b\S*self\b)/i,m.user.nick+"'s") if !target.nil?;

  populate_attacks!

  output = if target
    attack!(target.gsub(/\x03([0-9]{2}(,[0-9]{2})?)?/,""), m.user.nick)
  else
    random_attack!(m.channel.users, m.user.nick)
  end
  m.channel.action output;
end