コード例 #1
0
ファイル: session.py プロジェクト: jnraptor-builds/hetznerbot
        def wrapper(update, context):
            try:
                session = get_session()
                subscriber = Subscriber.get_or_create(session,
                                                      update.message.chat_id)

                username = update.message.from_user.username
                if (not subscriber.authorized and username is not None
                        and username.lower() != config["telegram"]["admin"]):
                    update.message.chat.send_message(
                        "Sorry. Hetznerbot is no longer public.")
                    return

                func(context.bot, update, session, subscriber)
                session.commit()
            except:
                if send_message:
                    context.bot.sendMessage(
                        chat_id=update.message.chat_id,
                        text="An unknown error occurred.",
                    )
                traceback.print_exc()
                sentry.capture_exception(tags={"handler": "normal"})
            finally:
                session.remove()
コード例 #2
0
ファイル: session.py プロジェクト: jnraptor-builds/hetznerbot
    def wrapper(context):
        session = get_session()
        try:
            func(context, session)

            session.commit()
        except:  # noqa
            traceback.print_exc()
            sentry.capture_exception(tags={"handler": "job"})
        finally:
            session.close()
コード例 #3
0
ファイル: session.py プロジェクト: napcae/hetznerbot
        def wrapper(context):
            session = get_session()
            try:
                func(context, session)

                session.commit()
            except:  # noqa
                traceback.print_exc()
                sentry.captureException()
            finally:
                session.close()
コード例 #4
0
ファイル: session.py プロジェクト: napcae/hetznerbot
 def wrapper(update, context):
     session = get_session()
     try:
         func(context.bot, update, session)
         session.commit()
     except:
         if send_message:
             context.bot.sendMessage(
                 chat_id=update.message.chat_id,
                 text='An unknown error occurred.',
             )
         traceback.print_exc()
         sentry.captureException()
     finally:
         session.remove()