basic cleanup

This commit is contained in:
Lynne Megido 2020-01-19 21:20:56 +10:00
parent e6b17d38fb
commit b083eca53f
Signed by: lynnesbian
GPG key ID: F0A184B5213D9F90

17
gen.py
View file

@ -12,10 +12,11 @@ parser.add_argument('-s', '--simulate', dest='simulate', action='store_true',
args = parser.parse_args() args = parser.parse_args()
client = Mastodon( if not args.simulate:
client_id="clientcred.secret", client = Mastodon(
access_token="usercred.secret", client_id="clientcred.secret",
api_base_url="https://botsin.space") access_token="usercred.secret",
api_base_url="https://botsin.space")
db = sqlite3.connect("dict.db") db = sqlite3.connect("dict.db")
db.text_factory=str db.text_factory=str
@ -30,8 +31,10 @@ if not args.simulate:
try: try:
client.status_post(toot, visibility = 'unlisted') client.status_post(toot, visibility = 'unlisted')
except Exception as err: except Exception as err:
toot = "Mistress @lynnesbian@fedi.lynnesbian.space, something has gone terribly" \ toot = "Arr, @lynnesbian@fedi.lynnesbian.space, ye scallywag!" \
+ " wrong! While attempting to post a toot, I received the following" \ + " I've encountered an error most dire!" \
+ " error:\n" + "\n".join(traceback.format_tb(sys.exc_info()[2])) + " 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!") client.status_post(toot, visibility = 'unlisted', spoiler_text = "Error!")
print(toot) print(toot)