-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import json | ||
import logging | ||
import os | ||
import telegram | ||
|
||
from ...db.db_client import DBClient | ||
from ...strings import load | ||
from .utils import get_sender_username, reply | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def get_board_credentials(update: telegram.Update, tg_context): | ||
member = next((member for member in DBClient().get_all_members() if member.telegram == f"@{get_sender_username(update)}"), None) | ||
if member is None or not member.trello: | ||
reply(load('get_board_credentials_handler__not_found'), update) | ||
return | ||
try: | ||
with open('board_credentials.json', encoding="utf-8") as fin: | ||
try: | ||
board_json = json.loads(fin.read()) | ||
creds = next((cred for cred in board_json if cred["trelloUsername"] == f"@{member.trello}"), None) | ||
if not creds: | ||
reply(load('get_board_credentials_handler__not_found'), update) | ||
return | ||
reply(load('get_board_credentials_handler__found', username=creds["focalboardUsername"], password=creds["focalboardPassword"]), update) | ||
except json.JSONDecodeError as e: | ||
logger.error(e) | ||
except IOError: | ||
logger.warning(f"Board passwords file not found", exc_info=e) |