Method: Cinch::Channel#initialize
- Defined in:
- lib/cinch/channel.rb
#initialize(name, bot) ⇒ Channel
Note:
Generally, you shouldn’t initialize new instances of this class. Use Cinch::ChannelList#find_ensured instead.
Returns a new instance of Channel.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/cinch/channel.rb', line 49 def initialize(name, bot) @bot = bot @name = name @users = Hash.new {|h, k| h[k] = []} @bans = [] @owners = [] @modes = {} # TODO raise if not a channel @topic = nil @in_channel = false @synced_attributes = Set.new @when_requesting_synced_attribute = lambda {|attr| if @in_channel && attr == :topic && !attribute_synced?(:topic) # Even if we are in the channel, if there's no topic set, # the attribute won't be synchronised yet. Explicitly # request the topic. @bot.irc.send "TOPIC #@name" next end unless @in_channel unsync(attr) case attr when :users @bot.irc.send "NAMES #@name" when :topic @bot.irc.send "TOPIC #@name" when :bans @bot.irc.send "MODE #@name +b" when :owners if @bot.irc.network.owner_list_mode @bot.irc.send "MODE #@name +#{@bot.irc.network.owner_list_mode}" else # the current IRCd does not support channel owners, so # just mark the empty array as synced mark_as_synced(:owners) end when :modes @bot.irc.send "MODE #@name" end end } end |