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()
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()
def wrapper(context): session = get_session() try: func(context, session) session.commit() except: # noqa traceback.print_exc() sentry.captureException() finally: session.close()
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()