summaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-08-01 01:10:02 +0200
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-08-01 01:10:02 +0200
commit750ec27187e0b528e315657d020b68ba1bde8d90 (patch)
tree53a69bc0eb6363a08af2870803e4c690615acb1e /data
parent9ee2da224ddbb17059dd9ca2bedf7d4098cb8755 (diff)
quotes plugin: lastquote command
Diffstat (limited to 'data')
-rw-r--r--data/rbot/plugins/quotes.rb22
1 files changed, 21 insertions, 1 deletions
diff --git a/data/rbot/plugins/quotes.rb b/data/rbot/plugins/quotes.rb
index e3dc9844..50ca326c 100644
--- a/data/rbot/plugins/quotes.rb
+++ b/data/rbot/plugins/quotes.rb
@@ -56,6 +56,10 @@ class QuotePlugin < Plugin
super
end
+ def lastquote(channel)
+ @lists[channel].length-1
+ end
+
def addquote(source, channel, quote)
@lists[channel] = Array.new if(!@lists.has_key?(channel))
num = @lists[channel].length
@@ -137,8 +141,10 @@ class QuotePlugin < Plugin
_("whoquote [<channel>] <num> => show who added quote <num>. You only need to supply <channel> if you are addressing %{nick} privately") % { :nick => @bot.nick }
when "whenquote"
_("whenquote [<channel>] <num> => show when quote <num> was added. You only need to supply <channel> if you are addressing %{nick} privately") % { :nick => @bot.nick }
+ when "lastquote"
+ _("lastquote [<channel>] => show the last quote in a given channel. You only need to supply <channel> if you are addressing %{nick} privately") % { :nick => @bot.nick }
else
- _("Quote module (Quote storage and retrieval) topics: addquote, delquote, getquote, searchquote, topicquote, countquote, whoquote, whenquote") % { :nick => @bot.nick }
+ _("Quote module (Quote storage and retrieval) topics: addquote, delquote, getquote, searchquote, topicquote, countquote, whoquote, whenquote, lastquote") % { :nick => @bot.nick }
end
end
@@ -242,6 +248,19 @@ class QuotePlugin < Plugin
m.reply _("quote not found!")
end
end
+
+ def cmd_lastquote(m, p)
+ channel = p[:channel] || m.channel.to_s
+ quote, total = getquote(m.source, channel, lastquote(channel))
+ if quote
+ m.reply _("[%{num}] %{quote}") % {
+ :num => quote.num,
+ :quote => quote.quote
+ }
+ else
+ m.reply _("quote not found!")
+ end
+ end
end
plugin = QuotePlugin.new
@@ -258,6 +277,7 @@ plugin.map "whenquote :num", :action => :cmd_whenquote, :private => false, :requ
plugin.map "searchquote *reg", :action => :cmd_searchquote, :private => false, :auth_path => '!quote::view::search!'
plugin.map "countquote [*reg]", :action => :cmd_countquote, :private => false, :auth_path => '!quote::view::count!'
plugin.map "topicquote [:num]", :action => :cmd_topicquote, :private => false, :requirements => { :num => /^\d+$/ }, :auth_path => '!quote::topic!'
+plugin.map "lastquote", :action => :cmd_lastquote, :private => false, :auth_path => '!quote::view::last!'
plugin.default_auth('other::edit', false) # Prevent random people from editing other channels quote lists by default
plugin.default_auth('other::view', true) # But allow them to view them