Anpassungen Anwendungspasswort web.de
This commit is contained in:
parent
ad82226d8d
commit
49cd480692
1 changed files with 21 additions and 0 deletions
|
|
@ -2,6 +2,7 @@ from imap_tools import MailBox
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import json
|
import json
|
||||||
|
import telebot
|
||||||
|
|
||||||
def conf():
|
def conf():
|
||||||
appname = os.path.basename(sys.argv[0])
|
appname = os.path.basename(sys.argv[0])
|
||||||
|
|
@ -38,4 +39,24 @@ def conf():
|
||||||
passw = conf()
|
passw = conf()
|
||||||
telegram_chat_id = passw['Telegram']['Chat_ID']
|
telegram_chat_id = passw['Telegram']['Chat_ID']
|
||||||
telegram_token = passw['Telegram']['TOKEN']
|
telegram_token = passw['Telegram']['TOKEN']
|
||||||
|
tb = telebot.TeleBot(telegram_token)
|
||||||
|
|
||||||
|
host = passw['mail']['mail_host']
|
||||||
|
username = passw['mail']['mail_user']
|
||||||
|
password = passw['mail']['mail_pass']
|
||||||
|
folder = passw['mail']['mail_folder']
|
||||||
|
|
||||||
|
with MailBox(host).login(username, password, folder) as mailbox:
|
||||||
|
anzahl = len(mailbox.numbers(criteria='UNSEEN'))
|
||||||
|
ankuendigung = 'Heute befinden sich ' + str(anzahl) + ' Sendungen auf dem Weg in die Hintergasse.'
|
||||||
|
tb.send_message(telegram_chat_id, ankuendigung)
|
||||||
|
for msg in mailbox.fetch(mark_seen=True,criteria='UNSEEN' ): #criteria='UNSEEN'
|
||||||
|
for att in msg.attachments:
|
||||||
|
fn = att.filename
|
||||||
|
ext = (att.content_type[-3:])
|
||||||
|
fn = str(msg.uid) + fn +'.'+ ext
|
||||||
|
with open(fn, 'wb') as f:
|
||||||
|
f.write(att.payload)
|
||||||
|
document = open(fn, 'rb')
|
||||||
|
tb.send_document(telegram_chat_id, document, caption=msg.date)
|
||||||
|
os.remove(fn)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue