### Home Classes Methods

### In Files

- lib/rbot/irc.rb

### Parent

Object

### Namespace

- CLASS Irc::Channel::Mode
- CLASS Irc::Channel::ModeHash
- CLASS Irc::Channel::ModeTypeA
- CLASS Irc::Channel::ModeTypeB
- CLASS Irc::Channel::ModeTypeC
- CLASS Irc::Channel::ModeTypeD
- CLASS Irc::Channel::Topic
- CLASS Irc::Channel::UserMode

### Methods

- ::new
- ::npname
- #add_user
- #create_mode
- #delete_user
- #get_user
- #has_op?
- #has_user?
- #has_voice?
- #inspect
- #local?
- #modeless?
- #modes_of
- #normal?
- #prefix
- #safe?
- #to_irc_channel
- #user_nicks

### Included Modules

- Irc::ServerOrCasemap

### Class/Module Index

Quicksearch

- Irc
- Irc::AsciiCasemap
- Irc::BanlistMessage
- Irc::BasicUserMessage
- Irc::Bot
- Irc::Bot::Auth
- Irc::Bot::Auth::BotOwnerClass
- Irc::Bot::Auth::BotUser
- Irc::Bot::Auth::Command
- Irc::Bot::Auth::DefaultBotUserClass
- Irc::Bot::Auth::InvalidPassword
- Irc::Bot::Auth::ManagerClass
- Irc::Bot::Auth::PermissionSet
- Irc::Bot::Config
- Irc::Bot::Config::ArrayValue
- Irc::Bot::Config::BooleanValue
- Irc::Bot::Config::EnumValue
- Irc::Bot::Config::FloatValue
- Irc::Bot::Config::IntegerValue
- Irc::Bot::Config::ManagerClass
- Irc::Bot::Config::StringValue
- Irc::Bot::Config::Value
- Irc::Bot::Config::Wizard
- Irc::Bot::DataFilter
- Irc::Bot::DataStream
- Irc::Bot::Language
- Irc::Bot::MessageMapper
- Irc::Bot::MessageMapper::Failure
- Irc::Bot::MessageMapper::FriendlyFailure
- Irc::Bot::MessageMapper::NoActionFailure
- Irc::Bot::MessageMapper::NoMatchFailure
- Irc::Bot::MessageMapper::NotPrivateFailure
- Irc::Bot::MessageMapper::NotPublicFailure
- Irc::Bot::MessageMapper::PartialMatchFailure
- Irc::Bot::MessageParameter
- Irc::Bot::MessageTemplate
- Irc::Bot::Plugins
- Irc::Bot::Plugins::BotModule
- Irc::Bot::Plugins::CoreBotModule
- Irc::Bot::Plugins::Plugin
- Irc::Bot::Plugins::PluginManagerClass
- Irc::Bot::Plugins::RecurseTooDeep
- Irc::Bot::Plugins::RemoteBotModule
- Irc::Bot::Plugins::RemoteCoreBotModule
- Irc::Bot::Plugins::RemotePlugin
- Irc::Bot::Registry
- Irc::Bot::Registry::Accessor
- Irc::Bot::RemoteDispatcher
- Irc::Bot::RemoteMessage
- Irc::Bot::RemoteObject
- Irc::Bot::Wordlist
- Irc::BotConfig
- Irc::Casemap
- Irc::Channel
- Irc::Channel::Mode
- Irc::Channel::ModeHash
- Irc::Channel::ModeTypeA
- Irc::Channel::ModeTypeB
- Irc::Channel::ModeTypeC
- Irc::Channel::ModeTypeD
- Irc::Channel::Topic
- Irc::Channel::UserMode
- Irc::ChannelList
- Irc::Client
- Irc::DBHash
- Irc::DBTree
- Irc::InviteMessage
- Irc::JoinMessage
- Irc::KickMessage
- Irc::MessageQueue
- Irc::ModeChangeMessage
- Irc::MotdMessage
- Irc::NamesMessage
- Irc::Netmask
- Irc::NetmaskDb
- Irc::NetmaskDb::Tree
- Irc::NetmaskList
- Irc::NickMessage
- Irc::NoSuchTargetMessage
- Irc::NoticeMessage
- Irc::PartMessage
- Irc::PrivMessage
- Irc::QueueRing
- Irc::QuitMessage
- Irc::RfcCasemap
- Irc::Server
- Irc::ServerOrCasemap
- Irc::Socket
- Irc::Socket::IdentityFilter
- Irc::StrictRfcCasemap
- Irc::TopicMessage
- Irc::UnknownMessage
- Irc::User
- Irc::UserList
- Irc::UserMessage
- Irc::Utils
- Irc::Utils::HttpUtil
- Irc::Utils::HttpUtil::CachedObject
- Irc::Utils::ParseTime
- Irc::WelcomeMessage
- Irc::WhoisMessage
- BDB
- BDB::CIBtree
- MonitorMixin
- MonitorMixin::ConditionVariable
- Net
- Net::HTTPResponse
- Regexp
- Regexp::Irc
- Singleton
- Singleton::SingletonClassMethods
- Timer
- Timer::Action
- TokyoCabinet
- TokyoCabinet::CIBDB
- UnicodePlugin
- UnicodePlugin::UnicodeFilter
- Array
- ArrayOf
- AuthModule
- BasicsModule
- ConditionVariable
- ConfigModule
- DottedIndex
- Enumerable
- Exception
- FiltersModule
- GetText
- GetTextVersionError
- HttpUtilPlugin
- IrcLogModule
- Module
- Numeric
- Object
- Range
- RemoteModule
- ServerError
- String
- Symbol
- UserDataModule
- WordlistModule
- YAML

No matching classes.

# Irc::Channel

An IRC Channel is identified by its name, and it has a set of properties:

- a Channel::Topic

- a UserList

- a set of Channel::Modes

The Channel::Topic and Channel::Mode classes are defined within the Channel namespace because they only make sense there

Here we start with the actual Channel class

### Attributes

creation_time[RW]
mode[R]
name[R]
to_s[R]
topic[R]
url[RW]
users[R]

### Public Class Methods

new(name, topic=nil, users=[], opts={}) click to toggle source

Creates a new channel with the given name, optionally setting the topic and an initial users list.

No additional info is created here, because the channel flags and userlists allowed depend on the server.

    # File lib/rbot/irc.rb, line 1395
    def initialize(name, topic=nil, users=[], opts={})
      raise ArgumentError, "Channel name cannot be empty" if name.to_s.empty?
      warn "Unknown channel prefix #{name[0,1]}" if name !~ /^[&#+!]/
      raise ArgumentError, "Invalid character in #{name.inspect}" if name =~ /[ \x07,]/

      init_server_or_casemap(opts)

      @name = name

      @topic = topic ? topic.to_irc_channel_topic : Channel::Topic.new

      @users = UserList.new

      users.each { |u|
        add_user(u)
      }

      # Flags
      @mode = ModeHash.new

      # creation time, only on some networks
      @creation_time = nil

      # URL, only on some networks
      @url = nil
    end

npname(str) click to toggle source

Return the non-prefixed part of a channel name. Also works with ## channels found on some networks (e.g. FreeNode)

    # File lib/rbot/irc.rb, line 1335
    def self.npname(str)
      return str.to_s.sub(/^[&#+!]+/,'')
    end

### Public Instance Methods

add_user(user, opts={}) click to toggle source

Adds a user to the channel

    # File lib/rbot/irc.rb, line 1380
    def add_user(user, opts={})
      silent = opts.fetch(:silent, false)
      if has_user?(user)
        warn "Trying to add user #{user} to channel #{self} again" unless silent
      else
        @users << user.to_irc_user(server_and_casemap)
      end
    end

create_mode(sym, kl) click to toggle source

Create a new mode

    # File lib/rbot/irc.rb, line 1463
    def create_mode(sym, kl)
      @mode[sym.to_sym] = kl.new(self)
    end

delete_user(user) click to toggle source

Removes a user from the channel

    # File lib/rbot/irc.rb, line 1424
    def delete_user(user)
      @mode.each { |sym, mode|
        mode.reset(user) if mode.kind_of?(UserMode)
      }
      @users.delete(user)
    end

get_user(nick) click to toggle source

Returns the user with nick nick, if available

    # File lib/rbot/irc.rb, line 1373
    def get_user(nick)
      idx = has_user?(nick)
      @users[idx] if idx
    end

has_op?(user) click to toggle source

    # File lib/rbot/irc.rb, line 1475
    def has_op?(user)
      @mode.has_key?(:o) and @mode[:o].list[user]
    end

has_user?(nick) click to toggle source

Checks if the receiver already has a user with the given nick

    # File lib/rbot/irc.rb, line 1367
    def has_user?(nick)
      @users.index(nick.to_irc_user(server_and_casemap))
    end

has_voice?(user) click to toggle source

    # File lib/rbot/irc.rb, line 1479
    def has_voice?(user)
      @mode.has_key?(:v) and @mode[:v].list[user]
    end

inspect() click to toggle source

    # File lib/rbot/irc.rb, line 1344
    def inspect
      str = self.__to_s__[0..-2]
      str << " on server #{server}" if server
      str << " @name=#{@name.inspect} @topic=#{@topic.text.inspect}"
      str << " @users=[#{user_nicks.sort.join(', ')}]"
      str << " (created on #{creation_time})" if creation_time
      str << " (URL #{url})" if url
      str << ">"
    end

local?() click to toggle source

A channel is local to a server if it has the '&' prefix

    # File lib/rbot/irc.rb, line 1439
    def local?
      name[0,1] == '&'
    end

modeless?() click to toggle source

A channel is modeless if it has the '+' prefix

    # File lib/rbot/irc.rb, line 1445
    def modeless?
      name[0,1] == '+'
    end

modes_of(user) click to toggle source

    # File lib/rbot/irc.rb, line 1467
    def modes_of(user)
      l = []
      @mode.map { |s, m|
        l << s if (m.class <= UserMode and m.list[user])
      }
      l
    end

normal?() click to toggle source

A channel is normal if it has the '#' prefix

    # File lib/rbot/irc.rb, line 1457
    def normal?
      name[0,1] == '#'
    end

prefix() click to toggle source

The channel prefix

    # File lib/rbot/irc.rb, line 1433
    def prefix
      name[0,1]
    end

safe?() click to toggle source

A channel is safe if it has the '!' prefix

    # File lib/rbot/irc.rb, line 1451
    def safe?
      name[0,1] == '!'
    end

to_irc_channel() click to toggle source

Returns self

    # File lib/rbot/irc.rb, line 1356
    def to_irc_channel
      self
    end

user_nicks() click to toggle source

TODO Ho

    # File lib/rbot/irc.rb, line 1361
    def user_nicks
      @users.map { |u| u.downcase }
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.