diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-02-18 21:03:26 +0000 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-02-18 21:03:26 +0000 |
commit | 7b7f1309e8c3dbc3bb4408d56489ae5fba77d57a (patch) | |
tree | 5e7b503927d65e3e3fc552e8422aa3cf4b8f61e1 | |
parent | 24eda0b8d6e3ad839d1a8a1093de9c0089268068 (diff) |
Initial steps towards a namespace rationalization
-rwxr-xr-x | bin/rbot | 2 | ||||
-rw-r--r-- | data/rbot/plugins/script.rb | 2 | ||||
-rw-r--r-- | lib/rbot/core/remote.rb | 4 | ||||
-rw-r--r-- | lib/rbot/ircbot.rb | 10 | ||||
-rw-r--r-- | lib/rbot/rfc2812.rb | 26 |
5 files changed, 22 insertions, 22 deletions
@@ -112,7 +112,7 @@ if ($opts["help"]) exit 0 end -if(bot = Irc::IrcBot.new(ARGV.shift, :argv => orig_opts)) +if(bot = Irc::Bot.new(ARGV.shift, :argv => orig_opts)) # just run the bot bot.mainloop end diff --git a/data/rbot/plugins/script.rb b/data/rbot/plugins/script.rb index c091b586..1b695868 100644 --- a/data/rbot/plugins/script.rb +++ b/data/rbot/plugins/script.rb @@ -36,7 +36,7 @@ class ScriptPlugin < Plugin def help( plugin, topic="" ) if topic == "add" - "Scripts are little Ruby programs that run in the context of the script plugin. You can access @bot (class IrcBot), m (class PrivMessage), user (class String, either the first argument, or if missing the sourcenick), and args (class Array, an array of arguments). Example: 'script add greet m.reply( 'Hello ' + user )'. Invoke the script just like a plugin: '<botnick>: greet'." + "Scripts are little Ruby programs that run in the context of the script plugin. You can access @bot (class Irc::Bot), m (class Irc::PrivMessage), user (class String, either the first argument, or if missing the sourcenick), and args (class Array, an array of arguments). Example: 'script add greet m.reply( 'Hello ' + user )'. Invoke the script just like a plugin: '<botnick>: greet'." else "Create mini plugins on IRC. 'script add <name> <code>' => Create script named <name> with the Ruby program <code>. 'script list' => Show a list of all known scripts. 'script show <name>' => Show the source code for <name>. 'script del <name>' => Delete the script <name>." end diff --git a/lib/rbot/core/remote.rb b/lib/rbot/core/remote.rb index 35827d89..7ced878f 100644 --- a/lib/rbot/core/remote.rb +++ b/lib/rbot/core/remote.rb @@ -192,9 +192,9 @@ module ::Irc end - class IrcBot + class Bot - # The Irc::IrcBot::RemoteObject class represents and object that will take care + # The Irc::Bot::RemoteObject class represents and object that will take care # of interfacing with remote clients # # Example client session: diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb index bd19e637..bc6cf760 100644 --- a/lib/rbot/ircbot.rb +++ b/lib/rbot/ircbot.rb @@ -88,8 +88,8 @@ module Irc # Main bot class, which manages the various components, receives messages, # handles them or passes them to plugins, and contains core functionality. -class IrcBot - # the bot's IrcAuth data +class Bot + # the bot's Auth data attr_reader :auth # the bot's BotConfig data @@ -134,7 +134,7 @@ class IrcBot # bot User in the client/server connection # TODO multiserver def myself - @client.client + @client.user end # bot User in the client/server connection @@ -142,7 +142,7 @@ class IrcBot myself.nick end - # create a new IrcBot with botclass +botclass+ + # create a new Bot with botclass +botclass+ def initialize(botclass, params = {}) # BotConfig for the core bot # TODO should we split socket stuff into ircsocket, etc? @@ -437,7 +437,7 @@ class IrcBot @socket = IrcSocket.new(@config['server.name'], @config['server.port'], @config['server.bindhost'], @config['server.sendq_delay'], @config['server.sendq_burst'], :ssl => @config['server.ssl']) - @client = IrcClient.new + @client = Client.new # Channels where we are quiet # Array of channels names where the bot should be quiet diff --git a/lib/rbot/rfc2812.rb b/lib/rbot/rfc2812.rb index 4a095dc8..1a5adb84 100644 --- a/lib/rbot/rfc2812.rb +++ b/lib/rbot/rfc2812.rb @@ -812,16 +812,16 @@ module Irc RPL_DATASTR=290 # implements RFC 2812 and prior IRC RFCs. - # clients register handler proc{}s for different server events and IrcClient + # clients register handler proc{}s for different server events and Client # handles dispatch - class IrcClient + class Client - attr_reader :server, :client + attr_reader :server, :user - # create a new IrcClient instance + # create a new Client instance def initialize @server = Server.new # The Server - @client = @server.user("") # The User representing the client on this Server + @user = @server.user("") # The User representing the client on this Server @handlers = Hash.new @@ -921,9 +921,9 @@ module Irc data[:target] = argv[0] # A numeric reply /should/ be directed at the client, except when we're connecting with a used nick, in which case # it's directed at '*' - not_us = !([@client.nick, '*'].include?(data[:target])) + not_us = !([@user.nick, '*'].include?(data[:target])) if not_us - warning "Server reply #{serverstring.inspect} directed at #{data[:target]} instead of client (#{@client.nick})" + warning "Server reply #{serverstring.inspect} directed at #{data[:target]} instead of client (#{@user.nick})" end num=command.to_i @@ -932,16 +932,16 @@ module Irc # "Welcome to the Internet Relay Network # <nick>!<user>@<host>" if not_us - warning "Server thinks client (#{@client.inspect}) has a different nick" - @client.nick = data[:target] + warning "Server thinks client (#{@user.inspect}) has a different nick" + @user.nick = data[:target] end if argv[1] =~ /(\S+)(?:!(\S+?))?@(\S+)/ nick = $1 user = $2 host = $2 warning "Welcome message nick mismatch (#{nick} vs #{data[:target]})" if nick != data[:target] - @client.user = user if user - @client.host = host if host + @user.user = user if user + @user.host = host if host end handle(:welcome, data) when RPL_YOURHOST @@ -1162,7 +1162,7 @@ module Irc data[:message] = argv[2] @server.delete_user_from_channel(data[:target], data[:channel]) - if data[:target] == @client + if data[:target] == @user @server.delete_channel(data[:channel]) end @@ -1172,7 +1172,7 @@ module Irc data[:message] = argv[1] @server.delete_user_from_channel(data[:source], data[:channel]) - if data[:source] == @client + if data[:source] == @user @server.delete_channel(data[:channel]) end |