Class: Admin::AutoVoice

Inherits:
Object
  • Object
show all
Includes:
Cinch::Helpers, Cinch::Plugin
Defined in:
lib/Zeta/admin/autovoice.rb

Instance Method Summary collapse

Methods included from Cinch::Plugin

#check?, #log2chan

Constructor Details

#initialize(*args) ⇒ AutoVoice

Returns a new instance of AutoVoice.



12
13
14
15
# File 'lib/Zeta/admin/autovoice.rb', line 12

def initialize(*args)
  @auto_voice_state = Array.new
  super
end

Instance Method Details

#autovoice(msg) ⇒ Object

Methods



32
33
34
35
36
# File 'lib/Zeta/admin/autovoice.rb', line 32

def autovoice(msg)
  if @auto_voice_state.include?(msg.channel.to_s) && msg.user.authed?
    Channel(msg.channel).voice(msg.user)
  end
end

#autovoice_mode(msg, mode = 'status') ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/Zeta/admin/autovoice.rb', line 17

def autovoice_mode(msg, mode='status')
  return unless msg.user.oper?

  if mode == 'on' || mode == 'true'
    @auto_voice_state << msg.channel.to_s
    return msg.reply "AutoVoice is now enabled!"
  elsif mode == 'off' || mode == 'false'
    @auto_voice_state.delete_if { _1 == msg.channel.to_s }
    return msg.reply "AutoVoice is now disabled!"
  end

  msg.reply "AutoVoice is currently: #{@auto_voice_state.include?(msg.channel.to_s) ? 'On' : 'Off'}"
end