From cdf59c2820a284e4f9994258c52a19a41445ddca Mon Sep 17 00:00:00 2001 From: Tim van der Staaij Date: Sat, 12 Nov 2016 23:30:58 +0100 Subject: [PATCH] Handle chat_add_user_link service message in plaintext, pisg and html formatters (#50) Also fixes a bug in the pisg formatter where the incorrect user ID was extracted from an chat_add_user message. --- formatters/html.rb | 2 ++ formatters/pisg.rb | 2 ++ formatters/plaintext.rb | 2 ++ 3 files changed, 6 insertions(+) diff --git a/formatters/html.rb b/formatters/html.rb index 157595e..984de3b 100644 --- a/formatters/html.rb +++ b/formatters/html.rb @@ -154,6 +154,8 @@ def format_dialog(dialog, messages) else text += "added %s" % CGI::escapeHTML(get_full_name(msg['action']['user'])) end + elsif msg['action']['type'] == 'chat_add_user_link' + text += "joined with an invite link" elsif msg['action']['type'] == 'chat_rename' text += "changed group name to «%s»" % CGI::escapeHTML(msg['action']['title']) elsif msg['action']['type'] == 'chat_change_photo' diff --git a/formatters/pisg.rb b/formatters/pisg.rb index ceb7afc..f309fd6 100644 --- a/formatters/pisg.rb +++ b/formatters/pisg.rb @@ -63,6 +63,8 @@ def dump_message_line(message, message_line, output_stream) target_ref = target ? 'u' + target['id'].to_s : '' case message['action']['type'].downcase when 'chat_add_user' + "*** Joins: #{target_ref} (tg@#{target_ref}.users.telegram)" + when 'chat_add_user_link' "*** Joins: #{user_ref} (tg@#{user_ref}.users.telegram)" when 'chat_del_user' return if target['print_name'].to_s == '' diff --git a/formatters/plaintext.rb b/formatters/plaintext.rb index 54a6c5d..d102261 100644 --- a/formatters/plaintext.rb +++ b/formatters/plaintext.rb @@ -59,6 +59,8 @@ def format_message(dialog, message, output_stream) else "#{from_name} added #{user_name}" end + when 'chat_add_user_link' + "#{from_name} joined with an invite link" when 'chat_del_user' if message['from']['peer_id'] == user['peer_id'] || !message['from']['peer_id']