diff --git a/gen.py b/gen.py index 84f1b06..4961990 100755 --- a/gen.py +++ b/gen.py @@ -12,10 +12,11 @@ parser.add_argument('-s', '--simulate', dest='simulate', action='store_true', args = parser.parse_args() -client = Mastodon( - client_id="clientcred.secret", - access_token="usercred.secret", - api_base_url="https://botsin.space") +if not args.simulate: + client = Mastodon( + client_id="clientcred.secret", + access_token="usercred.secret", + api_base_url="https://botsin.space") db = sqlite3.connect("dict.db") db.text_factory=str @@ -30,8 +31,10 @@ if not args.simulate: try: client.status_post(toot, visibility = 'unlisted') except Exception as err: - toot = "Mistress @lynnesbian@fedi.lynnesbian.space, something has gone terribly" \ - + " wrong! While attempting to post a toot, I received the following" \ - + " error:\n" + "\n".join(traceback.format_tb(sys.exc_info()[2])) + toot = "Arr, @lynnesbian@fedi.lynnesbian.space, ye scallywag!" \ + + " I've encountered an error most dire!" \ + + " Check error.log in ye bot directory!!" + with open("error.log", "w") as f: + f.write("\n".join(traceback.format_tb(sys.exc_info()[2]))) client.status_post(toot, visibility = 'unlisted', spoiler_text = "Error!") print(toot)