From 07a397f63f0c7dc7f53830a57ce9048cfd9efb53 Mon Sep 17 00:00:00 2001 From: Matthias Hecker Date: Mon, 6 Apr 2020 21:08:55 +0200 Subject: plugin(points): +/- must come after, closes #34 This modifies the karma/points plugin to ignore increment/ decrement suffixes. `--SOMETHING` is more trouble than its worth, people will write --NAME as a signature, or paste a command line argument, e.g. `ls --sort time` which causes issues. I also added tests for the points plugin, the plan is to make the plugin testing easier more "rubionic" --- data/rbot/plugins/points.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'data') diff --git a/data/rbot/plugins/points.rb b/data/rbot/plugins/points.rb index 21157f3d..58f24501 100644 --- a/data/rbot/plugins/points.rb +++ b/data/rbot/plugins/points.rb @@ -78,13 +78,17 @@ class PointsPlugin < Plugin op = nil ac = Hash.new m.message.split.each_with_index do |tok, i| + # ignore preceeding +/- + if op && arg.nil? + op = nil + end tok.sub!(/[:,]$/, '') if i == 0 catch :me_if_you_can do if m.channel.users[tok].nil? - if (tok =~ /^(?:--)(.*[^-].*)$/) || (tok =~ /^(.*[^-].*)(?:--)$/) + if tok =~ /^(.*[^-].*)(?:--)$/ op, arg = '--', $1 next - elsif (tok =~ /^(?:\+\+)(.*[^+].*)$/)||(tok =~ /^(.*[^+].*)(?:\+\+)$/) + elsif tok =~ /^(.*[^+].*)(?:\+\+)$/ op, arg = '++', $1 next end -- cgit v1.2.3