Exemple #1
0
def report(bot, update):
    # get tagged Message
    message = update.message.reply_to_message

    # delete ![command] message
    messageRemover(bot, update.message)
    try:
        # get chat_id of admins group
        admins_group_chat_id = Config.getInt('GENERAL.ADMINS_GROUP_CHAT_ID', 0)
        if admins_group_chat_id != 0:
            forwarded_message = bot.forward_message(
                chat_id=admins_group_chat_id,
                from_chat_id=update.message.chat_id,
                message_id=message.message_id
            )

            reported_message_delete(bot, update, admins_group_chat_id, forwarded_message, message)
            # TODO: Replace Method
            # user = message.from_user
            # user_info = "[{}](tg://user?id={})".format(
            #     user.username if user.username else user.first_name,
            #     user.id
            # )
            # # TODO: video, sticker
            # if bool(message.photo):
            #     bot.send_photo(
            #
            #     )
            # else:
            #     bot.send_message(
            #         chat_id=admins_group_chat_id,
            #         text=REPORT_MESSAGE.read().format(
            #             user=user_info,
            #             message=message.text
            #         ),
            #         parse_mode=telegram.ParseMode.MARKDOWN,
            #     )

        else:
            log.error(__file__, 'report', "you don't set ADMINS_GROUP_CHAT_ID in configuration yet")
    except Exception as e:
        log.error(__file__, 'report', e)
Exemple #2
0
def registration_verification(bot, update, job_queue, user):
    # define button
    commands = [
        [InlineKeyboardButton(
            REGISTRATION_VERIFY_BUTTON.read(),
            callback_data=str(user.id)
        )],
    ]
    # create a markup
    reply_markup = InlineKeyboardMarkup(commands)

    # TODO: is it safe ? others can get information about logged in user
    #   Mitigation: it's better that show first name of joined user
    user_info = "[{}](tg://user?id={})".format(
        user.username if user.username else user.first_name,
        user.id
    )

    # timer should be a number (we wanna use integer)
    timer = Config.getInt('OPTIONS.REGISTER_TIMER_MINUTES', 1)

    # send verification message
    message = bot.send_message(
        chat_id=update.message.chat_id,
        text=WELCOME.read().format(
            USER=user_info,
            TIME=timer
        ),
        reply_markup=reply_markup,
        parse_mode=telegram.ParseMode.MARKDOWN
    )

    # add to job queue
    job_queue.run_once(
        register_timer,
        timer * 60,
        context={
            "chat_id": update.message.chat_id,
            "message": message,
            "user_id": user.id
        }
    )