class Atheme::Channel

Public Instance Methods

admin(nick)
Alias for: protect
ban(nick_or_host) click to toggle source

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

# File lib/atheme/entities/channel.rb, line 213
def ban(nick_or_host)
  @session.chanserv.ban(self.name, nick_or_host)
end
close!(reason) click to toggle source

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.

# File lib/atheme/entities/channel.rb, line 107
def close!(reason)
  @session.chanserv.close(self.name, :on, reason)
end
deadmin(nick)
Alias for: deprotect
dehalfop(nick) click to toggle source

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).

# File lib/atheme/entities/channel.rb, line 165
def dehalfop(nick)
  change_permissions(:dehalfop, nick)
end
deop(nick) click to toggle source

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).

# File lib/atheme/entities/channel.rb, line 149
def deop(nick)
  change_permissions(:deop, nick)
end
deprotect(nick) click to toggle source

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).

# File lib/atheme/entities/channel.rb, line 132
def deprotect(nick)
  change_permissions(:deprotect, nick)
end
Also aliased as: deadmin
devoice(nick) click to toggle source

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).

# File lib/atheme/entities/channel.rb, line 181
def devoice(nick)
  change_permissions(:devoice, nick)
end
entrymsg() click to toggle source

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

# File lib/atheme/entities/channel.rb, line 47
def entrymsg
  match(/Entrymsg\s+:\s+(.+)/)
end
entrymsg!(msg=nil) click to toggle source

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

# 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!() click to toggle source

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

# File lib/atheme/entities/channel.rb, line 91
def fdrop!
  @session.chanserv.fdrop(self.name)
end
flags() click to toggle source

Array of channel flags

# File lib/atheme/entities/channel.rb, line 69
def flags
  match(/Flags\s+:\s+(.+)$/).split rescue []
end
founder() click to toggle source

Returns the founder as an Atheme::User object

# File lib/atheme/entities/channel.rb, line 14
def founder
  Atheme::User.new(@session, match(/Founder\s+:\s+(\w+)/))
end
halfop(nick) click to toggle source

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).

# File lib/atheme/entities/channel.rb, line 157
def halfop(nick)
  change_permissions(:halfop, nick)
end
kick(reason=nil) click to toggle source

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

# 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_used() click to toggle source

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

# 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) click to toggle source

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

# File lib/atheme/entities/channel.rb, line 187
def mark!(reason)
  @session.chanserv.mark(self.name, :on, reason)
end
mlock() click to toggle source

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

# File lib/atheme/entities/channel.rb, line 35
def mlock
  match(/Mode\slock\s+:\s+([-+A-Za-z0-9]*)/)
end
Also aliased as: mode_lock
mlock!(modes) click to toggle source

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

# File lib/atheme/entities/channel.rb, line 41
def mlock!(modes)
  @session.chanserv.set(self.name, :mlock, modes)
end
Also aliased as: mode_lock!
mode_lock()
Alias for: mlock
mode_lock!(modes)
Alias for: mlock!
name() click to toggle source

Returns the channel’s name

# File lib/atheme/entities/channel.rb, line 9
def name
  match(/^Information\son\s([&#+][^:]+):$/)
end
op(nick) click to toggle source

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).

# File lib/atheme/entities/channel.rb, line 141
def op(nick)
  change_permissions(:op, nick)
end
open!() click to toggle source

Opens a previously closed channel.

Only opers may use this.

# File lib/atheme/entities/channel.rb, line 114
def open!
  @session.chanserv.close(self.name, :off)
end
prefix() click to toggle source

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

# File lib/atheme/entities/channel.rb, line 74
def prefix
  match(/Prefix\s+:\s+([^\s])/)
end
prefix!(prefix="DEFAULT") click to toggle source

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

# File lib/atheme/entities/channel.rb, line 83
def prefix!(prefix="DEFAULT")
  @session.chanserv.set(self.name, :prefix, prefix)
end
prepend_topic!(topic) click to toggle source

Prepends something to the topic on the channel.

# File lib/atheme/entities/channel.rb, line 237
def prepend_topic!(topic)
  @session.chanserv.topicprepend(self.name, topic)
end
protect(nick) click to toggle source

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).

# File lib/atheme/entities/channel.rb, line 123
def protect(nick)
  change_permissions(:protect, nick)
end
Also aliased as: admin
recover!() click to toggle source

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.

# File lib/atheme/entities/channel.rb, line 208
def recover!
  @session.chanserv.recover(self.name)
end
registered() click to toggle source

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

# 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
successor() click to toggle source

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

# 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) click to toggle source

Sets a topic on the channel.

# File lib/atheme/entities/channel.rb, line 232
def topic!(topic)
  @session.chanserv.topic(self.name, topic)
end
unban(nick_or_host) click to toggle source

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

# File lib/atheme/entities/channel.rb, line 218
def unban(nick_or_host)
  @session.chanserv.unban(self.name, nick_or_host)
end
unmark!() click to toggle source

Unmark a previously marked channel.

# File lib/atheme/entities/channel.rb, line 192
def unmark!
  @session.chanserv.mark(self.name, :off)
end
url() click to toggle source

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

# File lib/atheme/entities/channel.rb, line 58
def url
  match(/URL\s+:\s+(.+)/)
end
url!(url=nil) click to toggle source

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

# 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) click to toggle source

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).

# File lib/atheme/entities/channel.rb, line 173
def voice(nick)
  change_permissions(:voice, nick)
end

Private Instance Methods

change_permissions(perm, nick) click to toggle source
# File lib/atheme/entities/channel.rb, line 242
def change_permissions(perm, nick)
  case
    when nick.kind_of?(String)
      @session.chanserv.send(perm, self.name, nick)
    when nick.kind_of?(Atheme::User)
      @session.chanserv.send(perm, self.name, nick.name)
    when nick.kind_of?(Array)
      nick.each do |n|
        change_permissions(perm, self.name, n)
    end
end
end