]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
Initial steps towards a namespace rationalization
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Sun, 18 Feb 2007 21:03:26 +0000 (21:03 +0000)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Sun, 18 Feb 2007 21:03:26 +0000 (21:03 +0000)
bin/rbot
data/rbot/plugins/script.rb
lib/rbot/core/remote.rb
lib/rbot/ircbot.rb
lib/rbot/rfc2812.rb

index 8fba53d6c3a908029532278635bbb52647068268..5872e3e1c7bd43683debecfa417294e6369ce987 100755 (executable)
--- a/bin/rbot
+++ b/bin/rbot
@@ -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
index c091b5864a430baa4fc291016ff888a6cdf1b208..1b69586816c06a53365da5299a8f27ddc796cf07 100644 (file)
@@ -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
index 35827d89e81eae58f238c6a3a427ca3812a659be..7ced878f57e7d4c8f230627688360d94e8afcacf 100644 (file)
@@ -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:
index bd19e6375e3b4021703c3c25a678714b9e083189..bc6cf76093b08b29369e5d09d431a61519618ea8 100644 (file)
@@ -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
index 4a095dc8dac0b0dc0bfb95d812f702b53fedfd5a..1a5adb846edf3419487d21489ed55fd0bcc6c3e0 100644 (file)
@@ -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