Fix to get Mastodon connector working, tested.
This commit is contained in:
parent
0769cfe775
commit
07b153538b
|
|
@ -57,5 +57,4 @@ BOT_TOKEN = xxxxxxxxxx:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||||
ENABLE = TRUE
|
ENABLE = TRUE
|
||||||
ACCESS_TOKEN = mastodonaccesstoken
|
ACCESS_TOKEN = mastodonaccesstoken
|
||||||
APP_URL = mastodonappurl
|
APP_URL = mastodonappurl
|
||||||
MAX_IMAGE_SIZE = maximagesize
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,9 @@ def sendMastodon(photo, message, config):
|
||||||
while sent == False:
|
while sent == False:
|
||||||
try:
|
try:
|
||||||
bot = Mastodon(
|
bot = Mastodon(
|
||||||
access_token=config.get['MASTODON']['ACCESS_TOKEN'],
|
access_token=config.get('MASTODON','ACCESS_TOKEN'),
|
||||||
api_base_url=config.get['MASTODON']['APP_URL']
|
api_base_url=config.get('MASTODON','APP_URL')
|
||||||
)
|
)
|
||||||
#todo: add photo/image processing here, Mastodon has strict image sizing requirements
|
|
||||||
mediaid = bot.media_post(photo, mime_type="image/jpeg")
|
mediaid = bot.media_post(photo, mime_type="image/jpeg")
|
||||||
sent = bot.status_post(message,None,mediaid,False, "Public")
|
sent = bot.status_post(message,None,mediaid,False, "Public")
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
|
|
@ -17,7 +16,7 @@ def sendMastodon(photo, message, config):
|
||||||
print(f"Unexpected {err=}, {type(err)=}")
|
print(f"Unexpected {err=}, {type(err)=}")
|
||||||
print("\nString err:\n"+str(err))
|
print("\nString err:\n"+str(err))
|
||||||
if retry_c > 4:
|
if retry_c > 4:
|
||||||
print('Telegram attempts exceeded. Message not sent.')
|
print('Mastodon attempts exceeded. Message not sent.')
|
||||||
break
|
break
|
||||||
elif str(err) == 'Unauthorized':
|
elif str(err) == 'Unauthorized':
|
||||||
print('Invalid Mastodon bot token, message not sent.')
|
print('Invalid Mastodon bot token, message not sent.')
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue