Commit 96ea2e38 authored by user's avatar user
Browse files

error checking

parent 06937eb6
......@@ -13,13 +13,21 @@ def shout(bot, trigger):
conn = sqlite3.connect(db)
c = conn.cursor()
mastodon = Mastodon(
access_token = bot.config.mastodon.access_token,
api_base_url = bot.config.mastodon.api_base_url
)
c.execute('''INSERT INTO shouts(created_at,name,message) VALUES(?,?,?)''', (trigger.time, trigger.nick, trigger.group(2) ))
mastodon.toot('Shoutout from ' + trigger.nick +' : ' + trigger.group(2))
try:
c.execute('''INSERT INTO shouts(created_at,name,message) VALUES(?,?,?)''', (trigger.time, trigger.nick, trigger.group(2) ))
except TypeError:
bot.say("that was not a valid shout")
try:
mastodon = Mastodon(
access_token = bot.config.mastodon.access_token,
api_base_url = bot.config.mastodon.api_base_url
)
mastodon.toot('Shoutout from ' + trigger.nick +' : ' + trigger.group(2))
except MastodonBadGatewayError:
bot.say("mastodont failed")
conn.commit()
conn.close()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment