### Home Classes Methods

### In Files

- lib/rbot/irc.rb
- lib/rbot/core/userdata.rb
- lib/rbot/botuser.rb

### Parent

Irc::Netmask

### Methods

- ::new
- #away=
- #away?
- #botdata
- #botuser
- #channels
- #delete_botdata
- #get_botdata
- #host=
- #is_op?
- #is_voice?
- #known?
- #modes_on
- #nick=
- #replace
- #set_botdata
- #to_irc_user
- #user=
- #with_botdata

### 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::User

An IRC User is identified by his/her Netmask (which must not have globs). In fact, User is just a subclass of Netmask.

Ideally, the user and host information of an IRC User should never change, and it shouldn't contain glob patterns. However, IRC is somewhat idiosincratic and it may be possible to know the nick of a User much before its user and host are known. Moreover, some networks (namely Freenode) may change the hostname of a User when (s)he identifies with Nickserv.

As a consequence, we must allow changes to a User host and user attributes. We impose a restriction, though: they may not contain glob patterns, except for the special case of an unknown user/host which is represented by a *.

It is possible to create a totally unknown User (e.g. for initializations) by setting the nick to * too.

TODO list:

- see if it's worth to add the other USER data

- see if it's worth to add NICKSERV status

### Attributes

idle_since[RW]
real_name[RW]
signon[RW]

### Public Class Methods

new(str="", opts={}) click to toggle source

Create a new IRC User from a given Netmask (or anything that can be converted into a Netmask) provided that the given Netmask does not have globs.

    # File lib/rbot/irc.rb, line 953
    def initialize(str="", opts={})
      super
      raise ArgumentError, "#{str.inspect} must not have globs (unescaped * or ?)" if nick.has_irc_glob? && nick != "*"
      raise ArgumentError, "#{str.inspect} must not have globs (unescaped * or ?)" if user.has_irc_glob? && user != "*"
      raise ArgumentError, "#{str.inspect} must not have globs (unescaped * or ?)" if host.has_irc_glob? && host != "*"
      @away = false
      @real_name = String.new
      @idle_since = nil
      @signon = nil
    end

### Public Instance Methods

away=(msg="") click to toggle source

Set the away status of the user. Use away=(nil) or away=(false) to unset away

    # File lib/rbot/irc.rb, line 1004
    def away=(msg="")
      if msg
        @away = msg
      else
        @away = false
      end
    end

away?() click to toggle source

Is the user away?

    # File lib/rbot/irc.rb, line 997
    def away?
      return @away
    end

botdata(key=nil) click to toggle source

Retrive Bot data associated with the receiver. This method is intended for data retrieval only. See set_bot_data() if you need to alter User data.

    # File lib/rbot/core/userdata.rb, line 14
    def botdata(key=nil)
      Irc::Utils.bot.plugins['userdata'].get_data(self,key)
    end

Also aliased as: get_botdata
botuser() click to toggle source

A convenience method to automatically found the botuser associated with the receiver

    # File lib/rbot/botuser.rb, line 935
    def botuser
      Irc::Bot::Auth.manager.irc_to_botuser(self)
    end

channels() click to toggle source

    # File lib/rbot/irc.rb, line 1068
    def channels
      if @server
        @server.channels.select { |ch| ch.has_user?(self) }
      else
        Array.new
      end
    end

delete_botdata(*keys) click to toggle source

This method removes the data associated with the key, returning the value of the deleted key.

    # File lib/rbot/core/userdata.rb, line 44
    def delete_botdata(*keys)
      Irc::Utils.bot.plugins['userdata'].delete_data(self, *keys)
    end

get_botdata(key=nil) click to toggle source
Alias for: botdata
host=(newhost) click to toggle source

We have to allow changing the host of an Irc User due to some networks (e.g. Freenode) changing hostmasks on the fly. We still check if the new host data has glob patterns though.

    # File lib/rbot/irc.rb, line 984
    def host=(newhost)
      raise "Can't change the hostname to #{newhost}" if defined?(@host) and newhost.has_irc_glob?
      super
    end

is_op?(channel) click to toggle source

    # File lib/rbot/irc.rb, line 1048
    def is_op?(channel)
      case channel
      when Channel
        channel.has_op?(self)
      else
        return @server.channel(channel).has_op?(self) if @server
        raise "Can't resolve channel #{channel}"
      end
    end

is_voice?(channel) click to toggle source

    # File lib/rbot/irc.rb, line 1058
    def is_voice?(channel)
      case channel
      when Channel
        channel.has_voice?(self)
      else
        return @server.channel(channel).has_voice?(self) if @server
        raise "Can't resolve channel #{channel}"
      end
    end

known?() click to toggle source

Checks if a User is well-known or not by looking at the hostname and user

    # File lib/rbot/irc.rb, line 991
    def known?
      return nick != "*" && user != "*" && host != "*"
    end

modes_on(channel) click to toggle source

    # File lib/rbot/irc.rb, line 1038
    def modes_on(channel)
      case channel
      when Channel
        channel.modes_of(self)
      else
        return @server.channel(channel).modes_of(self) if @server
        raise "Can't resolve channel #{channel}"
      end
    end

nick=(newnick) click to toggle source

The nick of a User may be changed freely, but it must not contain glob patterns.

    # File lib/rbot/irc.rb, line 966
    def nick=(newnick)
      raise "Can't change the nick to #{newnick}" if defined?(@nick) and newnick.has_irc_glob?
      super
    end

replace(other) click to toggle source

We can replace everything at once with data from another User

    # File lib/rbot/irc.rb, line 1024
    def replace(other)
      case other
      when User
        self.nick = other.nick
        self.user = other.user
        self.host = other.host
        @server = other.server
        @casemap = other.casemap unless @server
        @away = other.away?
      else
        self.replace(other.to_irc_user(server_and_casemap))
      end
    end

set_botdata(key, value=nil, &block) click to toggle source

This method is used to store Bot data associated with the receiver. If no block is passed, value is stored for the key key; if a block is passed, it will be called with the previous key value as parameter, and its return value will be stored as the new value. If value is present in the block form, it will be used to initialize key if it's missing.

If you have to do large-scale editing of the Bot data Hash, please use with_botdata.

    # File lib/rbot/core/userdata.rb, line 29
    def set_botdata(key, value=nil, &block)
      Irc::Utils.bot.plugins['userdata'].set_data(self, key, value, &block)
    end

to_irc_user(opts={}) click to toggle source

Since to_irc_user runs the same checks on server and channel as to_irc_netmask, we just try that and return self if it works.

Subclasses of User will return self if possible.

    # File lib/rbot/irc.rb, line 1017
    def to_irc_user(opts={})
      return self if fits_with_server_and_casemap?(opts)
      return self.full_downcase.to_irc_user(opts)
    end

user=(newuser) click to toggle source

We have to allow changing the user of an Irc User due to some networks (e.g. Freenode) changing hostmasks on the fly. We still check if the new user data has glob patterns though.

    # File lib/rbot/irc.rb, line 975
    def user=(newuser)
      raise "Can't change the username to #{newuser}" if defined?(@user) and newuser.has_irc_glob?
      super
    end

with_botdata(&block) click to toggle source

This method yields the entire Bot data Hash to the block, and stores any changes done to it, returning a copy of the (changed) Hash.

    # File lib/rbot/core/userdata.rb, line 37
    def with_botdata(&block)
      Irc::Utils.bot.plugins['userdata'].with_data(self, &block)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.