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()
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)