Class: Atheme::Channel

Inherits:
Entity show all
Defined in:
lib/atheme/entities/channel.rb

Instance Attribute Summary

Attributes inherited from EntityBase

#token

Instance Method Summary collapse

Methods inherited from Entity

#fetchable?

Methods inherited from EntityBase

#initialize, #method_missing

Constructor Details

This class inherits a constructor from Atheme::EntityBase

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Atheme::EntityBase

Instance Method Details

#ban(nick_or_host) ⇒ Object

Allows you to ban a user or hostmask from a channel.



213
214
215
# File 'lib/atheme/entities/channel.rb', line 213

def ban(nick_or_host)
  @session.chanserv.ban(self.name, nick_or_host)
end

#close!(reason) ⇒ Object

close prevents a channel from being used. Anyone who enters is immediately kickbanned. The channel cannot be dropped and foundership cannot be transferred.

On executing this method, it will immediately kick all users from the channel.

Use unclose/open to reopen a channel. While closed, channels will still expire.

Only opers may use this.



107
108
109
# File 'lib/atheme/entities/channel.rb', line 107

def close!(reason)
  @session.chanserv.close(self.name, :on, reason)
end

#dehalfop(nick) ⇒ Object

Takes channel halpop (-h) from someone. If the nick is omitted the action is performed on the person requesting the command. Nick can be a single user or an array of users (as strings or Atheme::Users).



165
166
167
# File 'lib/atheme/entities/channel.rb', line 165

def dehalfop(nick)
  change_permissions(:dehalfop, nick)
end

#deop(nick) ⇒ Object

Takes channel operator (-o) permissions from someone. If the nick is omitted the action is performed on the person requesting the command. Nick can be a single user or an array of users (as strings or Atheme::Users).



149
150
151
# File 'lib/atheme/entities/channel.rb', line 149

def deop(nick)
  change_permissions(:deop, nick)
end

#deprotect(nick) ⇒ Object Also known as: deadmin

Takes channel operator (-a) permissions from someone. If the nick is omitted the action is performed on the person requesting the command. Nick can be a single user or an array of users (as strings or Atheme::Users).



132
133
134
# File 'lib/atheme/entities/channel.rb', line 132

def deprotect(nick)
  change_permissions(:deprotect, nick)
end

#devoice(nick) ⇒ Object

Takes channel voice (-v) from someone. If the nick is omitted the action is performed on the person requesting the command. Nick can be a single user or an array of users (as strings or Atheme::Users).



181
182
183
# File 'lib/atheme/entities/channel.rb', line 181

def devoice(nick)
  change_permissions(:devoice, nick)
end

#entrymsgObject

Entry message of the channel, if set - otherwise nil.



47
48
49
# File 'lib/atheme/entities/channel.rb', line 47

def entrymsg
  match(/Entrymsg\s+:\s+(.+)/)
end

#entrymsg!(msg = nil) ⇒ Object

Sets the entrymsg for the channel. Call without arguments to clear it.



53
54
55
# File 'lib/atheme/entities/channel.rb', line 53

def entrymsg!(msg=nil)
  msg.kind_of?(String) ? @session.chanserv.set(self.name, :entrymsg, msg) : @session.chanserv.set(self.name, :entrymsg)
end

#fdrop!Object

Forcefully removes the channel, including all data associated with it (like access lists etc) and cannot be restored. Only opers may use this.



91
92
93
# File 'lib/atheme/entities/channel.rb', line 91

def fdrop!
  @session.chanserv.fdrop(self.name)
end

#fetch!Object

:nodoc:



4
5
6
# File 'lib/atheme/entities/channel.rb', line 4

def fetch! #:nodoc:
  @session.chanserv.info(@token)
end

#flagsObject

Array of channel flags



69
70
71
# File 'lib/atheme/entities/channel.rb', line 69

def flags
  match(/Flags\s+:\s+(.+)$/).split rescue []
end

#founderObject

Returns the founder as an Atheme::User object



14
15
16
# File 'lib/atheme/entities/channel.rb', line 14

def founder
  Atheme::User.new(@session, match(/Founder\s+:\s+(\w+)/))
end

#halfop(nick) ⇒ Object

Gives someone channel halfop (+h). If the nick is omitted the action is performed on the person requesting the command. Nick can be a single user or an array of users (as strings or Atheme::Users).



157
158
159
# File 'lib/atheme/entities/channel.rb', line 157

def halfop(nick)
  change_permissions(:halfop, nick)
end

#kick(reason = nil) ⇒ Object

The KICK command allows for the removal of a user from a channel. The user can immediately rejoin.

Your nick will be added to the kick reason. The reason is optional./cs



227
228
229
# File 'lib/atheme/entities/channel.rb', line 227

def kick(reason=nil)
  reason.kind_of?(String) ? @session.chanserv.kick(self.name, nick) : @session.chanserv.kick(self.name, nick, reason)
end

#last_usedObject

Date object which is set to the time when the channel was last used



30
31
32
# File 'lib/atheme/entities/channel.rb', line 30

def last_used
  Date.parse(match(/Last\sused\s+:\s+(\w+ [0-9]{2} [0-9(:?)]+ [0-9]{4})/)) rescue nil
end

#mark!(reason) ⇒ Object

mark allows operators to attach a note to a channel. For example, an operator could mark the channel to be a botnet channel.



187
188
189
# File 'lib/atheme/entities/channel.rb', line 187

def mark!(reason)
  @session.chanserv.mark(self.name, :on, reason)
end

#mlockObject Also known as: mode_lock

String of the mode locked on the channel, e.g. “+Ctn-ksi”



35
36
37
# File 'lib/atheme/entities/channel.rb', line 35

def mlock
  match(/Mode\slock\s+:\s+([-+A-Za-z0-9]*)/)
end

#mlock!(modes) ⇒ Object Also known as: mode_lock!

Sets the given mlock/mode lock on the channel, e.g. mntF-kljf or ntlL 40 #foo2



41
42
43
# File 'lib/atheme/entities/channel.rb', line 41

def mlock!(modes)
  @session.chanserv.set(self.name, :mlock, modes)
end

#nameObject

Returns the channel’s name



9
10
11
# File 'lib/atheme/entities/channel.rb', line 9

def name
  match(/^Information\son\s([&#+][^:]+):$/)
end

#op(nick) ⇒ Object

Gives someone channel operator (+o) permissions If the nick is omitted the action is performed on the person requesting the command. Nick can be a single user or an array of users (as strings or Atheme::Users).



141
142
143
# File 'lib/atheme/entities/channel.rb', line 141

def op(nick)
  change_permissions(:op, nick)
end

#open!Object

Opens a previously closed channel.

Only opers may use this.



114
115
116
# File 'lib/atheme/entities/channel.rb', line 114

def open!
  @session.chanserv.close(self.name, :off)
end

#prefixObject

Prefix character used on the channel, e.g. “!”



74
75
76
# File 'lib/atheme/entities/channel.rb', line 74

def prefix
  match(/Prefix\s+:\s+([^\s])/)
end

#prefix!(prefix = "DEFAULT") ⇒ Object

Allows you to customize the channel fantasy trigger for your channel. This is particularly useful if you have channel bots that conflict with ChanServ’s default fantasy prefix. Providing no prefix argument (or DEFAULT) resets the channel fantasy prefix to the network default prefix



83
84
85
# File 'lib/atheme/entities/channel.rb', line 83

def prefix!(prefix="DEFAULT")
  @session.chanserv.set(self.name, :prefix, prefix)
end

#prepend_topic!(topic) ⇒ Object

Prepends something to the topic on the channel.



237
238
239
# File 'lib/atheme/entities/channel.rb', line 237

def prepend_topic!(topic)
  @session.chanserv.topicprepend(self.name, topic)
end

#protect(nick) ⇒ Object Also known as: admin

Gives someone channel admin/protection (+a) permissions If the nick is omitted the action is performed on the person requesting the command. Nick can be a single user or an array of users (as strings or Atheme::Users).



123
124
125
# File 'lib/atheme/entities/channel.rb', line 123

def protect(nick)
  change_permissions(:protect, nick)
end

#recover!Object

Allows you to regain control of your channel in the event of a takeover.

More precisely, everyone will be deopped, limit and key will be cleared, all bans matching you are removed, a ban exception matching you is added (in case of bans Atheme can’t see), the channel is set invite-only and moderated and you are invited.

If you are on channel, you will be opped and no ban exception will be added.



208
209
210
# File 'lib/atheme/entities/channel.rb', line 208

def recover!
  @session.chanserv.recover(self.name)
end

#registeredObject

Date object which is set to the time when the channel was registered



25
26
27
# File 'lib/atheme/entities/channel.rb', line 25

def registered
  Date.parse(match(/Registered\s+:\s+(\w+ [0-9]{2} [0-9(:?)]+ [0-9]{4})/))
end

#successorObject

Returns the successor as an Atheme::User object Returns nil if noone has been set



20
21
22
# File 'lib/atheme/entities/channel.rb', line 20

def successor
  match(/Successor\s+:\s+\(none\)/) ? nil : Atheme::User.new(@session, match(/Successor\s+:\s+(\w+)/))
end

#topic!(topic) ⇒ Object

Sets a topic on the channel.



232
233
234
# File 'lib/atheme/entities/channel.rb', line 232

def topic!(topic)
  @session.chanserv.topic(self.name, topic)
end

#unban(nick_or_host) ⇒ Object

Allows you to unban a user or hostmask from a channel.



218
219
220
# File 'lib/atheme/entities/channel.rb', line 218

def unban(nick_or_host)
  @session.chanserv.unban(self.name, nick_or_host)
end

#unmark!Object

Unmark a previously marked channel.



192
193
194
# File 'lib/atheme/entities/channel.rb', line 192

def unmark!
  @session.chanserv.mark(self.name, :off)
end

#urlObject

Returns the hannel’s URL if one has been set, otherwise nil.



58
59
60
# File 'lib/atheme/entities/channel.rb', line 58

def url
  match(/URL\s+:\s+(.+)/)
end

#url!(url = nil) ⇒ Object

Sets the URL for the channel. Call without arguments to clear it.



64
65
66
# File 'lib/atheme/entities/channel.rb', line 64

def url!(url=nil)
  url.kind_of?(String) ? @session.chanserv.set(self.name, :url, url) : @session.chanserv.set(self.name, :url)
end

#voice(nick) ⇒ Object

Gives someone channel voice (+v). If the nick is omitted the action is performed on the person requesting the command. Nick can be a single user or an array of users (as strings or Atheme::Users).



173
174
175
# File 'lib/atheme/entities/channel.rb', line 173

def voice(nick)
  change_permissions(:voice, nick)
end