flock: Pass recipient's name as first argument in get_recipient_id method.

This commit is contained in:
novokrest 2018-06-08 22:11:20 +03:00 committed by showell
parent 5c46a4e68e
commit d24e4fc5c8

View file

@ -19,10 +19,8 @@ def find_recipient(res: str, to: str) -> str:
return obj['id']
# Returns User's ID, if not found, returns error message.
def get_recipient_id(content: str, config: Dict[str, str]) -> str:
def get_recipient_id(recipient_name: str, config: Dict[str, str]) -> str:
token = config['token']
content_pieces = content.split(':')
to = content_pieces[0].strip()
payload = {
'token': token
}
@ -35,11 +33,11 @@ def get_recipient_id(content: str, config: Dict[str, str]) -> str:
right now.\nPlease try again later"
res = res.json()
to = find_recipient(res, to)
if to is None:
recipient_id = find_recipient(res, recipient_name)
if recipient_id is None:
return "No user found. Make sure you typed it correctly."
else:
return to
return recipient_id
# This handles the message sending work.
def get_flock_response(content: str, config: Dict[str, str]) -> str:
@ -48,7 +46,7 @@ def get_flock_response(content: str, config: Dict[str, str]) -> str:
recipient_name = content_pieces[0].strip()
message = content_pieces[1].strip()
recipient_id = get_recipient_id(content, config)
recipient_id = get_recipient_id(recipient_name, config)
if len(str(recipient_id)) > 30:
return recipient_id