diff options
Diffstat (limited to 'bot.py')
-rw-r--r-- | bot.py | 18 |
1 files changed, 2 insertions, 16 deletions
@@ -1,9 +1,8 @@ import logging import os -from utils.mail import EmailClient +from utils.client import EmailClient from telegram import ParseMode -from telegram.constants import MAX_MESSAGE_LENGTH from telegram.ext import (Updater, CommandHandler) @@ -49,22 +48,9 @@ def get_email(bot, update, args): index = args[0] with EmailClient(email_addr, email_passwd) as client: mail = client.get_mail_by_index(index) - subject = "*Subject*: %s\n" % mail.subject - sender = "*From*: %s - %s\n" % (mail.from_nickname, mail.from_account) - date = "*Date*: %s\n" % mail.receivedtime bot.send_message(update.message.chat_id, parse_mode=ParseMode.MARKDOWN, - text=subject+sender+date) - if len(mail.text_content) > MAX_MESSAGE_LENGTH: - text = mail.text_content[0:4096] - bot.send_message(update.message.chat_id, - text=text) - mail.text_content = mail.text_content.lstrip(text) - if mail.text_content: - bot.send_message(update.message.chat_id, - text=mail.text_content) - - + text=mail) def main(): # Create the EventHandler and pass it your bot's token. |