summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Gilbert <tom@linuxbrit.co.uk>2005-03-10 12:11:17 +0000
committerTom Gilbert <tom@linuxbrit.co.uk>2005-03-10 12:11:17 +0000
commit787c3322e0c1acdccb457c47bea76f31c5747f52 (patch)
tree6dc7e8e1bb39907208c441994127e4d6e63da03c
parentbebe7f8392f3f1750bc196cb19bd4bfbda3310b6 (diff)
fix http usage, other tweaks
-rw-r--r--ChangeLog11
-rw-r--r--TODO1
-rw-r--r--rbot/ircbot.rb4
-rw-r--r--rbot/keywords.rb1
-rw-r--r--rbot/message.rb12
-rw-r--r--rbot/plugins/google.rb22
-rw-r--r--rbot/plugins/nickserv.rb8
-rw-r--r--rbot/utils.rb16
8 files changed, 53 insertions, 22 deletions
diff --git a/ChangeLog b/ChangeLog
index ec1c8886..d6506ee8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+Wed Oct 13 16:16:31 BST 2004 Tom Gilbert <tom@linuxbrit.co.uk>
+
+ * Fix bug with quotes plugin where it gets confused and sees both a quote
+ and a keyword, both plugins are triggered by, for example "addquote foo is
+ bar"
+ * fixed this by implementing the "has_responded" flag on a message. When a
+ plugin replied to a message (or it manually sets m.replied to true), the
+ keywords plugin will honour that flag and not examine the message for
+ keywords. This flag can also be checked by listen plugins that don't want to
+ interfere with other plugin commands.
+
Mon Oct 11 00:37:52 BST 2004 Tom Gilbert <tom@linuxbrit.co.uk>
* Fixes to the NickServ plugin
diff --git a/TODO b/TODO
index 1cba66db..6c9bae1f 100644
--- a/TODO
+++ b/TODO
@@ -1,5 +1,4 @@
o runtime language changing
-o keyword searching
o maybe runtime language configuration?
o freeze/thaw factoids (make them readonly) at higher auth
o respond to insults
diff --git a/rbot/ircbot.rb b/rbot/ircbot.rb
index 60ed5e98..45603963 100644
--- a/rbot/ircbot.rb
+++ b/rbot/ircbot.rb
@@ -69,6 +69,9 @@ class IrcBot
# storage (hash interface tied to a bdb file, plugins use Accessors to store
# and restore objects in their own namespaces.)
attr_reader :registry
+
+ # our webrick instance
+ attr_reader :http_server
# create a new IrcBot with botclass +botclass+
def initialize(botclass)
@@ -392,6 +395,7 @@ class IrcBot
@socket.flush
@socket.shutdown
@registry.close
+ @http_server.shutdown
puts "rbot quit (#{message})"
exit 0
end
diff --git a/rbot/keywords.rb b/rbot/keywords.rb
index b8ce84fd..7895b399 100644
--- a/rbot/keywords.rb
+++ b/rbot/keywords.rb
@@ -350,6 +350,7 @@ module Irc
# privmsg handler
def privmsg(m)
+ return if m.replied?
if(m.address?)
if(!(m.message =~ /\\\?\s*$/) && m.message =~ /^(.*\S)\s*\?\s*$/)
keyword m, $1 if(@bot.auth.allow?("keyword", m.source, m.replyto))
diff --git a/rbot/message.rb b/rbot/message.rb
index 8604e1a4..c217b1da 100644
--- a/rbot/message.rb
+++ b/rbot/message.rb
@@ -22,7 +22,10 @@ module Irc
# contents of the message
attr_accessor :message
-
+
+ # has the message been replied to/handled by a plugin?
+ attr_accessor :replied
+
# instantiate a new Message
# bot:: associated bot class
# source:: hostmask of the message source
@@ -35,6 +38,7 @@ module Irc
@address = false
@target = target
@message = BasicUserMessage.stripcolour message
+ @replied = false
# split source into consituent parts
if source =~ /^((\S+)!(\S+))$/
@@ -56,6 +60,11 @@ module Irc
return @address
end
+ # has this message been replied to by a plugin?
+ def replied?
+ return @replied
+ end
+
# strip mIRC colour escapes from a string
def BasicUserMessage.stripcolour(string)
return "" unless string
@@ -163,6 +172,7 @@ module Irc
# in a channel, it will reply in the channel.
def reply(string)
@bot.say @replyto, string
+ @replied = true
end
end
diff --git a/rbot/plugins/google.rb b/rbot/plugins/google.rb
index 5fa466e7..2e9aacba 100644
--- a/rbot/plugins/google.rb
+++ b/rbot/plugins/google.rb
@@ -29,21 +29,21 @@ class GooglePlugin < Plugin
http = Net::HTTP.new("www.google.com", 80, proxy_host, proxy_port)
- http.start {|http|
- begin
- resp , = http.get(query)
+ begin
+ http.start {|http|
+ resp = http.get(query)
if resp.code == "302"
result = resp['location']
end
- rescue => e
- p e
- if e.response && e.response['location']
- result = e.response['location']
- else
- result = "error!"
- end
+ }
+ rescue => e
+ p e
+ if e.response && e.response['location']
+ result = e.response['location']
+ else
+ result = "error!"
end
- }
+ end
m.reply "#{m.params}: #{result}"
end
end
diff --git a/rbot/plugins/nickserv.rb b/rbot/plugins/nickserv.rb
index 6067ec3e..94c57e6d 100644
--- a/rbot/plugins/nickserv.rb
+++ b/rbot/plugins/nickserv.rb
@@ -9,7 +9,7 @@ class NickServPlugin < Plugin
when "password"
return "nickserv password <nick> <passwd>: remember the password for nick <nick> and use it to identify in future"
when "register"
- return "nickserv register [<password>]: register the current nick, choosing a random password unless <password> is supplied - current nick must not already be registered for this to work"
+ return "nickserv register [<password> [<email>]]: register the current nick, choosing a random password unless <password> is supplied - current nick must not already be registered for this to work. Also specify email if required by your services"
when "identify"
return "nickserv identify: identify with nickserv - shouldn't be needed - bot should identify with nickserv immediately on request - however this could be useful after splits or service disruptions, or when you just set the password for the current nick"
when "listnicks"
@@ -44,6 +44,12 @@ class NickServPlugin < Plugin
@bot.sendmsg "PRIVMSG", "NickServ", "REGISTER " + passwd
@registry[@bot.nick] = passwd
@bot.okay m.replyto
+ when (/^register\s*(\S*)\s*(.*)$/)
+ passwd = $1
+ email = $2
+ @bot.sendmsg "PRIVMSG", "NickServ", "REGISTER " + passwd + " " + email
+ @registry[@bot.nick] = passwd
+ @bot.okay m.replyto
when (/^register\s*(.*)\s*$/)
passwd = $1
@bot.sendmsg "PRIVMSG", "NickServ", "REGISTER " + passwd
diff --git a/rbot/utils.rb b/rbot/utils.rb
index 516fb4dc..36276e8d 100644
--- a/rbot/utils.rb
+++ b/rbot/utils.rb
@@ -166,18 +166,18 @@ module Irc
http.open_timeout = opentimeout
http.read_timeout = readtimeout
- http.start {|http|
- begin
+ begin
+ http.start {|http|
resp = http.get(query)
if resp.code == "200"
return resp.body
end
- rescue => e
- # cheesy for now
- $stderr.puts "Utils.http_get exception: #{e}, while trying to get #{uristr}"
- return nil
- end
- }
+ }
+ rescue => e
+ # cheesy for now
+ $stderr.puts "Utils.http_get exception: #{e}, while trying to get #{uristr}"
+ return nil
+ end
end
# This is nasty-ass. I hate writing parsers.