summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2021-06-07 17:31:21 +0200
committerMatthias Hecker <36882671+mattzque@users.noreply.github.com>2021-06-09 13:49:34 +0200
commit464e8afad5d3c72378b680f4579773adbd089f8f (patch)
treef23240920e4b4a313b36245d704ca1e390556b26
parente01699c5284bdb45f88ee6335dc90f25f4932b66 (diff)
webhook: define number for watch/star actions too
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.
-rw-r--r--data/rbot/plugins/webhook.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/data/rbot/plugins/webhook.rb b/data/rbot/plugins/webhook.rb
index cf93d9a7..502b5e93 100644
--- a/data/rbot/plugins/webhook.rb
+++ b/data/rbot/plugins/webhook.rb
@@ -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