diff options
author | hyfc <[email protected]> | 2018-07-21 12:16:49 +0800 |
---|---|---|
committer | hyfc <[email protected]> | 2020-10-22 11:37:50 +0800 |
commit | b8313d83e8c5c0a86a17710a0356102aab01eb27 (patch) | |
tree | c225e4ee10e8a6e4aec25b80ac16dfeaae5c253e | |
parent | 594b88b8dca478541dc783dc5f4f829fec73dc83 (diff) | |
download | telegram-mail-bot-b8313d83e8c5c0a86a17710a0356102aab01eb27.tar.gz telegram-mail-bot-b8313d83e8c5c0a86a17710a0356102aab01eb27.tar.bz2 telegram-mail-bot-b8313d83e8c5c0a86a17710a0356102aab01eb27.zip |
add some useful info logs
-rw-r--r-- | bot.py | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -7,7 +7,7 @@ from utils.client import EmailClient logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s:%(lineno)d' - ' - %(message)s', filename='mailbot.log', + ' - %(message)s', filename='/var/log/mailbot.log', level=logging.INFO) logger = logging.getLogger(__name__) @@ -43,10 +43,11 @@ def setting_email(bot, update, args, job_queue): global email_addr, email_passwd, inbox_num email_addr = args[0] email_passwd = args[1] - + logger.info("received setting_email command.") update.message.reply_text("Configure email success!") with EmailClient(email_addr, email_passwd) as client: inbox_num = client.get_mails_count() + logger.info("periodic task scheduled.") job_queue.run_repeating(periodic_task, 600) @@ -58,6 +59,7 @@ def periodic_task(bot, update): get_email(bot, update, new_inbox_num) def inbox(bot, update): + logger.info("received inbox command.") with EmailClient(email_addr, email_passwd) as client: inbox_num = client.get_mails_count() reply_text = "The index of newest mail is *%d*" % inbox_num @@ -67,6 +69,7 @@ def inbox(bot, update): def get_email(bot, update, args): index = args[0] + logger.info("received get command.") with EmailClient(email_addr, email_passwd) as client: mail = client.get_mail_by_index(index) content = mail.__repr__() |