diff options
-rw-r--r-- | lib/rbot/core/auth.rb | 8 | ||||
-rw-r--r-- | lib/rbot/ircbot.rb | 3 | ||||
-rw-r--r-- | lib/rbot/message.rb | 4 | ||||
-rw-r--r-- | lib/rbot/plugins.rb | 4 | ||||
-rw-r--r-- | lib/rbot/rfc2812.rb | 3 |
5 files changed, 17 insertions, 5 deletions
diff --git a/lib/rbot/core/auth.rb b/lib/rbot/core/auth.rb index 32e6f733..c37c9273 100644 --- a/lib/rbot/core/auth.rb +++ b/lib/rbot/core/auth.rb @@ -293,8 +293,8 @@ class AuthModule < CoreBotModule get_botuser_for(user).username end - def welcome(user) - _("welcome, %{user}") % {:user => get_botusername_for(user)} + def say_welcome(m) + m.reply _("welcome, %{user}") % {:user => get_botusername_for(m.source)} end def auth_auth(m, params) @@ -306,7 +306,7 @@ class AuthModule < CoreBotModule begin case @bot.auth.login(m.source, params[:botuser], params[:password]) when true - m.reply welcome(m.source) + say_welcome(m) @bot.auth.set_changed else m.reply _("sorry, can't do") @@ -322,7 +322,7 @@ class AuthModule < CoreBotModule if u.default? m.reply _("I couldn't find anything to let you login automatically") else - m.reply welcome(m.source) + say_welcome(m) end end diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb index 9afdc46c..29c0a116 100644 --- a/lib/rbot/ircbot.rb +++ b/lib/rbot/ircbot.rb @@ -528,8 +528,11 @@ class Bot @quiet = [] @client[:welcome] = proc {|data| + m = WelcomeMessage.new(self, server, data[:source], data[:target], data[:message]) + irclog "joined server #{@client.server} as #{myself}", "server" + @plugins.delegate("welcome", m) @plugins.delegate("connect") @config['irc.join_channels'].each { |c| diff --git a/lib/rbot/message.rb b/lib/rbot/message.rb index 918425d9..d923fd8e 100644 --- a/lib/rbot/message.rb +++ b/lib/rbot/message.rb @@ -215,6 +215,10 @@ module Irc end + # class for handling welcome messages from the server + class WelcomeMessage < BasicUserMessage + end + # class for handling IRC user messages. Includes some utilities for handling # the message, for example in plugins. # The +message+ member will have any bot addressing "^bot: " removed diff --git a/lib/rbot/plugins.rb b/lib/rbot/plugins.rb index 8c077bea..d714fcf3 100644 --- a/lib/rbot/plugins.rb +++ b/lib/rbot/plugins.rb @@ -118,6 +118,10 @@ module Plugins Called when a user (or the bot) changes a channel topic + welcome(WelcomeMessage):: + Called when the welcome message is received on + joining a server succesfully. + connect:: Called when a server is joined successfully, but before autojoin channels are joined (no params) diff --git a/lib/rbot/rfc2812.rb b/lib/rbot/rfc2812.rb index b5203648..f3dabf30 100644 --- a/lib/rbot/rfc2812.rb +++ b/lib/rbot/rfc2812.rb @@ -1069,13 +1069,14 @@ module Irc num=command.to_i case num when RPL_WELCOME + data[:message] = argv[1] # "Welcome to the Internet Relay Network # <nick>!<user>@<host>" if not_us warning "Server thinks client (#{@user.inspect}) has a different nick" @user.nick = data[:target] end - if argv[1] =~ /([^@!\s]+)(?:!([^@!\s]+?))?@(\S+)/ + if data[:message] =~ /([^@!\s]+)(?:!([^@!\s]+?))?@(\S+)/ nick = $1 user = $2 host = $3 |