summaryrefslogtreecommitdiff
path: root/rbot/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'rbot/plugins')
-rw-r--r--rbot/plugins/autoop.rb4
-rw-r--r--rbot/plugins/cal.rb9
-rw-r--r--rbot/plugins/eightball.rb5
-rw-r--r--rbot/plugins/karma.rb93
-rw-r--r--rbot/plugins/lart.rb8
-rw-r--r--rbot/plugins/nickserv.rb10
-rw-r--r--rbot/plugins/opmeh.rb1
-rw-r--r--rbot/plugins/quotes.rb4
-rw-r--r--rbot/plugins/remind.rb2
-rw-r--r--rbot/plugins/roulette.rb2
10 files changed, 70 insertions, 68 deletions
diff --git a/rbot/plugins/autoop.rb b/rbot/plugins/autoop.rb
index 094ee343..fdbcf6e0 100644
--- a/rbot/plugins/autoop.rb
+++ b/rbot/plugins/autoop.rb
@@ -38,7 +38,7 @@ class AutoOP < Plugin
@registry[ma[1]] = channels.split(/,\s*/).collect { |x|
x.strip
}
- @bot.okay m.replyto
+ m.okay
else
m.reply @bot.lang.get('dunno')
end
@@ -48,7 +48,7 @@ class AutoOP < Plugin
if(!@registry.delete(params))
m.reply @bot.lang.get('dunno')
else
- @bot.okay m.replyto
+ m.okay
end
end
diff --git a/rbot/plugins/cal.rb b/rbot/plugins/cal.rb
index 1e823194..4f28310b 100644
--- a/rbot/plugins/cal.rb
+++ b/rbot/plugins/cal.rb
@@ -2,13 +2,14 @@ class CalPlugin < Plugin
def help(plugin, topic="")
"cal [options] => show current calendar [unix cal options]"
end
- def privmsg(m)
- if m.params && m.params.length > 0
- m.reply Utils.safe_exec("cal", m.params)
+ def cal(m, params)
+ if params.has_key?(:month)
+ m.reply Utils.safe_exec("cal", params[:month], params[:year])
else
m.reply Utils.safe_exec("cal")
end
end
end
plugin = CalPlugin.new
-plugin.register("cal")
+plugin.map 'cal :month :year', :requirements => {:month => /^\d+$/, :year => /^\d+$/}
+plugin.map 'cal'
diff --git a/rbot/plugins/eightball.rb b/rbot/plugins/eightball.rb
index 6d123b34..64748490 100644
--- a/rbot/plugins/eightball.rb
+++ b/rbot/plugins/eightball.rb
@@ -8,11 +8,12 @@ class EightBallPlugin < Plugin
def help(plugin, topic="")
"magic 8-ball ruby bot module written by novex for nvinfo on #dumber@quakenet, usage:<botname> 8ball will i ever beat this cancer?"
end
- def privmsg(m)
+ def eightball(m, params)
answers = @answers[rand(@answers.length)]
action = "shakes the magic 8-ball... #{answers}"
@bot.action m.replyto, action
end
end
plugin = EightBallPlugin.new
-plugin.register("8ball")
+plugin.map '8ball', :action => 'usage'
+plugin.map '8ball *params', :action => 'eightball'
diff --git a/rbot/plugins/karma.rb b/rbot/plugins/karma.rb
index 1bed175a..148427a5 100644
--- a/rbot/plugins/karma.rb
+++ b/rbot/plugins/karma.rb
@@ -27,60 +27,59 @@ class KarmaPlugin < Plugin
end
end
+
+ def stats(m, params)
+ if (@registry.length)
+ max = @registry.values.max
+ min = @registry.values.min
+ best = @registry.to_hash.index(max)
+ worst = @registry.to_hash.index(min)
+ m.reply "#{@registry.length} items. Best: #{best} (#{max}); Worst: #{worst} (#{min})"
+ end
+ end
+
+ def karma(m, params)
+ thing = params[:key]
+ thing = m.sourcenick unless thing
+ thing = thing.to_s
+ karma = @registry[thing]
+ if(karma != 0)
+ m.reply "karma for #{thing}: #{@registry[thing]}"
+ else
+ m.reply "#{thing} has neutral karma"
+ end
+ end
+
+
def help(plugin, topic="")
- "karma module: <thing>++/<thing>-- => increase/decrease karma for <thing>, karma for <thing>? => show karma for <thing>. Karma is a community rating system - only in-channel messages can affect karma and you cannot adjust your own."
+ "karma module: <thing>++/<thing>-- => increase/decrease karma for <thing>, karma for <thing>? => show karma for <thing>, karmastats => show stats. Karma is a community rating system - only in-channel messages can affect karma and you cannot adjust your own."
end
def listen(m)
- if(m.kind_of?(PrivMessage) && m.public?)
- # in channel message, the kind we are interested in
- if(m.message =~ /(\+\+|--)/)
- string = m.message.sub(/\W(--|\+\+)(\(.*?\)|[^(++)(\-\-)\s]+)/, "\2\1")
- seen = Hash.new
- while(string.sub!(/(\(.*?\)|[^(++)(\-\-)\s]+)(\+\+|--)/, ""))
- key = $1
- change = $2
- next if seen[key]
- seen[key] = true
+ return unless m.kind_of?(PrivMessage) && m.public?
+ # in channel message, the kind we are interested in
+ if(m.message =~ /(\+\+|--)/)
+ string = m.message.sub(/\W(--|\+\+)(\(.*?\)|[^(++)(\-\-)\s]+)/, "\2\1")
+ seen = Hash.new
+ while(string.sub!(/(\(.*?\)|[^(++)(\-\-)\s]+)(\+\+|--)/, ""))
+ key = $1
+ change = $2
+ next if seen[key]
+ seen[key] = true
- key.sub!(/^\((.*)\)$/, "\1")
- key.gsub!(/\s+/, " ")
- next unless(key.length > 0)
- next if(key == m.sourcenick)
- if(change == "++")
- @registry[key] += 1
- elsif(change == "--")
- @registry[key] -= 1
- end
+ key.sub!(/^\((.*)\)$/, "\1")
+ key.gsub!(/\s+/, " ")
+ next unless(key.length > 0)
+ next if(key == m.sourcenick)
+ if(change == "++")
+ @registry[key] += 1
+ elsif(change == "--")
+ @registry[key] -= 1
end
end
end
end
- def privmsg(m)
- if (m.plugin == "karmastats")
- if (@registry.length)
- max = @registry.values.max
- min = @registry.values.min
- best = @registry.to_hash.index(max)
- worst = @registry.to_hash.index(min)
- m.reply "#{@registry.length} votes. Best: #{best} (#{max}); Worst: #{worst} (#{min})"
- return
- end
- end
- unless(m.params)
- m.reply "incorrect usage: " + m.plugin
- return
- end
- if(m.params =~ /^(?:for\s+)?(\S+?)\??$/)
- thing = $1
- karma = @registry[thing]
- if(karma != 0)
- m.reply "karma for #{thing}: #{@registry[thing]}"
- else
- m.reply "#{thing} has neutral karma"
- end
- end
- end
end
plugin = KarmaPlugin.new
-plugin.register("karma")
-plugin.register("karmastats")
+plugin.map 'karmastats', :action => 'stats'
+plugin.map 'karma :key', :defaults => {:key => false}
+plugin.map 'karma for :key'
diff --git a/rbot/plugins/lart.rb b/rbot/plugins/lart.rb
index 385b17c3..1c72c648 100644
--- a/rbot/plugins/lart.rb
+++ b/rbot/plugins/lart.rb
@@ -130,25 +130,25 @@ class LartPlugin < Plugin
#{{{
def handle_addlart(m)
@larts << m.params
- @bot.okay m.replyto
+ m.okay
end
#}}}
#{{{
def handle_rmlart(m)
@larts.delete m.params
- @bot.okay m.replyto
+ m.okay
end
#}}}
#{{{
def handle_addpraise(m)
@praises << m.params
- @bot.okay m.replyto
+ m.okay
end
#}}}
#{{{
def handle_rmpraise(m)
@praises.delete m.params
- @bot.okay m.replyto
+ m.okay
end
#}}}
#}}}
diff --git a/rbot/plugins/nickserv.rb b/rbot/plugins/nickserv.rb
index 94c57e6d..1ef2baf7 100644
--- a/rbot/plugins/nickserv.rb
+++ b/rbot/plugins/nickserv.rb
@@ -38,23 +38,23 @@ class NickServPlugin < Plugin
nick = $1
passwd = $2
@registry[nick] = passwd
- @bot.okay m.replyto
+ m.okay
when (/^register$/)
passwd = genpasswd
@bot.sendmsg "PRIVMSG", "NickServ", "REGISTER " + passwd
@registry[@bot.nick] = passwd
- @bot.okay m.replyto
+ m.okay
when (/^register\s*(\S*)\s*(.*)$/)
passwd = $1
email = $2
@bot.sendmsg "PRIVMSG", "NickServ", "REGISTER " + passwd + " " + email
@registry[@bot.nick] = passwd
- @bot.okay m.replyto
+ m.okay
when (/^register\s*(.*)\s*$/)
passwd = $1
@bot.sendmsg "PRIVMSG", "NickServ", "REGISTER " + passwd
@registry[@bot.nick] = passwd
- @bot.okay m.replyto
+ m.okay
when (/^listnicks$/)
if @bot.auth.allow?("config", m.source, m.replyto)
if @registry.length > 0
@@ -68,7 +68,7 @@ class NickServPlugin < Plugin
when (/^identify$/)
if @registry.has_key?(@bot.nick)
@bot.sendmsg "PRIVMSG", "NickServ", "IDENTIFY " + @registry[@bot.nick]
- @bot.okay m.replyto
+ m.okay
else
m.reply "I dunno the nickserv password for the nickname #{@bot.nick} :("
end
diff --git a/rbot/plugins/opmeh.rb b/rbot/plugins/opmeh.rb
index eb392513..2776de60 100644
--- a/rbot/plugins/opmeh.rb
+++ b/rbot/plugins/opmeh.rb
@@ -12,6 +12,7 @@ class OpMehPlugin < Plugin
end
target = m.sourcenick
@bot.sendq("MODE #{channel} +o #{target}")
+ m.okay
end
end
plugin = OpMehPlugin.new
diff --git a/rbot/plugins/quotes.rb b/rbot/plugins/quotes.rb
index 0e46b495..674a9ed6 100644
--- a/rbot/plugins/quotes.rb
+++ b/rbot/plugins/quotes.rb
@@ -186,7 +186,7 @@ class QuotePlugin < Plugin
num = $2.to_i
if(@bot.auth.allow?("delquote", m.source, m.replyto))
if(delquote(channel, num))
- @bot.okay m.replyto
+ m.okay
else
m.reply "quote not found!"
end
@@ -288,7 +288,7 @@ class QuotePlugin < Plugin
num = $1.to_i
if(@bot.auth.allow?("delquote", m.source, m.replyto))
if(delquote(m.target, num))
- @bot.okay m.replyto
+ m.okay
else
m.reply "quote not found!"
end
diff --git a/rbot/plugins/remind.rb b/rbot/plugins/remind.rb
index 402e2d08..5ad980ae 100644
--- a/rbot/plugins/remind.rb
+++ b/rbot/plugins/remind.rb
@@ -145,7 +145,7 @@ class RemindPlugin < Plugin
m.reply "incorrect usage: " + help(m.plugin)
return
end
- @bot.okay m.replyto
+ m.okay
end
end
plugin = RemindPlugin.new
diff --git a/rbot/plugins/roulette.rb b/rbot/plugins/roulette.rb
index a3d102f3..c9d585ea 100644
--- a/rbot/plugins/roulette.rb
+++ b/rbot/plugins/roulette.rb
@@ -30,7 +30,7 @@ class RoulettePlugin < Plugin
elsif m.params == "clearstats"
if @bot.auth.allow?("config", m.source, m.replyto)
@registry.clear
- @bot.okay m.replyto
+ m.okay
end
return
elsif m.params