diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-09-20 15:10:08 +0000 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-09-20 15:10:08 +0000 |
commit | 8b7e8b461cf7c8ee3d88499a8fa72ce7bb2becce (patch) | |
tree | 44a67a001f424e6daf81e491c247827365dd30d7 /data | |
parent | 5acaaf04bfc0bc5386cf3f2aa5c07b34837dcb7c (diff) |
reaction plugin: allow moving replies from one trigger to another
Diffstat (limited to 'data')
-rw-r--r-- | data/rbot/plugins/reaction.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/data/rbot/plugins/reaction.rb b/data/rbot/plugins/reaction.rb index ef2e85da..a61be294 100644 --- a/data/rbot/plugins/reaction.rb +++ b/data/rbot/plugins/reaction.rb @@ -136,11 +136,16 @@ end class ReactionPlugin < Plugin ADD_SYNTAX = 'react to *trigger with *reply [at :chance chance]' + MOVE_SYNTAX = 'reaction move *source to *dest' def add_syntax return ADD_SYNTAX end + def move_syntax + return MOVE_SYNTAX + end + attr :reactions def initialize @@ -264,6 +269,22 @@ class ReactionPlugin < Plugin m.reply "I'll react to #{reaction.raw_trigger} with #{reaction.raw_replies.last} (#{(reaction.replies.last.pct * 100).to_i}%)" end + def handle_move(m, params) + source = params[:source].to_s + dest = params[:dest].to_s + found = find_reaction(source) + if not found + m.reply "I don't react to #{source}" + return + end + if find_reaction(dest) + m.reply "I already react to #{dest}, so I won't move #{source} to #{dest}" + return + end + found.trigger=dest + m.reply "Ok, I'll react to #{found.raw_trigger} now" + end + def handle_rm(m, params) trigger = params[:trigger].to_s debug trigger.inspect @@ -328,6 +349,17 @@ plugin.map 'reaction list [:page]', :action => 'handle_list', plugin.map 'reaction show *trigger', :action => 'handle_show' +plugin.map plugin.move_syntax, :action => 'handle_move', + :requirements => { :source => /^(?:act:)?!.*?!/ } +plugin.map plugin.move_syntax, :action => 'handle_move', + :requirements => { :source => /^(?:act:)?\/.*?\// } +plugin.map plugin.move_syntax, :action => 'handle_move', + :requirements => { :source => /^(?:act:)?".*?"/ } +plugin.map plugin.move_syntax, :action => 'handle_move', + :requirements => { :source => /^(?:act:)?'.*?'/ } +plugin.map plugin.move_syntax.sub('*', ':'), :action => 'handle_move' + + plugin.map 'reaction del[ete] *trigger', :action => 'handle_rm' plugin.map 'reaction delete *trigger', :action => 'handle_rm' plugin.map 'reaction remove *trigger', :action => 'handle_rm' |