twitter: wrap exceptions in str() before format()
this might also do something about #1, considering i'm also just doing blanket except Exception:s now. fingers crossed
This commit is contained in:
parent
124cf0bdb0
commit
b09c20e910
@ -95,8 +95,10 @@ class Twitter(Plugin):
|
||||
try:
|
||||
tweet = self.twit.show_status(id=status)
|
||||
return self._return_tweet_or_retweet_text(event, tweet=tweet, print_source=print_source, print_id=print_id)
|
||||
except twython.exceptions.TwythonError as e:
|
||||
return self.bot.reply(event, "Couldn't obtain status: {0:s}".format(e))
|
||||
except Exception as e:
|
||||
log.error("couldn't obtain status")
|
||||
log.exception(e)
|
||||
return self.bot.reply(event, "Couldn't obtain status: {0:s}".format(str(e)))
|
||||
|
||||
def handle_getuserstatus(self, connection, event, match):
|
||||
"""Get a status for a user. Allows for getting one other than the most recent."""
|
||||
@ -130,12 +132,10 @@ class Twitter(Plugin):
|
||||
tweet = tweets[-1*index]
|
||||
return self._return_tweet_or_retweet_text(event, tweet=tweet, print_source=print_source,
|
||||
print_id=print_id)
|
||||
except requests.exceptions.SSLError as ssle:
|
||||
return self.bot.reply(event, "Couldn't obtain status: {0:s}, you can maybe try again".format(ssle))
|
||||
except twython.exceptions.TwythonError as e:
|
||||
return self.bot.reply(event, "Couldn't obtain status: {0:s}".format(e))
|
||||
except ValueError as e:
|
||||
return self.bot.reply(event, "Couldn't obtain status: {0:s}".format(e))
|
||||
except Exception as e:
|
||||
log.error("couldn't obtain status")
|
||||
log.exception(e)
|
||||
return self.bot.reply(event, "Couldn't obtain status: {0:s}".format(str(e)))
|
||||
|
||||
def handle_tweet(self, connection, event, match):
|
||||
"""Tweet. Needs authentication."""
|
||||
@ -151,8 +151,10 @@ class Twitter(Plugin):
|
||||
return self.bot.reply(event, "'{0:s}' tweeted.".format(tweet))
|
||||
else:
|
||||
return self.bot.reply(event, "Unknown error sending tweet(s).")
|
||||
except twython.exceptions.TwythonError as e:
|
||||
return self.bot.reply(event, "Couldn't tweet: {0:s}".format(e))
|
||||
except Exception as e:
|
||||
log.error("couldn't tweet")
|
||||
log.exception(e)
|
||||
return self.bot.reply(event, "Couldn't tweet: {0:s}".format(str(e)))
|
||||
|
||||
def handle_replyto(self, connection, event, match):
|
||||
"""Reply to a tweet, in the twitter in_reply_to_status_id sense. Needs authentication."""
|
||||
@ -174,8 +176,10 @@ class Twitter(Plugin):
|
||||
return self.bot.reply(event, "'{0:s}' tweeted.".format(tweet))
|
||||
else:
|
||||
return self.bot.reply(event, "Unknown error sending tweet.")
|
||||
except twython.exceptions.TwythonError as e:
|
||||
return self.bot.reply(event, "Couldn't tweet: {0:s}".format(e))
|
||||
except Exception as e:
|
||||
log.error("couldn't tweet")
|
||||
log.exception(e)
|
||||
return self.bot.reply(event, "Couldn't tweet: {0:s}".format(str(e)))
|
||||
|
||||
def handle_gettoken(self, connection, event, match):
|
||||
"""Get an oauth token, so that the user may authenticate the bot."""
|
||||
|
Loading…
Reference in New Issue
Block a user