hopefully neuter works
This commit is contained in:
15
bot.py
15
bot.py
@@ -3,14 +3,20 @@ import logging
|
||||
|
||||
# Mastodon bot to post things
|
||||
class bot():
|
||||
def __init__(self, config):
|
||||
def __init__(self, config, neuter=False):
|
||||
self.neuter = neuter
|
||||
self.masto = Mastodon(access_token=config["mastodon"]["access_token"], api_base_url=config["mastodon"]["host"])
|
||||
|
||||
# uploads media to mastodon, returns the mastodon ID
|
||||
# specify mimetype of video files as "video/mp4" to avoid error
|
||||
def upload_media(self, filename, mimetype=None):
|
||||
logging.info(f"Uploading media {filename}")
|
||||
return self.masto.media_post(filename, mime_type=mimetype)
|
||||
if not self.neuter:
|
||||
returnval = self.masto.media_post(filename, mime_type=mimetype)
|
||||
else:
|
||||
print(f"Would have uploaded {filename}")
|
||||
returnval = True
|
||||
return returnval
|
||||
|
||||
# uploads all given media
|
||||
def upload_all_media(self, filenames):
|
||||
@@ -21,4 +27,7 @@ class bot():
|
||||
|
||||
def toot(self, text, media=None):
|
||||
logging.info(f"Posting:\n Text: {text}")
|
||||
self.masto.status_post(text, media_ids=media)
|
||||
if not self.neuter:
|
||||
self.masto.status_post(text, media_ids=media)
|
||||
else:
|
||||
print(f"Would have posted {text}")
|
||||
|
||||
Reference in New Issue
Block a user