summaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
authorMatthias Hecker <mail@apoc.cc>2020-04-06 21:08:55 +0200
committerMatthias Hecker <mail@apoc.cc>2020-04-06 21:08:55 +0200
commit07a397f63f0c7dc7f53830a57ce9048cfd9efb53 (patch)
treeb5fca98ca966fafcc8017f276bd2524af2e889c3 /data
parent618df277b7cb7d160ba5c86d1a22298a4741ed5f (diff)
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"
Diffstat (limited to 'data')
-rw-r--r--data/rbot/plugins/points.rb8
1 files changed, 6 insertions, 2 deletions
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