summaryrefslogtreecommitdiff
path: root/rbot
diff options
context:
space:
mode:
authorTom Gilbert <tom@linuxbrit.co.uk>2005-07-16 01:18:13 +0000
committerTom Gilbert <tom@linuxbrit.co.uk>2005-07-16 01:18:13 +0000
commita08b4def5c276df964ae2a8d9c3f661593d757e6 (patch)
treecd563b11ab095bd364036d14bc28fb5fb4c065a8 /rbot
parent71e16adb8a62a78fc1e8cdcc6776b6cd84fbe758 (diff)
various fixes by me, plus most of Rene's patch (#1).
Diffstat (limited to 'rbot')
-rw-r--r--rbot/channel.rb4
-rw-r--r--rbot/ircbot.rb9
-rw-r--r--rbot/languages/english.lang6
-rw-r--r--rbot/plugins/autorejoin.rb6
-rw-r--r--rbot/plugins/fortune.rb9
-rw-r--r--rbot/plugins/host.rb2
-rw-r--r--rbot/plugins/nslookup.rb2
-rw-r--r--rbot/plugins/quotes.rb4
-rw-r--r--rbot/plugins/spell.rb2
-rw-r--r--rbot/registry.rb20
10 files changed, 42 insertions, 22 deletions
diff --git a/rbot/channel.rb b/rbot/channel.rb
index 0db4c106..edd206bf 100644
--- a/rbot/channel.rb
+++ b/rbot/channel.rb
@@ -39,6 +39,10 @@ module Irc
# topic set by
attr_accessor :by
+ def initialize
+ @name = ""
+ end
+
# when called like "puts @bots.channels[chan].topic"
def to_s
@name
diff --git a/rbot/ircbot.rb b/rbot/ircbot.rb
index 5c72e40b..823a66a6 100644
--- a/rbot/ircbot.rb
+++ b/rbot/ircbot.rb
@@ -236,7 +236,7 @@ class IrcBot
end
@channels[channel].users.clear
users.each {|u|
- @channels[channel].users[u[0]] = ["mode", u[1]]
+ @channels[channel].users[u[0].sub(/^[@&~+]/, '')] = ["mode", u[1]]
}
}
@client["UNKNOWN"] = proc {|data|
@@ -432,6 +432,11 @@ class IrcBot
def nickchg(name)
sendq "NICK #{name}"
end
+
+ # changing mode
+ def mode(channel, mode, target)
+ sendq "MODE #{channel} #{mode} #{target}"
+ end
# m:: message asking for help
# topic:: optional topic help is requested for
@@ -556,6 +561,8 @@ class IrcBot
action $1, $2 if(@auth.allow?("say", m.source, m.replyto))
when (/^topic\s+(\S+)\s+(.*)$/i)
topic $1, $2 if(@auth.allow?("topic", m.source, m.replyto))
+ when (/^mode\s+(\S+)\s+(\S+)\s+(.*)$/i)
+ mode $1, $2, $3 if(@auth.allow?("mode", m.source, m.replyto))
when (/^ping$/i)
say m.replyto, "pong"
when (/^rescan$/i)
diff --git a/rbot/languages/english.lang b/rbot/languages/english.lang
index 58427a42..f275d82f 100644
--- a/rbot/languages/english.lang
+++ b/rbot/languages/english.lang
@@ -1,6 +1,7 @@
okay:
okay
okay then :)
+ okies!
fine
done
can do!
@@ -13,14 +14,16 @@ dunno:
beats me
no idea
no clue
+ ...eh?
*shrug*
don't ask me
who knows?
I can't do that Dave.
- you best check yo'self
+ you best check yo'self!
dunno_about_X:
but I dunno anything about %s
I never heard of %s :(
+ %s? what's that then?
but what's %s?
insult:
%s: wanker!
@@ -28,6 +31,7 @@ insult:
%s: I hate you :(
%s: die!
%s: I'm offended!
+ %s: you hurt my feelings
hello:
hello :)
hola :)
diff --git a/rbot/plugins/autorejoin.rb b/rbot/plugins/autorejoin.rb
index 03118f85..b5dd1ee1 100644
--- a/rbot/plugins/autorejoin.rb
+++ b/rbot/plugins/autorejoin.rb
@@ -4,8 +4,10 @@ class AutoRejoinPlugin < Plugin
end
def kick(m)
if m.address?
- @bot.join m.channel
- @bot.say m.channel, @bot.lang.get("insult") % m.sourcenick
+ @bot.timer.add_onceu(10, m) {|m|
+ @bot.join m.channel
+ @bot.say m.channel, @bot.lang.get("insult") % m.sourcenick
+ }
end
end
end
diff --git a/rbot/plugins/fortune.rb b/rbot/plugins/fortune.rb
index 2f76a318..fd90f69b 100644
--- a/rbot/plugins/fortune.rb
+++ b/rbot/plugins/fortune.rb
@@ -15,8 +15,13 @@ class FortunePlugin < Plugin
m.reply "incorrect usage: " + help(m.plugin)
return
end
- ret = Utils.safe_exec("/usr/games/fortune", "-n", "255", "-s", db)
- m.reply ret.split("\n").join(" ")
+ fortune = nil
+ ["/usr/games/fortune", "/usr/bin/fortune", "/usr/local/bin/fortune"].each {|f|
+ fortune = f if FileTest.executable? f
+ }
+ m.reply "fortune not found" unless fortune
+ ret = Utils.safe_exec(fortune, "-n", "255", "-s", db)
+ m.reply ret.gsub(/\t/, " ").split(/\n/).join(" ")
return
end
end
diff --git a/rbot/plugins/host.rb b/rbot/plugins/host.rb
index cb88eee7..ef8dc8bc 100644
--- a/rbot/plugins/host.rb
+++ b/rbot/plugins/host.rb
@@ -3,7 +3,7 @@ class HostPlugin < Plugin
"host <domain> => query nameserver about domain names and zones for <domain>"
end
def privmsg(m)
- unless(m.params =~ /^(\w|\.)+$/)
+ unless(m.params =~ /^(\w|-|\.)+$/)
m.reply "incorrect usage: " + help(m.plugin)
return
end
diff --git a/rbot/plugins/nslookup.rb b/rbot/plugins/nslookup.rb
index a68f0ee8..92da1ba7 100644
--- a/rbot/plugins/nslookup.rb
+++ b/rbot/plugins/nslookup.rb
@@ -38,7 +38,7 @@ class DnsPlugin < Plugin
rescue StandardError => err
m.reply "#{m.params}: not found"
end
- elsif(m.params =~ /^(\w|\.)+$/)
+ elsif(m.params =~ /^\S+$/)
begin
a = getaddresses(m.params)
m.reply m.params + ": " + a.join(", ")
diff --git a/rbot/plugins/quotes.rb b/rbot/plugins/quotes.rb
index 072e352a..0e46b495 100644
--- a/rbot/plugins/quotes.rb
+++ b/rbot/plugins/quotes.rb
@@ -64,7 +64,7 @@ class QuotePlugin < Plugin
return 0 unless(@lists.has_key?(channel))
return 0 unless(@lists[channel].length > 0)
if(regexp)
- matches = @lists[channel].compact.find_all {|a| a.quote =~ /#{regexp}/ }
+ matches = @lists[channel].compact.find_all {|a| a.quote =~ /#{regexp}/i }
else
matches = @lists[channel].compact
end
@@ -73,7 +73,7 @@ class QuotePlugin < Plugin
def searchquote(source, channel, regexp)
return nil unless(@lists.has_key?(channel))
return nil unless(@lists[channel].length > 0)
- matches = @lists[channel].compact.find_all {|a| a.quote =~ /#{regexp}/ }
+ matches = @lists[channel].compact.find_all {|a| a.quote =~ /#{regexp}/i }
if(matches.length > 0)
return matches[rand(matches.length)], @lists[channel].length - 1
else
diff --git a/rbot/plugins/spell.rb b/rbot/plugins/spell.rb
index eb80a48d..81ee1ac6 100644
--- a/rbot/plugins/spell.rb
+++ b/rbot/plugins/spell.rb
@@ -3,7 +3,7 @@ class SpellPlugin < Plugin
"spell <word> => check spelling of <word>, suggest alternatives"
end
def privmsg(m)
- unless(m.params && m.params =~ /^\w+$/)
+ unless(m.params && m.params =~ /^\S+$/)
m.reply "incorrect usage: " + help(m.plugin)
return
end
diff --git a/rbot/registry.rb b/rbot/registry.rb
index 751ec9a6..cd78dcbf 100644
--- a/rbot/registry.rb
+++ b/rbot/registry.rb
@@ -207,13 +207,13 @@ module Irc
# just like Hash#has_value?
def has_value?(value)
- return @registry.has_value(store(value))
+ return @registry.has_value?(store(value))
end
# just like Hash#index?
def index(value)
ind = @registry.index(store(value))
- if ind.gsub!(/^#{Regexp.escape(@prefix)}/, "")
+ if ind && ind.gsub!(/^#{Regexp.escape(@prefix)}/, "")
return ind
else
return nil
@@ -228,12 +228,12 @@ module Irc
# returns a list of your keys
def keys
return @registry.keys.collect {|key|
- if key.gsub!(/^#{Regexp.escape(@prefix)}/, "")
- key
- else
- nil
- end
- }.compact
+ if key.gsub!(/^#{Regexp.escape(@prefix)}/, "")
+ key
+ else
+ nil
+ end
+ }.compact
end
# Return an array of all associations [key, value] in your namespace
@@ -272,9 +272,7 @@ module Irc
def values
ret = Array.new
self.each {|k,v|
- if key =~ /^#{Regexp.escape(@prefix)}/
- Array << restore(v)
- end
+ ret << restore(v)
}
return ret
end