Merge branch 'py3' into 'master'
Py3 - Format exceptions properly Exceptions need to be explicitly cast as strings before being fed to format() now See merge request !4
This commit is contained in:
commit
3718db5086
@ -82,7 +82,7 @@ class DispatchMessage(generics.GenericAPIView):
|
||||
bot.privmsg(action.destination, text)
|
||||
except Exception as e:
|
||||
new_data = copy.deepcopy(message.data)
|
||||
new_data['status'] = "FAILED - {0:s}".format(e)
|
||||
new_data['status'] = "FAILED - {0:s}".format(str(e))
|
||||
new_message = self.serializer_class(data=new_data)
|
||||
return Response(new_message.initial_data)
|
||||
elif action.type == DispatcherAction.FILE_TYPE:
|
||||
|
@ -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