Class: ModSpox::Models::Channel

Inherits:
Object
  • Object
show all
Defined in:
lib/mod_spox/models/Channel.rb

Overview

Attributes provided by model:

name

Channel name

password

Channel password

autojoin

Set bot to autojoin this channel

topic

Channel topic

quiet

Silence the bot in this channel

parked

Bot is currently in this channel

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.cleanObject

Purges all channel information



54
55
56
57
# File 'lib/mod_spox/models/Channel.rb', line 54

def self.clean
    Channel.set(:topic => nil, :parked => false)
    ChannelMode.destroy_all
end

.locate(string, create = true) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/mod_spox/models/Channel.rb', line 15

def Channel.locate(string, create = true)
    chan = nil
    if(Database.type == :pgsql)
        chan = Channel.filter('name = lower(?)', string).first
    end
    chan = Channel.find_or_create(:name => string) if !chan && create
    return chan
end

Instance Method Details

#channel_modesObject

Modes for this channel



25
26
27
# File 'lib/mod_spox/models/Channel.rb', line 25

def channel_modes
    ChannelMode.filter(:channel_id => pk)
end

#clear_nicksObject

Removes all nicks from this channel



49
50
51
# File 'lib/mod_spox/models/Channel.rb', line 49

def clear_nicks
    NickChannel.filter(:channel_id => pk, :nick_id => nick.pk).each{|o| o.destroy}
end

#nick_add(nick) ⇒ Object

Adds a nick to this channel



39
40
41
# File 'lib/mod_spox/models/Channel.rb', line 39

def nick_add(nick)
    NickChannel.find_or_create(:channel_id => pk, :nick_id => nick.pk)
end

#nick_remove(nick) ⇒ Object

Removes a nick from this channel



44
45
46
# File 'lib/mod_spox/models/Channel.rb', line 44

def nick_remove(nick)
    NickChannel.filter(:channel_id => pk, :nick_id => nick.pk).first.destroy
end

#nicksObject

Nicks residing within this channel



30
31
32
33
34
35
36
# File 'lib/mod_spox/models/Channel.rb', line 30

def nicks
    all_nicks = []
    NickChannel.filter(:channel_id => pk).each do |nc|
        all_nicks << nc.nick
    end
    return all_nicks
end