]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
webhook: define number for watch/star actions too
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Mon, 7 Jun 2021 15:31:21 +0000 (17:31 +0200)
committerMatthias Hecker <36882671+mattzque@users.noreply.github.com>
Wed, 9 Jun 2021 11:49:34 +0000 (13:49 +0200)
When a star is added/removed, we get notified with a message
that has no number, title or link. The pseudo-sentence is also
very bare (X started/created/deleted, without an object).

Show the number of watchers and/or stars (as appropriate) to produce
a more meaningful phrase.

data/rbot/plugins/webhook.rb

index cf93d9a732678cb28ac88f8e2df048b09150eb90..502b5e9372692cefa302929ed4b28c2d249abbe2 100644 (file)
@@ -227,6 +227,13 @@ class WebHookPlugin < Plugin
     num = json[:size] || json[:commits].size rescue nil
     stream_hash[:number] = _("%{num} commits") % { :num => num } if num
 
+    case event
+    when :watch
+      stream_hash[:number] ||= 'watching ðŸ‘€%{watchers_count}' % json[:repository]
+    when :star
+      stream_hash[:number] ||= 'star â˜† %{watchers_count}' % json[:repository]
+    end
+
     debug stream_hash
 
     return input_stream.merge stream_hash