### Home Classes Methods

### In Files

- lib/rbot/core/utils/extends.rb
- lib/rbot/message.rb

### Parent

Object

### Methods

- ::new
- ::strip_formatting
- ::strip_initial_formatting
- ::stripcolour
- #address?
- #botuser
- #identified?
- #inspect
- #parse_channel_list
- #prefixed?
- #recurse_depth
- #recurse_depth=
- #sourceaddress
- #sourcenick

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

base user message class, all user messages derive from this (a user message is defined as having a source hostmask, a target nick/channel and a message part)

### Attributes

bot[R]

associated bot

ignored[RW]

should the message be ignored?

ignored?[RW]

should the message be ignored?

in_thread[RW]

set this to true if the method that delegates the message is run in a thread

in_thread?[RW]

set this to true if the method that delegates the message is run in a thread

logmessage[RW]

contents of the message (for logging purposes)

message[RW]

contents of the message (stripped of initial/final format codes)

plainmessage[RW]

contents of the message (stripped of all formatting)

replied[RW]

has the message been replied to/handled by a plugin?

replied?[RW]

has the message been replied to/handled by a plugin?

server[R]

associated server

source[R]

User that originated the message

target[R]

User/Channel message was sent to

time[R]

when the message was received

### Public Class Methods

new(bot, server, source, target, message) click to toggle source

instantiate a new Message

bot | associated bot class
server | Server where the message took place
source | User that sent the message
target | User/Channel is destined for
message | actual message

    # File lib/rbot/message.rb, line 179
    def initialize(bot, server, source, target, message)
      @msg_wants_id = false unless defined? @msg_wants_id

      @time = Time.now
      @bot = bot
      @source = source
      @address = false
      @prefixed = false
      @target = target
      @message = message || ""
      @replied = false
      @server = server
      @ignored = false
      @in_thread = false

      @identified = false
      if @msg_wants_id && @server.capabilities[:"identify-msg"]
        if @message =~ /^([-+])(.*)/
          @identified = ($1=="+")
          @message = $2
        else
          warning "Message does not have identification"
        end
      end
      @logmessage = @message.dup
      @plainmessage = BasicUserMessage.strip_formatting(@message)
      @message = BasicUserMessage.strip_initial_formatting(@message)

      if target && target == @bot.myself
        @address = true
      end

    end

strip_formatting(string) click to toggle source

    # File lib/rbot/message.rb, line 264
    def BasicUserMessage.strip_formatting(string)
      string.gsub(FormattingRx,"")
    end

strip_initial_formatting(string) click to toggle source

    # File lib/rbot/message.rb, line 259
    def BasicUserMessage.strip_initial_formatting(string)
      return "" unless string
      ret = string.gsub(/^#{FormattingRx}|#{FormattingRx}$/,"")
    end

stripcolour(string) click to toggle source

strip mIRC colour escapes from a string

    # File lib/rbot/message.rb, line 252
    def BasicUserMessage.stripcolour(string)
      return "" unless string
      ret = string.gsub(ColorRx, "")
      #ret.tr!("\x00-\x1f", "")
      ret
    end

### Public Instance Methods

address?() click to toggle source

returns true if the message was addressed to the bot. This includes any private message to the bot, or any public message which looks like it's addressed to the bot, e.g. "bot: foo", "bot, foo", a kick message when bot was kicked etc.

    # File lib/rbot/message.rb, line 241
    def address?
      return @address
    end

botuser() click to toggle source

Access the botuser corresponding to the source, if any

    # File lib/rbot/message.rb, line 227
    def botuser
      source.botuser rescue @bot.auth.everyone
    end

identified?() click to toggle source

Was the message from an identified user?

    # File lib/rbot/message.rb, line 233
    def identified?
      return @identified
    end

inspect(fields=nil) click to toggle source

    # File lib/rbot/message.rb, line 150
    def inspect(fields=nil)
      ret = self.__to_s__[0..-2]
      ret << ' bot=' << @bot.__to_s__
      ret << ' server=' << server.to_s
      ret << ' time=' << time.to_s
      ret << ' source=' << source.to_s
      ret << ' target=' << target.to_s
      ret << ' message=' << message.inspect
      ret << ' logmessage=' << logmessage.inspect
      ret << ' plainmessage=' << plainmessage.inspect
      ret << fields if fields
      ret << ' (identified)' if identified?
      if address?
        ret << ' (addressed to me'
        ret << ', with prefix' if prefixed?
        ret << ')'
      end
      ret << ' (replied)' if replied?
      ret << ' (ignored)' if ignored?
      ret << ' (in thread)' if in_thread?
      ret << '>'
    end

parse_channel_list(string) click to toggle source

We extend the BasicUserMessage class with a method that parses a string which is a channel list as matched by IN_CHAN(_LIST) and co. The method returns an array of channel names, where 'private' or 'pvt' is replaced by the Symbol :"?", 'here' is replaced by the channel of the message or by :"?" (depending on whether the message target is the bot or a Channel), and 'anywhere' and 'everywhere' are replaced by Symbol :*

    # File lib/rbot/core/utils/extends.rb, line 421
    def parse_channel_list(string)
      return [:*] if [:anywhere, :everywhere].include? string.to_sym
      string.scan(
      /(?:^|,?(?:\s+and)?\s+)(?:in|on\s+)?(#{Regexp::Irc::GEN_CHAN}|here|private|pvt)/
                 ).map { |chan_ar|
        chan = chan_ar.first
        case chan.to_sym
        when :private, :pvt
          :"?"
        when :here
          case self.target
          when Channel
            self.target.name
          else
            :"?"
          end
        else
          chan
        end
      }.uniq
    end

prefixed?() click to toggle source

returns true if the messaged was addressed to the bot via the address prefix. This can be used to tell appart "!do this" from "botname, do this"

    # File lib/rbot/message.rb, line 247
    def prefixed?
      return @prefixed
    end

recurse_depth() click to toggle source

The recurse depth of a message, for fake messages. 0 means an original message

    # File lib/rbot/core/utils/extends.rb, line 445
    def recurse_depth
      unless defined? @recurse_depth
        @recurse_depth = 0
      end
      @recurse_depth
    end

recurse_depth=(val) click to toggle source

Set the recurse depth of a message, for fake messages. 0 should only be used by original messages

    # File lib/rbot/core/utils/extends.rb, line 454
    def recurse_depth=(val)
      @recurse_depth = val
    end

sourceaddress() click to toggle source

Access the user@host of the source

    # File lib/rbot/message.rb, line 221
    def sourceaddress
      "#{@source.user}@#{@source.host}" rescue @source.to_s
    end

sourcenick() click to toggle source

Access the nick of the source

    # File lib/rbot/message.rb, line 215
    def sourcenick
      @source.nick rescue @source.to_s
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.