flock: Pass recipient's name as first argument in get_recipient_id
method.
This commit is contained in:
parent
5c46a4e68e
commit
d24e4fc5c8
|
@ -19,10 +19,8 @@ def find_recipient(res: str, to: str) -> str:
|
||||||
return obj['id']
|
return obj['id']
|
||||||
|
|
||||||
# Returns User's ID, if not found, returns error message.
|
# 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']
|
token = config['token']
|
||||||
content_pieces = content.split(':')
|
|
||||||
to = content_pieces[0].strip()
|
|
||||||
payload = {
|
payload = {
|
||||||
'token': token
|
'token': token
|
||||||
}
|
}
|
||||||
|
@ -35,11 +33,11 @@ def get_recipient_id(content: str, config: Dict[str, str]) -> str:
|
||||||
right now.\nPlease try again later"
|
right now.\nPlease try again later"
|
||||||
|
|
||||||
res = res.json()
|
res = res.json()
|
||||||
to = find_recipient(res, to)
|
recipient_id = find_recipient(res, recipient_name)
|
||||||
if to is None:
|
if recipient_id is None:
|
||||||
return "No user found. Make sure you typed it correctly."
|
return "No user found. Make sure you typed it correctly."
|
||||||
else:
|
else:
|
||||||
return to
|
return recipient_id
|
||||||
|
|
||||||
# This handles the message sending work.
|
# This handles the message sending work.
|
||||||
def get_flock_response(content: str, config: Dict[str, str]) -> str:
|
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()
|
recipient_name = content_pieces[0].strip()
|
||||||
message = content_pieces[1].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:
|
if len(str(recipient_id)) > 30:
|
||||||
return recipient_id
|
return recipient_id
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue