Compare commits

..

No commits in common. "6eaa6a19d5409a6ace8b12eb1063c532d8328707" and "1c1c9acc8d510afa91b9ef9c74e0ad19efcd0349" have entirely different histories.

2 changed files with 0 additions and 66 deletions

View File

@ -1,7 +0,0 @@
[credentials]
USER_MAIL = username
PASS_MAIL = password
URL_MAIL = example.org
PORT_MAIL = 993
TOKEN = token
URL = example1.org

View File

@ -1,59 +0,0 @@
#!/usr/bin/env python3
# Bot that mirrors emails to Mastodon account
import argparse
import configparser
import imaplib
from mastodon import Mastodon
CONFIG_PATH = "./config.ini"
VERSION = '0.1.0'
def show_version():
print("EmailMastodon " + VERSION)
print("License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>")
print("This is free software: you are free to change and redistribute it.")
print("There is NO WARRANTY, to the extent permitted by law.")
def publish(ctx, token, url):
pass
def listen(user, passwd, url, port):
mail = imaplib.IMAP4_SSL(url, port=port)
mail.login(user, passwd)
_, messages = mail.select()
past_messages = int(messages[0].decode())
while True:
ctx = []
_, messages = mail.select()
if past_messages != int(messages[0].decode()):
for i in range(past_messages+1, int(messages[0].decode())+1):
_, msg = mail.fetch(str(i), "(RFC822)")
for resp in msg:
if isinstance(resp, tuple):
msg = email.messages_from_bytes(response[1])
body = msg.get_payload(decode=True).decode()
ctx.append(body)
publish("".join(ctx), TOKEN, URL)
past_messages = int(messages[0].decode())
else:
continue
if __name__ == '__main__':
argparser = argparse.ArgumentParser(description="Bot that mirrors emails to Mastodon account")
argparser.add_argument("--version", dest="version", help="print version information and exit", action="store_true")
args = argparser.parse_args()
if args.version:
show_version()
exit()
config = configparser.ConfigParser()
config.read(CONFIG_PATH)
USER_MAIL = config.get('credentials', 'USER_MAIL')
PASS_MAIL = config.get('credentials', 'PASS_MAIL')
URL_MAIL = config.get('credentials', 'URL_MAIL')
PORT_MAIL = config.get('credentials', 'PORT_MAIL')
TOKEN = config.get('credentials', 'TOKEN')
URL = config.get('credentials', 'URL')