images support
This commit is contained in:
parent
5bcb7a6278
commit
a0fbd9f91a
2 changed files with 9 additions and 4 deletions
|
@ -25,4 +25,4 @@ https://github.com/caffeinewriter/botvenon
|
|||
|
||||
## Todo
|
||||
|
||||
1. Images support in toot
|
||||
1. User documentation
|
||||
|
|
11
megafono.py
11
megafono.py
|
@ -39,7 +39,7 @@ def megafono():
|
|||
last_id = 0
|
||||
with open(last_id_file) as f:
|
||||
last_id = int(f.read())
|
||||
with open(ANNOUNCEMENT_FILE, 'r', encoding='utf8') as a:
|
||||
with open(ANNOUNCEMENT_FILE, 'r') as a:
|
||||
toot = a.readlines()[last_id]
|
||||
with open(ANNOUNCEMENT_FILE, 'r') as a:
|
||||
length = len(a.readlines())
|
||||
|
@ -47,8 +47,13 @@ def megafono():
|
|||
last_id %= length
|
||||
with open(last_id_file, 'w+') as f:
|
||||
f.write(str(last_id))
|
||||
mastodon.status_post(toot.replace('\\n','\n'), visibility='unlisted')
|
||||
print("Sent: "+str(toot))
|
||||
|
||||
if toot.startswith('IMG='):
|
||||
msg = toot.split(' ', 1)
|
||||
img = mastodon.media_post(msg[0].split('=')[1], "image/jpeg")
|
||||
mastodon.status_post(msg[1].replace('\\n','\n'), media_ids=img['id'], visibility='unlisted')
|
||||
else:
|
||||
mastodon.status_post(toot.replace('\\n','\n'), visibility='unlisted')
|
||||
|
||||
|
||||
megafono()
|
||||
|
|
Loading…
Reference in a new issue