From: Giuseppe Bilotta Date: Mon, 7 Jun 2021 15:31:21 +0000 (+0200) Subject: webhook: define number for watch/star actions too X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=464e8afad5d3c72378b680f4579773adbd089f8f;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git 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. --- 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