Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
bots: Use user 'id' instead of 'name' in is_private function.
Names are not guaranteed to be unique, user ids should
be used when comparing if the sender and receiver are the same.
  • Loading branch information
abhijeetkaur committed Aug 18, 2017
commit 26654973e5362ba54940ce62fd74c8a3a74303c4
5 changes: 3 additions & 2 deletions zulip_bots/zulip_bots/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def __init__(self, client, root_dir):
self._client = client
self._root_dir = root_dir
try:
self.user_id = user_profile['user_id']
self.full_name = user_profile['full_name']
self.email = user_profile['email']
except KeyError:
Expand Down Expand Up @@ -176,10 +177,10 @@ def extract_query_without_mention(message, client):

def is_private(message, client):
# type: (Dict[str, Any], ExternalBotHandler) -> bool
# bot will not reply if the sender name is the same as the bot name
# bot will not reply if the sender id is the same as the bot id
# to prevent infinite loop
if message['type'] == 'private':
return client.full_name != message['sender_full_name']
return client.user_id != message['sender_id']
return False

def run_message_handler_for_bot(lib_module, quiet, config_file, bot_name):
Expand Down