Skip to content

Commit

Permalink
Handle chat_add_user_link service message in plaintext, pisg and html…
Browse files Browse the repository at this point in the history
… formatters (#50)

Also fixes a bug in the pisg formatter where the incorrect user ID was extracted from an chat_add_user message.
  • Loading branch information
tvdstaaij committed Nov 12, 2016
1 parent de5ca3f commit cdf59c2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions formatters/html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 2 additions & 0 deletions formatters/pisg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 == ''
Expand Down
2 changes: 2 additions & 0 deletions formatters/plaintext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down

0 comments on commit cdf59c2

Please sign in to comment.