示例#1
0
                except ws_exceptions.WebSocketConnectionClosedException as err:
                    output("Connection is closed.\n{}\n{}".format(
                        err,
                        *sys.exc_info()[0:]))
                    break
                except ConnectionResetError as err:
                    output("Connection has been reset.\n{}\n{}".format(
                        err,
                        *sys.exc_info()[0:]))
                    break
                except Exception as err:
                    output("Something awful happened!")
                    output(err)
                    output("{}".format(*sys.exc_info()[0:]))

                    bot.cleanup_your_mess()

                    if app_config:
                        try:
                            smtp_server = smtplib.SMTP_SSL(
                                app_config.get('smtp_address'),
                                app_config.get('smtp_port'))
                            smtp_server.ehlo()
                            smtp_server.login(app_config.get('mail_user'),
                                              app_config.get('mail_pass'))

                            subject = "{} is down!".format(bot_name)
                            body = "{} has stopped running due to the following exception:".format(
                                bot_name)

                            email_text = "From: {}\nTo: {}\nSubject: {}\n\n{}\n{}\n{}".format(