Compare commits
No commits in common. "e7512312adf66380ab5072809359b5ae442ceca7" and "10c19997d539e7f17a0e5f2be38747fde9a17e73" have entirely different histories.
e7512312ad
...
10c19997d5
@ -4,4 +4,4 @@ PASS_MAIL = password
|
||||
URL_MAIL = example.org
|
||||
PORT_MAIL = 993
|
||||
TOKEN = token
|
||||
URL = https://example1.org
|
||||
URL = example1.org
|
||||
|
@ -2,9 +2,8 @@
|
||||
# Bot that mirrors emails to Mastodon account
|
||||
import argparse
|
||||
import configparser
|
||||
import email
|
||||
import imaplib
|
||||
import mastodon
|
||||
from mastodon import Mastodon
|
||||
|
||||
CONFIG_PATH = "./config.ini"
|
||||
|
||||
@ -17,7 +16,7 @@ def show_version():
|
||||
print("There is NO WARRANTY, to the extent permitted by law.")
|
||||
|
||||
def publish(ctx, token, url):
|
||||
m = mastodon.Mastodon(access_token=token, api_base_url=url)
|
||||
m = Mastodon(access_token=token, api_base_url=url)
|
||||
m.toot(ctx)
|
||||
|
||||
def listen(user, passwd, url, port):
|
||||
@ -33,7 +32,7 @@ def listen(user, passwd, url, port):
|
||||
_, msg = mail.fetch(str(i), "(RFC822)")
|
||||
for resp in msg:
|
||||
if isinstance(resp, tuple):
|
||||
msg = email.message_from_bytes(resp[1])
|
||||
msg = email.messages_from_bytes(response[1])
|
||||
body = msg.get_payload(decode=True).decode()
|
||||
ctx.append(body)
|
||||
publish("".join(ctx), TOKEN, URL)
|
||||
@ -59,5 +58,3 @@ if __name__ == '__main__':
|
||||
PORT_MAIL = config.get('credentials', 'PORT_MAIL')
|
||||
TOKEN = config.get('credentials', 'TOKEN')
|
||||
URL = config.get('credentials', 'URL')
|
||||
|
||||
listen(USER_MAIL, PASS_MAIL, URL_MAIL, PORT_MAIL)
|
||||
|
Loading…
Reference in New Issue
Block a user