### Home Classes Methods

### In Files

- lib/rbot/core/basics.rb

### Parent

CoreBotModule

### Methods

- #bot_action
- #bot_channel_list
- #bot_help
- #bot_hide
- #bot_join
- #bot_mode
- #bot_part
- #bot_ping
- #bot_quiet
- #bot_quit
- #bot_reconnect
- #bot_restart
- #bot_say
- #bot_talk
- #connect
- #ctcp_listen
- #help
- #identified
- #invite
- #join_channels

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

# BasicsModule

Author | Giuseppe "Oblomov" Bilotta <giuseppe.bilotta@gmail.com>

### Public Instance Methods

bot_action(m, param) click to toggle source

    # File lib/rbot/core/basics.rb, line 106
    def bot_action(m, param)
      @bot.action param[:where], param[:what].to_s
    end

bot_channel_list(m, param) click to toggle source

    # File lib/rbot/core/basics.rb, line 72
    def bot_channel_list(m, param)
      ret = _('I am in: ')
      # sort the channels by the base name and then map with prefixes for the
      # mode and display.
      ret << @bot.channels.compact.sort { |a,b|
          a.name.downcase <=> b.name.downcase
      }.map { |c|
          c.modes_of(@bot.myself).map{ |mo|
            m.server.prefix_for_mode(mo)
          }.to_s + c.name
      }.join(', ')
      m.reply ret
    end

bot_help(m, param) click to toggle source

    # File lib/rbot/core/basics.rb, line 140
    def bot_help(m, param)
      m.reply @bot.help(param[:topic].join(" "))
    end

bot_hide(m, param) click to toggle source

    # File lib/rbot/core/basics.rb, line 98
    def bot_hide(m, param)
      @bot.join 0
    end

bot_join(m, param) click to toggle source

    # File lib/rbot/core/basics.rb, line 50
    def bot_join(m, param)
      if param[:pass]
        @bot.join param[:chan], param[:pass]
      else
        @bot.join param[:chan]
      end
    end

bot_mode(m, param) click to toggle source

    # File lib/rbot/core/basics.rb, line 110
    def bot_mode(m, param)
      @bot.mode param[:where], param[:what], param[:who].join(" ")
    end

bot_part(m, param) click to toggle source

    # File lib/rbot/core/basics.rb, line 64
    def bot_part(m, param)
      if param[:chan]
        @bot.part param[:chan]
      else
        @bot.part m.target if m.public?
      end
    end

bot_ping(m, param) click to toggle source

    # File lib/rbot/core/basics.rb, line 114
    def bot_ping(m, param)
      m.reply "pong"
    end

bot_quiet(m, param) click to toggle source

    # File lib/rbot/core/basics.rb, line 118
    def bot_quiet(m, param)
      if param.has_key?(:where)
        @bot.set_quiet param[:where].sub(/^here$/, m.target.downcase)
      else
        @bot.set_quiet
      end
      # Make sense when the commmand is given in private or in a non-quieted
      # channel
      m.okay
    end

bot_quit(m, param) click to toggle source

    # File lib/rbot/core/basics.rb, line 86
    def bot_quit(m, param)
      @bot.quit param[:msg].to_s
    end

bot_reconnect(m, param) click to toggle source

    # File lib/rbot/core/basics.rb, line 94
    def bot_reconnect(m, param)
      @bot.reconnect param[:msg].to_s
    end

bot_restart(m, param) click to toggle source

    # File lib/rbot/core/basics.rb, line 90
    def bot_restart(m, param)
      @bot.restart param[:msg].to_s
    end

bot_say(m, param) click to toggle source

    # File lib/rbot/core/basics.rb, line 102
    def bot_say(m, param)
      @bot.say param[:where], param[:what].to_s
    end

bot_talk(m, param) click to toggle source

    # File lib/rbot/core/basics.rb, line 129
    def bot_talk(m, param)
      if param.has_key?(:where)
        @bot.reset_quiet param[:where].sub(/^here$/, m.target.downcase)
      else
        @bot.reset_quiet
      end
      # Make sense when the commmand is given in private or in a non-quieted
      # channel
      m.okay
    end

connect() click to toggle source

on connect, we join the default channels unless we have to wait for identification. Observe that this means the bot may not connect any channels until the 'identified' method gets delegated

    # File lib/rbot/core/basics.rb, line 32
    def connect
      if @bot.config['irc.join_after_identify']
        log "waiting for identififcation before JOINing default channels"
      else
        join_channels
      end
    end

ctcp_listen(m) click to toggle source

    # File lib/rbot/core/basics.rb, line 40
    def ctcp_listen(m)
      who = m.private? ? "me" : m.target
      case m.ctcp.intern
      when :PING
        m.ctcp_reply m.message
      when :TIME
        m.ctcp_reply Time.now.to_s
      end
    end

help(cmd, topic="") click to toggle source

handle help requests for "core" topics

    # File lib/rbot/core/basics.rb, line 152
    def help(cmd, topic="")
      case cmd
      when "quit"
        _("quit [<message>] => quit IRC with message <message>")
      when "restart"
        _("restart => completely stop and restart the bot (including reconnect)")
      when "reconnect"
        _("reconnect => ask the bot to disconnect and then connect again")
      when "join"
        _("join <channel> [<key>] => join channel <channel> with secret key <key> if specified. #{@bot.myself} also responds to invites if you have the required access level")
      when "part"
        _("part <channel> => part channel <channel>")
      when "hide"
        _("hide => part all channels")
      when "say"
        _("say <channel>|<nick> <message> => say <message> to <channel> or in private message to <nick>")
      when "action"
        _("action <channel>|<nick> <message> => does a /me <message> to <channel> or in private message to <nick>")
      when "quiet"
        _("quiet [in here|<channel>] => with no arguments, stop speaking in all channels, if \"in here\", stop speaking in this channel, or stop speaking in <channel>")
      when "talk"
        _("talk [in here|<channel>] => with no arguments, resume speaking in all channels, if \"in here\", resume speaking in this channel, or resume speaking in <channel>")
      when "ping"
        _("ping => replies with a pong")
      when "mode"
        _("mode <channel> <mode> <nicks> => set channel modes for <nicks> on <channel> to <mode>")
      #     when "botsnack"
      #       return "botsnack => reward #{@bot.myself} for being good"
      #     when "hello"
      #       return "hello|hi|hey|yo [#{@bot.myself}] => greet the bot"
      else
        _("%{name}: quit, restart, join, part, hide, save, say, action, topic, quiet, talk, ping, mode") % {:name=>name}
        #, botsnack, hello
      end
    end

identified() click to toggle source

    # File lib/rbot/core/basics.rb, line 25
    def identified
      join_channels
    end

invite(m) click to toggle source

    # File lib/rbot/core/basics.rb, line 58
    def invite(m)
      if @bot.auth.allow?(:"basics::move::join", m.source, m.source)
        @bot.join m.channel
      end
    end

join_channels() click to toggle source

    # File lib/rbot/core/basics.rb, line 14
    def join_channels
      @bot.config['irc.join_channels'].each { |c|
        debug "autojoining channel #{c}"
        if(c =~ /^(\S+)\s+(\S+)$/)
          @bot.join $1, $2
        else
          @bot.join c if(c)
        end
      }
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.