]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
plugin(points): strip/ignore some terms closes #34
authorMatthias Hecker <mail@apoc.cc>
Sat, 11 Apr 2020 19:25:03 +0000 (21:25 +0200)
committerMatthias Hecker <mail@apoc.cc>
Sat, 11 Apr 2020 19:25:03 +0000 (21:25 +0200)
- strip color/bold codes in terms
- ignore terms with ++/-- in them

data/rbot/plugins/points.rb

index 58f24501c096ad0dc8c74deb7991ca3249830c23..0209fabe28afc7686c2882760f3fb64c0e2a1f55 100644 (file)
@@ -109,7 +109,9 @@ class PointsPlugin < Plugin
     end
 
     ac.each do |k, v|
-      next if v == 0
+      next if v == 0 or /--|\+\+/.match(k)
+      # strip invisible formatting characters like bold or color codes
+      k = k.gsub(FormattingRx, '')
       @registry[k] += (v > 0 ? 1 : -1)
       m.reply @bot.lang.get("thanks") if k == @bot.nick && v > 0
       m.reply "#{k} now has #{@registry[k]} points!"