Example #1
0
def set_cooldown(bot, update, args=None):
    chat_id, chat_type, user_id, text, message = support.extract_update_info(update)
    support.delete_message(chat_id, message.message_id, bot)

    if (not support.is_admin(chat_id, user_id, bot) or are_banned(user_id, chat_id)) and is_staff(user_id) is False:
        return

    group = get_group(chat_id)
    if group is None:
        bot.sendMessage(
            chat_id=chat_id,
            text="❌ No puedo reconocer este grupo. Si estaba funcionando hasta ahora, pregunta en @profesordumbledoreayuda.",
            parse_mode=telegram.ParseMode.MARKDOWN
        )
        return

    if args is None or len(args) != 1 or not args[0].isdigit() or int(args[0])<0:
        bot.sendMessage(
            chat_id=chat_id,
            text="❌ No he reconocido el parámetro introducido. Por favor, revisa el comando e intenta de nuevo.")
        return

    if int(args[0]) is 0:
        set_welcome_cooldown(chat_id, None)
        output = "👌 El mensaje de bienvenida no se eliminará automáticamente."
    else:
        set_welcome_cooldown(chat_id, int(args[0]))
        output = "👌 El mensaje de bienvenida se eliminará automáticamente en {} segundos".format(args[0])
    bot.sendMessage(
        chat_id=chat_id,
        text=output,
        parse_mode=telegram.ParseMode.MARKDOWN)
    return
Example #2
0
def add_ghost_cmd(bot, update, args=None):
    (chat_id, chat_type, user_id, text, message) = support.extract_update_info(update)
    support.delete_message(chat_id, message.message_id, bot)

    if not is_staff(user_id):
        return

    if len(args) == 0:
        return

    user = get_user(user_id)

    if user is not None:
        set_ghost(args[0], True)
        add_flag(args[0], "👻")

    else:
        bot.sendMessage(
        chat_id=chat_id,
        text="❌ Ese usuario no existe.",
        parse_mode=telegram.ParseMode.MARKDOWN)
        return

    bot.sendMessage(
        chat_id=chat_id,
        text="👌 El usuario ahora es un fantasma 👻",
        parse_mode=telegram.ParseMode.MARKDOWN)
Example #3
0
def list_news(bot, update):
    chat_id, chat_type, user_id, text, message = support.extract_update_info(
        update)
    support.delete_message(chat_id, message.message_id, bot)

    if not support.is_admin(chat_id, user_id, bot) or are_banned(
            user_id, chat_id):
        return

    active_news = news_sql.get_news_subscribed(chat_id)
    verified_out = ""
    def_out = ""

    if active_news is None:
        output = "❌ No hay suscrpiciones activas en este grupo."

    else:
        for k in active_news:
            provider = news_sql.get_news_provider(k.news_id)
            if provider.active:
                verified_out = "🔰 @{}\n".format(provider.alias) + verified_out
            else:
                def_out = "📰 {} - `{}`\n".format(provider.alias,
                                                 provider.id) + def_out

        output = "Listado de canales activos:\n" + verified_out + def_out

    bot.sendMessage(chat_id=chat_id,
                    text=output,
                    parse_mode=telegram.ParseMode.MARKDOWN)
Example #4
0
def set_maxmembers(bot, update, args=None):
    chat_id, chat_type, user_id, text, message = support.extract_update_info(update)
    support.delete_message(chat_id, message.message_id, bot)

    if (not support.is_admin(chat_id, user_id, bot) or are_banned(user_id, chat_id)) and is_staff(user_id) is False:
        return

    group = get_group(chat_id)
    if group is None:
        bot.sendMessage(
            chat_id=chat_id,
            text="❌ No puedo reconocer este grupo. Si estaba funcionando hasta ahora, pregunta en @profesordumbledoreayuda.",
            parse_mode=telegram.ParseMode.MARKDOWN
        )
        return

    if args is None or len(args) != 1 or not args[0].isdigit() or int(args[0])<0:
        bot.sendMessage(
            chat_id=chat_id,
            text="❌ No he reconocido el parámetro introducido. Por favor, revisa el comando e intenta de nuevo.")
        return

    if int(args[0]) is 0:
        set_max_members(chat_id, None)
        output = "👌 Número máximo de miembros en el grupo desactivado correctamente."
    else:
        set_max_members(chat_id, int(args[0]))
        output = "👌 Número máximo de miembros en el grupo establecido a {}".format(args[0])
    bot.sendMessage(
        chat_id=chat_id,
        text=output,
        parse_mode=telegram.ParseMode.MARKDOWN)
    return
Example #5
0
def listrefloat_cmd(bot, update):
    chat_id, chat_type, user_id, text, message = support.extract_update_info(
        update)
    support.delete_message(chat_id, message.message_id, bot)

    if message.reply_to_message is None or message.reply_to_message.chat.id != chat_id:
        return

    if message.reply_to_message.from_user.id != bot.id:
        return

    if are_banned(user_id,
                  chat_id) or not support.is_admin(chat_id, user_id, bot):
        return

    text = message.reply_to_message.text
    if REGLIST.search(text) is None:
        return

    text = message.reply_to_message.text
    button_list = [[
        InlineKeyboardButton(text="🙋‍♀️ Me apunto!",
                             callback_data='list_join'),
        InlineKeyboardButton(text="🙅‍♀️ Paso...", callback_data='list_left')
    ]]

    bot.sendMessage(chat_id=chat_id,
                    text=text,
                    parse_mode=telegram.ParseMode.MARKDOWN,
                    reply_markup=InlineKeyboardMarkup(button_list),
                    disable_web_page_preview=True)
    support.delete_message(chat_id, message.reply_to_message.message_id, bot)
Example #6
0
def init_news(bot, update, args=None):
    chat_id, chat_type, user_id, text, message = support.extract_update_info(
        update)
    support.delete_message(chat_id, message.message_id, bot)

    if chat_type != "channel":
        return

    if hasattr(message.chat, 'username') and message.chat.username is not None:
        alias = message.chat.username
    elif args is not None and len(args) != 0:
        alias = args[0]
    else:
        output = "❌ He reconocido este canal como un canal privado y no me has especificado un nombre para el canal."
        bot.sendMessage(chat_id=chat_id, text=output)
        return

    if not news_sql.is_news_provider(chat_id):
        news_sql.set_news_provider(chat_id, alias)

    output = (
        "📰 Bienvenido al sistema de noticias de @ProfesorDumbledoreBot.\nYa tan solo "
        "queda el último paso. Ejecuta `/add_news {}` en los grupos que quie"
        "ras recibir las noticias de este canal.".format(chat_id))
    bot.sendMessage(chat_id=chat_id,
                    text=output,
                    parse_mode=telegram.ParseMode.MARKDOWN)
Example #7
0
def listopen_cmd(bot, update):
    chat_id, chat_type, user_id, text, message = support.extract_update_info(
        update)
    support.delete_message(chat_id, message.message_id, bot)

    if message.reply_to_message is None or message.reply_to_message.chat.id != chat_id:
        return

    if message.reply_to_message.from_user.id != bot.id:
        return

    if are_banned(user_id,
                  chat_id) or not support.is_admin(chat_id, user_id, bot):
        return

    text = message.reply_to_message.text
    if REGLIST.search(text) is None:
        return

    button_list = [[
        InlineKeyboardButton(text="🙋‍♀️ Me apunto!",
                             callback_data='list_join'),
        InlineKeyboardButton(text="🙅‍♀️ Paso...", callback_data='list_left')
    ]]

    bot.edit_message_reply_markup(
        chat_id=chat_id,
        message_id=message.reply_to_message.message_id,
        reply_markup=InlineKeyboardMarkup(button_list))
def sighting_cmd(bot, update):
    chat_id, chat_type, user_id, text, message = support.extract_update_info(
        update)
    username = message.from_user.username
    support.delete_message(chat_id, message.message_id, bot)

    if are_banned(user_id, chat_id):
        return

    user = get_real_user(user_id)
    if user is None:
        bot.sendMessage(chat_id=chat_id,
                        text="❌ Debes registrarte para usar este comando.",
                        parse_mode=telegram.ParseMode.MARKDOWN)
        return

    if message.reply_to_message is not None:
        if message.reply_to_message.location is not None:
            support.delete_message(chat_id,
                                   message.reply_to_message.message_id, bot)
            lat = message.reply_to_message.location.latitude
            lon = message.reply_to_message.location.longitude

            group = get_group(chat_id)
            group_tz = group.timezone
            tz = pytz.timezone(group_tz)

            localTime = datetime.now().replace(tzinfo=pytz.utc)
            groupDateTime = localTime.astimezone(tz)
            groupTime = groupDateTime.time()

            button_list = [
                [
                    InlineKeyboardButton(
                        text="📍 Ubicación",
                        callback_data='sighting_ubi_{0}_{1}'.format(lat, lon))
                ],
                [
                    InlineKeyboardButton(
                        text="🙋‍♀️ ¡Está!",
                        callback_data='sighting_yes_{0}_{1}'.format(lat, lon)),
                    InlineKeyboardButton(
                        text="🙅‍♀️ No está...",
                        callback_data='sighting_no_{0}_{1}'.format(lat, lon))
                ]
            ]

            output = text.split(None, 1)
            out = "🐾 " + escape_markdown(
                output[1]
            ) + f"\n\n👤 Avistado por @{username} a las {groupTime.hour:02}:{groupTime.minute:02}\nℹ️ Información:"

            bot.sendMessage(chat_id=chat_id,
                            text=out,
                            reply_markup=InlineKeyboardMarkup(button_list))
Example #9
0
def clear_rules(bot, update):
    chat_id, chat_type, user_id, text, message = support.extract_update_info(
        update)
    support.delete_message(chat_id, message.message_id, bot)

    if not support.is_admin(chat_id, user_id, bot) or are_banned(
            user_id, chat_id):
        return

    rul_sql.add_rules(chat_id, "")
    update.effective_message.reply_text(
        "❌ Normas del grupo eliminadas correctamente.")
Example #10
0
def set_zone(bot, update, args=None):
    chat_id, chat_type, user_id, text, message = support.extract_update_info(
        update)
    support.delete_message(chat_id, message.message_id, bot)

    if not support.is_admin(chat_id, user_id, bot) or are_banned(
            user_id, chat_id):
        return

    group = get_group(chat_id)
    if group is None:
        bot.sendMessage(
            chat_id=chat_id,
            text=
            "❌ No puedo reconocer este grupo. Si estaba funcionando hasta ahora, pregunta en @profesordumbledoreayuda.",
            parse_mode=telegram.ParseMode.MARKDOWN)
        return

    if args is None or len(args) != 1 or len(args[0]) < 3 or len(args[0]) > 60:
        bot.sendMessage(
            chat_id=chat_id,
            text=
            ("❌ Me siento un poco perdido ahora mismo. Debes pasarme un nombre de zona horaria en inglés, por ejemplo, `America/Montevideo` o `Europe/Madrid`."
             ),
            parse_mode=telegram.ParseMode.MARKDOWN)
        return

    tz = support.get_unified_timezone(args[0])

    if len(tz) == 1:
        commit_group(chat_id, timezone=tz[0])
        bot.sendMessage(
            chat_id=chat_id,
            text="👌 Perfecto! Zona horaria cambiada de *{0}* a *{1}*.".format(
                group.timezone, tz[0]),
            parse_mode=telegram.ParseMode.MARKDOWN)
        now = datetime.now(timezone(tz[0])).strftime("%H:%M")
        bot.sendMessage(
            chat_id=chat_id,
            text="🕒 Por favor, comprueba que la hora sea correcta: {}".format(
                now))

    elif len(tz) == 0:
        bot.sendMessage(
            chat_id=chat_id,
            text="❌ Uy, no he encontrado ninguna zona horaria con ese nombre")

    else:
        bot.sendMessage(
            chat_id=chat_id,
            text=
            "❌ Has sido demasiado genérico con el nombre de la zona horaria. Intenta concretar más."
        )
Example #11
0
def stop_news(bot, update):
    chat_id, chat_type, user_id, text, message = support.extract_update_info(update)
    support.delete_message(chat_id, message.message_id, bot)

    if chat_type != "channel":
        return

    if news_sql.is_news_provider(chat_id):
        news_sql.rm_news_provider(chat_id)
        output = "✅ ¡Canal eliminado correctamente!"
    else:
        output = "❌ No he reconocido este canal como proveedor de noticias."

    bot.sendMessage(chat_id=chat_id, text=output)
Example #12
0
def process_gif(bot, update, job_queue):
    (chat_id, chat_type, user_id, text,
     message) = support.extract_update_info(update)
    nanny = get_nanny_settings(chat_id)

    if nanny and nanny.animation:
        if support.is_admin(chat_id, user_id, bot) and not nanny.admin_too:
            return

        support.delete_message(chat_id, message.message_id, bot)
        if nanny.warn:
            send_warn(bot, chat_id, user_id, job_queue, nanny.reply)
        else:
            send_alert(bot, chat_id, job_queue, nanny.reply)
Example #13
0
def nanny_text(bot, user_id, chat_id, message, job_queue):
    nanny = get_nanny_settings(chat_id)

    if nanny and nanny.text:
        if support.is_admin(chat_id, user_id, bot) and not nanny.admin_too:
            return False

        support.delete_message(chat_id, message.message_id, bot)
        if nanny and nanny.warn:
            send_warn(bot, chat_id, user_id, job_queue, nanny.reply)
        else:
            send_alert(bot, chat_id, job_queue, nanny.reply)

        return True

    return False
Example #14
0
def add_news(bot, update, args=None):
    chat_id, chat_type, user_id, text, message = support.extract_update_info(update)
    support.delete_message(chat_id, message.message_id, bot)

    if not support.is_admin(chat_id, user_id, bot) or are_banned(user_id, chat_id):
        return

    if args is None or len(args)!=1:
        return

    output = "❌ No he reconocido este canal como proveedor de noticias."

    if news_sql.is_news_provider(args[0]) and not news_sql.is_news_subscribed(chat_id, args[0]):
        news_sql.set_news_subscription(chat_id, args[0])
        output = "✅ ¡Suscripción realizada correctamente!"

    bot.sendMessage(chat_id=chat_id, text=output)
Example #15
0
def plants_list_cmd(bot, update, args=None):
    chat_id, chat_type, user_id, text, message = support.extract_update_info(
        update)
    support.delete_message(chat_id, message.message_id, bot)

    if are_banned(chat_id, user_id):
        return

    user = get_real_user(user_id)
    if user is None:
        bot.sendMessage(chat_id=chat_id,
                        text="❌ Debes registrarte para usar este comando.",
                        parse_mode=telegram.ParseMode.MARKDOWN)
        return

    text = "Lista de plantaciones en *{}*:\n".format(message.chat.title)
    plants_list = get_plant_list(chat_id)
    if not list(plants_list):
        bot.sendMessage(chat_id=user_id,
                        text="❌ No hay plantaciones registradas.",
                        parse_mode=telegram.ParseMode.MARKDOWN,
                        disable_web_page_preview=True)
        return
    count = 0
    for plant in plants_list:
        plantName = support.replace_plants(plant.plant_type)
        poi = get_poi(plant.portal)
        if plant.alerted:
            text = text + "\n- #{0} *{1}* - ⚠️ {2} ⚠️ - [{3}](https://maps.google.com/maps?q={4},{5})".format(
                plant.id, plantName,
                f"{plant.grow_end.hour:02}:{plant.grow_end.minute:02}",
                poi.name, poi.latitude, poi.longitude)
        else:
            text = text + "\n- #{0} *{1}* - {2} - [{3}](https://maps.google.com/maps?q={4},{5})".format(
                plant.id, plantName,
                f"{plant.grow_end.hour:02}:{plant.grow_end.minute:02}",
                poi.name, poi.latitude, poi.longitude)
        count += 1
        if count == 100:
            pass

    bot.sendMessage(chat_id=user_id,
                    text=text,
                    parse_mode=telegram.ParseMode.MARKDOWN,
                    disable_web_page_preview=True)
Example #16
0
def settings(bot, update, args=None):
    chat_id, chat_type, user_id, text, message = support.extract_update_info(update)
    support.delete_message(chat_id, message.message_id, bot)

    if (not support.is_admin(chat_id, user_id, bot) or are_banned(user_id, chat_id)) and is_staff(user_id) is False:
        return

    group = get_group(chat_id)
    if group is None:
        bot.sendMessage(
            chat_id=chat_id,
            text="❌ No puedo reconocer este grupo. Si estaba funcionando hasta ahora, pregunta en @profesordumbledoreayuda.",
            parse_mode=telegram.ParseMode.MARKDOWN
        )
        return

    message = bot.sendMessage(chat_id=chat_id, text="Oído cocina!...")
    support.update_settings_message(chat_id, bot, message.message_id, keyboard="main")
Example #17
0
def set_rules(bot, update):
    chat_id, chat_type, user_id, text, message = support.extract_update_info(
        update)
    support.delete_message(chat_id, message.message_id, bot)

    if not support.is_admin(chat_id, user_id, bot) or are_banned(
            user_id, chat_id):
        return

    args = text.split(None, 1)
    if len(args) == 2:
        txt = args[1]
        offset = len(txt) - len(text)
        markdown_rules = support.markdown_parser(
            txt, entities=message.parse_entities(), offset=offset)

        rul_sql.add_rules(chat_id, markdown_rules)
        update.effective_message.reply_text(
            "✅ Normas del grupo establecidas correctamente.".format(chat_id))
Example #18
0
def rps_ai_cmd(bot, update):
    (chat_id, chat_type, user_id, text, message) = support.extract_update_info(update)
    support.delete_message(chat_id, message.message_id, bot)

    choices = ["r", "p", "s"]

    b1 = "g*rps_ai_r_" + choices[randint(0,2)] + "_" + str(bot.id)
    b2 = "g*rps_ai_p_" + choices[randint(0,2)] + "_" + str(bot.id)
    b3 = "g*rps_ai_s_" + choices[randint(0,2)] + "_" + str(bot.id)

    markup = [
	[InlineKeyboardButton(text="Piedra", callback_data=b1)],
    [InlineKeyboardButton(text="Papel", callback_data=b2)],
    [InlineKeyboardButton(text="Tijera", callback_data=b3)]]

    bot.sendMessage(
	    chat_id=chat_id, 
	    text='@ProfesorDumbledoreBot te desafía a Piedra, Papel o Tijera! \n ¿Qué eliges?', 
	    disable_notification=True, 
	    reply_markup=InlineKeyboardMarkup(markup))
Example #19
0
def send_rules(bot, update, group_id=None):
    chat_id, chat_type, user_id, text, message = support.extract_update_info(
        update)
    support.delete_message(chat_id, message.message_id, bot)

    if group_id is None:
        try:
            chat = bot.get_chat(chat_id)
        except BadRequest as excp:
            return
        rules = rul_sql.get_rules(chat_id)
        if chat_type != "private":
            group = get_group_settings(chat_id)
            if group.reply_on_group:
                dest_id = chat_id
            else:
                dest_id = user_id
        else:
            dest_id = user_id
    else:
        try:
            chat = bot.get_chat(group_id)
            rules = rul_sql.get_rules(group_id)
            dest_id = user_id
            bot.restrict_chat_member(group_id,
                                     user_id,
                                     can_send_messages=True,
                                     can_send_media_messages=True,
                                     can_send_other_messages=True,
                                     can_add_web_page_previews=True)
        except BadRequest as excp:
            return

    text = "Normas de *{}*:\n\n{}".format(escape_markdown(chat.title), rules)

    if rules:
        bot.sendMessage(dest_id, text, parse_mode=telegram.ParseMode.MARKDOWN)
    else:
        bot.sendMessage(dest_id,
                        "❌ No hay normas establecidas en este grupo.",
                        parse_mode=telegram.ParseMode.MARKDOWN)
Example #20
0
def game_spawn_cmd(bot, update, args=None):
    (chat_id, chat_type, user_id, text, message) = support.extract_update_info(update)
    support.delete_message(chat_id, message.message_id, bot)
    
    if not is_staff(user_id):
        return
    
    games = {"grageas":grag_cmd, "quién dijo":whosaid_cmd}
    
    if args == None or len(args) == 0:
        game_list = games.keys()
        game_list = '\n'.join(game_list)
        bot.sendMessage(
            chat_id=chat_id, 
            text='Estos son los juegos disponibles:\n' + game_list, 
            disable_notification=True)
        return
    args = " ".join(args)
    
    if games[args] != None:
        games[args](bot, update)
Example #21
0
def list_cmd(bot, update):
    chat_id, chat_type, user_id, text, message = support.extract_update_info(
        update)
    support.delete_message(chat_id, message.message_id, bot)

    if are_banned(user_id, chat_id):
        return

    button_list = [[
        InlineKeyboardButton(text="🙋‍♀️ Me apunto!",
                             callback_data='list_join'),
        InlineKeyboardButton(text="🙅‍♀️ Paso...", callback_data='list_left')
    ]]

    output = text.split(None, 1)
    out = escape_markdown(output[1]) + "\n\nApuntados:"

    bot.sendMessage(chat_id=chat_id,
                    text=out,
                    parse_mode=telegram.ParseMode.MARKDOWN,
                    reply_markup=InlineKeyboardMarkup(button_list),
                    disable_web_page_preview=True)
Example #22
0
def rm_staff_cmd(bot, update, args=None):
    (chat_id, chat_type, user_id, text,
     message) = support.extract_update_info(update)
    support.delete_message(chat_id, message.message_id, bot)

    if not is_staff(user_id):
        return

    if len(args) == 0:
        return

    if get_user(user_id) is not None:
        set_staff(args[0], False)
    else:
        bot.sendMessage(chat_id=chat_id,
                        text="❌ Ese usuario no existe.",
                        parse_mode=telegram.ParseMode.MARKDOWN)
        return

    bot.sendMessage(chat_id=chat_id,
                    text="👌 El usuario ya no forma parte del Staff",
                    parse_mode=telegram.ParseMode.MARKDOWN)
Example #23
0
def duel_cmd(bot, update):
    chat_id, chat_type, user_id, text, message = support.extract_update_info(update)
    support.delete_message(chat_id, message.message_id, bot)
    user_username = message.from_user.username

    if are_banned(user_id, chat_id):
        return
    user = get_user(user_id)
    if user is None:
        bot.sendMessage(
            chat_id=chat_id,
            text="❌ Debes registrarte para usar este comando.",
            parse_mode=telegram.ParseMode.MARKDOWN
        )
        return
    try:
        if user_username is None:
            bot.sendMessage(
                chat_id=chat_id,
                text="❌ Es necesario que configures un alias en Telegram antes de continuar usando el bot.",
                parse_mode=telegram.ParseMode.MARKDOWN
            )
            return
    except:
        bot.sendMessage(
            chat_id=chat_id,
            text="❌ Es necesario que configures un alias en Telegram antes de continuar usando el bot.",
            parse_mode=telegram.ParseMode.MARKDOWN
        )
        return

    text = f"@{message.from_user.username} Vs ???\n\n¿Quién aceptará el duelo?"
    markup = [[InlineKeyboardButton(text="Aceptar el duelo", callback_data=f"g*duel_accept_{user_id}")]]

    bot.sendMessage(
	    chat_id=chat_id, 
	    text=text, 
	    disable_notification=True, 
	    reply_markup=InlineKeyboardMarkup(markup))
Example #24
0
def process_cmd(bot, update, job_queue):
    (chat_id, chat_type, user_id, text,
     message) = support.extract_update_info(update)

    try:
        args = re.sub(r"^/[a-zA-Z0-9_]+", "", text).strip().split(" ")
        if len(args) == 1 and args[0] == "":
            args = []

    except Exception:
        args = None

    m = re.match("/([a-zA-Z0-9_]+)", text)

    if m is not None:
        command = m.group(1).lower()

        if command == "init_news":
            init_news(bot, update, args)
            return

        elif command == "stop_news":
            stop_news(bot, update, job_queue)
            return

    nanny = get_nanny_settings(chat_id)

    if nanny and nanny.command:
        if support.is_admin(chat_id, user_id, bot) and not nanny.admin_too:
            return

        support.delete_message(chat_id, message.message_id, bot)

        if nanny and nanny.warn:
            send_warn(bot, chat_id, user_id, job_queue, nanny.reply)

        else:
            send_alert(bot, chat_id, job_queue, nanny.reply)
Example #25
0
def listclose_cmd(bot, update):
    chat_id, chat_type, user_id, text, message = support.extract_update_info(
        update)
    support.delete_message(chat_id, message.message_id, bot)

    if message.reply_to_message is None or message.reply_to_message.chat.id != chat_id:
        return

    if message.reply_to_message.from_user.id != bot.id:
        return

    if are_banned(user_id,
                  chat_id) or not support.is_admin(chat_id, user_id, bot):
        return

    text = message.reply_to_message.text
    if REGLIST.search(text) is None:
        return

    bot.edit_message_reply_markup(
        chat_id=chat_id,
        message_id=message.reply_to_message.message_id,
        reply_markup=None)
Example #26
0
def settingsbutton(bot, update):
    logging.debug("%s %s", bot, update)
    query = update.callback_query
    data = query.data
    user = update.effective_user
    user_id = query.from_user.id
    user_username = query.from_user.username
    chat_id = query.message.chat.id
    message_id = query.message.message_id

    are_banned(user_id, chat_id)

    settings_goto = {
        "settings_goto_general": "general",
        "settings_goto_join": "join",
        "settings_goto_news": "news",
        "settings_goto_welcome": "welcome",
        "settings_goto_nanny": "nanny",
        "settings_goto_ladmin": "ladmin",
        "settings_goto_main": "main"
    }
    settings_general = {
        "settings_general_games": "games",
        "settings_general_hard": "hard",
        "settings_general_reply": "reply",
        "settings_general_warn": "warn"
    }
    settings_join = {
        "settings_join_mute": "silence",
        "settings_join_silence": "mute",
        "settings_join_val": "val"
    }
    settings_welcome = {"settings_welcome_welcome": "should_welcome"}
    settings_nanny = {
        "settings_nanny_command": "cmd",
        "settings_nanny_animation": "animation",
        "settings_nanny_contact": "contact",
        "settings_nanny_photo": "photo",
        "settings_nanny_games": "games",
        "settings_nanny_text": "text",
        "settings_nanny_sticker": "sticker",
        "settings_nanny_location": "location",
        "settings_nanny_url": "url",
        "settings_nanny_video": "video",
        "settings_nanny_warn": "warn",
        "settings_nanny_admin_too": "admin_too",
        "settings_nanny_voice": "voice"
    }
    settings_ladmin = {
        "settings_ladmin_welcome": "welcome",
        "settings_ladmin_admin": "admin",
        "settings_ladmin_ejections": "ejections"
    }
    settings_admin = {
        "settings_admin_welcome": "welcome",
        "settings_admin_goodbye": "goodbye",
        "settings_admin_admin": "admin",
        "settings_admin_ejections": "ejections"
    }

    if re.match("^settings_.+$", data) is not None:
        match = re.match(r"settings_news_([-0-9]*)", query.data)
        if not support.is_admin(chat_id, user_id, bot):
            bot.answerCallbackQuery(
                text=
                "Solo los administradores del grupo pueden configurar el bot.",
                callback_query_id=update.callback_query.id,
                show_alert="true")
            return

        if data in settings_goto:
            support.update_settings_message(chat_id,
                                            bot,
                                            message_id,
                                            keyboard=settings_goto[data])
        elif data == "settings_done":
            support.delete_message(chat_id, message_id, bot)
        elif data in settings_general:
            set_general_settings(chat_id, settings_general[data])
            support.update_settings_message(chat_id,
                                            bot,
                                            message_id,
                                            keyboard="general")
        elif data in settings_join:
            set_join_settings(chat_id, settings_join[data])
            support.update_settings_message(chat_id,
                                            bot,
                                            message_id,
                                            keyboard="join")
        elif data in settings_welcome:
            set_welcome_settings(chat_id, settings_welcome[data])
            support.update_settings_message(chat_id,
                                            bot,
                                            message_id,
                                            keyboard="welcome")
        elif data in settings_nanny:
            set_nanny_settings(chat_id, settings_nanny[data])
            support.update_settings_message(chat_id,
                                            bot,
                                            message_id,
                                            keyboard="nanny")
        elif data in settings_admin:
            set_admin_settings(chat_id, settings_admin[data])
            support.update_settings_message(chat_id,
                                            bot,
                                            message_id,
                                            keyboard="admin")
        elif data in settings_ladmin:
            set_ladmin_settings(chat_id, settings_ladmin[data])
            support.update_settings_message(chat_id,
                                            bot,
                                            message_id,
                                            keyboard="ladmin")
        elif data == "settings_admin_spy":
            set_ladmin_settings(chat_id, "admin_bot")
            support.delete_message(chat_id, message_id, bot)
            output = "Antes de nada administradores quiero daros las gracias. Debeis haber demostrado verdadera lealtad hacia mi en el grupo, y solo eso ha podido lograr que acuda Fawkes a vuestro grupo.\nÉl no puede leer nada de lo que suceda en el grupo, simplemente enviará las alertas que hayais configurado. Si necesitais configurar de nuevo las alertas o quereis usar los comandos, invitadme de nuevo al grupo y cuando acabeis volved a activar a Fawkes."
            bot.sendMessage(chat_id=chat_id,
                            text=output,
                            parse_mode=telegram.ParseMode.MARKDOWN)
            bot.leaveChat(chat_id=chat_id)

        elif match:
            news_id = match.group(1)
            if is_news_subscribed(chat_id, news_id):
                rm_news_subscription(chat_id, news_id)
            else:
                set_news_subscription(chat_id, news_id)
            support.update_settings_message(chat_id,
                                            bot,
                                            message_id,
                                            keyboard="news")

        return

    match = re.match(r"rm_warn\((.+?)\)", query.data)
    if match:
        if not support.is_admin(chat_id, user_id, bot):
            bot.answerCallbackQuery(
                text="Solo los administradores del grupo pueden retirar warns.",
                callback_query_id=update.callback_query.id,
                show_alert="true")
            return

        user_id = match.group(1)
        res = remove_warn(user_id, chat_id)
        if res:
            text = "Aviso eliminado por @{}.".format(user_username)
            bot.answerCallbackQuery(text="Has eliminado un warn.",
                                    callback_query_id=update.callback_query.id,
                                    show_alert="true")

        else:
            bot.answerCallbackQuery(
                text=
                "En estos momentos no puedo eliminar el warn, prueba mas tarde.",
                callback_query_id=update.callback_query.id,
                show_alert="true")
            return
        bot.edit_message_text(text=text,
                              chat_id=chat_id,
                              message_id=message_id,
                              parse_mode=telegram.ParseMode.HTML,
                              disable_web_page_preview=True)
        return

    match = re.match(r"rm_ban\((.+?)\)", query.data)
    if match:
        if not support.is_admin(chat_id, user_id, bot):
            bot.answerCallbackQuery(
                text="Solo los administradores del grupo pueden retirar bans.",
                callback_query_id=update.callback_query.id,
                show_alert="true")
            return
        us_id = match.group(1)
        bot.unbanChatMember(chat_id, us_id)
        bot.answerCallbackQuery(text="Has eliminado un ban.",
                                callback_query_id=update.callback_query.id,
                                show_alert="true")
        text = "Ban retirado por @{}.".format(user_username)
        bot.edit_message_text(text=text,
                              chat_id=chat_id,
                              message_id=message_id,
                              parse_mode=telegram.ParseMode.HTML,
                              disable_web_page_preview=True)
        return

    match = re.match(r"rm_mute\((.+?)\)", query.data)
    if match:
        if not support.is_admin(chat_id, user_id, bot):
            bot.answerCallbackQuery(
                text=
                "Solo los administradores del grupo pueden desmutear usuarios.",
                callback_query_id=update.callback_query.id,
                show_alert="true")
            return
        us_id = match.group(1)
        bot.restrict_chat_member(chat_id,
                                 us_id,
                                 can_send_messages=True,
                                 can_send_media_messages=True,
                                 can_send_other_messages=True,
                                 can_add_web_page_previews=True)
        bot.answerCallbackQuery(text="El usuario ha sido desmuteado.",
                                callback_query_id=update.callback_query.id,
                                show_alert="true")
        text = "Usuario desmuteado por @{}.".format(user_username)
        bot.edit_message_text(text=text,
                              chat_id=chat_id,
                              message_id=message_id,
                              parse_mode=telegram.ParseMode.HTML,
                              disable_web_page_preview=True)
        return

    else:
        logging.error('settingsbutton:%s is not a expected settings command',
                      data)
Example #27
0
def nelu_cmd(bot, update, job_queue):
    chat_id, chat_type, user_id, text, message = support.extract_update_info(
        update)
    support.delete_message(chat_id, message.message_id, bot)
    realchat = chat_id

    chat_id = 0
    nelu_id = 0
    a1_object = support.SendContext(chat_id, "60")
    a1time = datetime.now().replace(hour=21, minute=00, second=1)
    job_queue.run_once(support.callback_send, a1time, context=a1_object)
    a1_object = support.SendContext(chat_id, "30")
    a1time = datetime.now().replace(hour=21, minute=30, second=1)

    job_queue.run_once(support.callback_send, a1time, context=a1_object)
    a1_object = support.SendContext(chat_id, "15")
    a1time = datetime.now().replace(hour=21, minute=45, second=1)

    job_queue.run_once(support.callback_send, a1time, context=a1_object)
    a1_object = support.SendContext(chat_id, "14")
    a1time = datetime.now().replace(hour=21, minute=46, second=1)

    job_queue.run_once(support.callback_send, a1time, context=a1_object)
    a1_object = support.SendContext(chat_id, "13")
    a1time = datetime.now().replace(hour=21, minute=47, second=1)

    job_queue.run_once(support.callback_send, a1time, context=a1_object)
    a1_object = support.SendContext(chat_id, "12")
    a1time = datetime.now().replace(hour=21, minute=48, second=1)

    job_queue.run_once(support.callback_send, a1time, context=a1_object)
    a1_object = support.SendContext(chat_id, "11")
    a1time = datetime.now().replace(hour=21, minute=49, second=1)

    job_queue.run_once(support.callback_send, a1time, context=a1_object)
    a1_object = support.SendContext(chat_id, "10")
    a1time = datetime.now().replace(hour=21, minute=50, second=1)

    job_queue.run_once(support.callback_send, a1time, context=a1_object)
    a1_object = support.SendContext(chat_id, "9")
    a1time = datetime.now().replace(hour=21, minute=51, second=1)

    job_queue.run_once(support.callback_send, a1time, context=a1_object)
    a1_object = support.SendContext(chat_id, "8")
    a1time = datetime.now().replace(hour=21, minute=52, second=1)

    job_queue.run_once(support.callback_send, a1time, context=a1_object)
    a1_object = support.SendContext(chat_id, "7")
    a1time = datetime.now().replace(hour=21, minute=53, second=1)

    job_queue.run_once(support.callback_send, a1time, context=a1_object)
    a1_object = support.SendContext(chat_id, "6")
    a1time = datetime.now().replace(hour=21, minute=54, second=1)

    job_queue.run_once(support.callback_send, a1time, context=a1_object)
    a1_object = support.SendContext(chat_id, "5")
    a1time = datetime.now().replace(hour=21, minute=55, second=1)

    job_queue.run_once(support.callback_send, a1time, context=a1_object)
    a1_object = support.SendContext(chat_id, "4")
    a1time = datetime.now().replace(hour=21, minute=56, second=1)

    job_queue.run_once(support.callback_send, a1time, context=a1_object)
    a1_object = support.SendContext(chat_id, "3")
    a1time = datetime.now().replace(hour=21, minute=57, second=1)

    job_queue.run_once(support.callback_send, a1time, context=a1_object)
    a1_object = support.SendContext(chat_id, "2")
    a1time = datetime.now().replace(hour=21, minute=58, second=1)

    job_queue.run_once(support.callback_send, a1time, context=a1_object)
    a1_object = support.SendContext(chat_id, "1")
    a1time = datetime.now().replace(hour=21, minute=59, second=1)

    job_queue.run_once(support.callback_send, a1time, context=a1_object)
    a1_object = support.SendContext(
        chat_id,
        "¡Muchas felicidades @nelulita! 🦉✉️ He mandado una lechuza con una carta para tí , ¿Por qué no le echas un vistazo cuando llegue?"
    )
    a1time = datetime.now().replace(hour=22,
                                    minute=00,
                                    second=0,
                                    microsecond=250000)
    job_queue.run_once(support.callback_send, a1time, context=a1_object)

    a1_object = support.SendContext(
        nelu_id,
        "🦉✉️ Bienvenida de nuevo a Hogwarts @nelulita, me gustaría que nos conociésemos en mi despacho al final del primer día de clases. \nNo olvide que Hagrid la está esperando en la estación. https://t.me/joinchat/H1N0wBeA28423yBKPKBGSA \n\n- Albus Dumbledore"
    )
    a1time = datetime.now().replace(day=12, hour=5, minute=00, second=1)
    job_queue.run_once(support.callback_send, a1time, context=a1_object)
    count = 0
    bot.send_message(chat_id=realchat,
                     text=nelu_json[count]["frase"],
                     reply_markup=InlineKeyboardMarkup([[
                         InlineKeyboardButton(text=nelu_json[count]["button"],
                                              callback_data=f'nelu_{count}')
                     ]]))
Example #28
0
def rem_plant_cmd(bot, update, job_queue, args=None):
    chat_id, chat_type, user_id, text, message = support.extract_update_info(
        update)
    support.delete_message(chat_id, message.message_id, bot)

    if are_banned(chat_id,
                  user_id) or not support.is_admin(chat_id, user_id, bot):
        return

    user = get_real_user(user_id)
    if user is None:
        bot.sendMessage(chat_id=chat_id,
                        text="❌ Debes registrarte para usar este comando.",
                        parse_mode=telegram.ParseMode.MARKDOWN)
        return

    if args is not None and len(args) != 0:
        if re.match(r"^[0-9]{0,10}$", args[0]):
            try:
                alert15PlantJob = job_queue.get_jobs_by_name(
                    "{}_plantJob15".format(args[0]))
                alert15PlantJob[0].schedule_removal()
            except:
                pass
            try:
                alertPlantJob = job_queue.get_jobs_by_name(
                    "{}_plantJob".format(args[0]))
                alertPlantJob[0].schedule_removal()
            except:
                pass
            try:
                deletePlantJob = job_queue.get_jobs_by_name(
                    "{}_plantJobDelete".format(args[0]))
                deletePlantJob[0].schedule_removal()
            except:
                pass

            support.save_jobs(job_queue)

            if delete_plant(plant_id=args[0], group_id=chat_id):
                text = "Plantación eliminada correctamente."
            else:
                text = "❌ No se pudo eliminar la plantación."
            bot.sendMessage(chat_id=chat_id,
                            text=text,
                            parse_mode=telegram.ParseMode.MARKDOWN)
        elif args[0] == "all":
            plants = delete_plant(group_id=chat_id, group=True)
            for plant in plants:
                try:
                    alert15PlantJob = job_queue.get_jobs_by_name(
                        "{}_plantJob15".format(plant.id))
                    alert15PlantJob[0].schedule_removal()
                except:
                    continue
                try:
                    alertPlantJob = job_queue.get_jobs_by_name(
                        "{}_plantJob".format(plant.id))
                    alertPlantJob[0].schedule_removal()
                except:
                    continue
                try:
                    deletePlantJob = job_queue.get_jobs_by_name(
                        "{}_plantJobDelete".format(plant.id))
                    deletePlantJob[0].schedule_removal()
                except:
                    continue

            support.save_jobs(job_queue)
            bot.sendMessage(
                chat_id=chat_id,
                text="Todas las plantaciones eliminadas correctamente.",
                parse_mode=telegram.ParseMode.MARKDOWN)
Example #29
0
def add_ingredients_cmd(bot, update, args=None):
    chat_id, chat_type, user_id, text, message = support.extract_update_info(
        update)
    support.delete_message(chat_id, message.message_id, bot)

    if are_banned(chat_id, user_id):
        return

    user = get_real_user(user_id)
    if user is None:
        bot.sendMessage(chat_id=chat_id,
                        text="❌ Debes registrarte para usar este comando.",
                        parse_mode=telegram.ParseMode.MARKDOWN)
        return

    if args is not None and len(args) > 0:
        if message.reply_to_message is not None:
            if message.reply_to_message.location is not None:
                support.delete_message(chat_id,
                                       message.reply_to_message.message_id,
                                       bot)
                lat = message.reply_to_message.location.latitude
                lon = message.reply_to_message.location.longitude
                reg = re.match(
                    r"(([0-1]?[0-9])|([0-9])|([2][0-3])):([0-5][0-9])",
                    args[0]).group()
                if reg:
                    button_list = [
                        [
                            InlineKeyboardButton(
                                "Ajenjo",
                                callback_data='gh_addplant_1_{0}_{1}'.format(
                                    reg, user_id))
                        ],
                        [
                            InlineKeyboardButton(
                                "Campanilla de invierno",
                                callback_data='gh_addplant_2_{0}_{1}'.format(
                                    reg, user_id))
                        ],
                        [
                            InlineKeyboardButton(
                                "Grano de sopóforo",
                                callback_data='gh_addplant_3_{0}_{1}'.format(
                                    reg, user_id))
                        ],
                        [
                            InlineKeyboardButton(
                                "Raíz de jengibre",
                                callback_data='gh_addplant_4_{0}_{1}'.format(
                                    reg, user_id))
                        ],
                        [
                            InlineKeyboardButton(
                                "Coclearia",
                                callback_data='gh_addplant_5_{0}_{1}'.format(
                                    reg, user_id))
                        ],
                        [
                            InlineKeyboardButton(
                                "Raíz de valeriana",
                                callback_data='gh_addplant_6_{0}_{1}'.format(
                                    reg, user_id))
                        ],
                        [
                            InlineKeyboardButton(
                                "Raíz amarga",
                                callback_data='gh_addplant_7_{0}_{1}'.format(
                                    reg, user_id))
                        ],
                        [
                            InlineKeyboardButton(
                                "Ligústico",
                                callback_data='gh_addplant_8_{0}_{1}'.format(
                                    reg, user_id))
                        ],
                        [
                            InlineKeyboardButton(
                                "Tármica",
                                callback_data='gh_addplant_9_{0}_{1}'.format(
                                    reg, user_id))
                        ],
                        [
                            InlineKeyboardButton(
                                "Hongo saltarín",
                                callback_data='gh_addplant_10_{0}_{1}'.format(
                                    reg, user_id))
                        ],
                        [
                            InlineKeyboardButton(
                                "Cristoforiana",
                                callback_data='gh_addplant_11_{0}_{1}'.format(
                                    reg, user_id))
                        ],
                        [
                            InlineKeyboardButton(
                                "Trompeta de ángel",
                                callback_data='gh_addplant_12_{0}_{1}'.format(
                                    reg, user_id))
                        ],
                        [
                            InlineKeyboardButton(
                                "❌ Cancelar",
                                callback_data='gh_cancel_._._{}'.format(
                                    user_id))
                        ]
                    ]

                    bot.send_venue(
                        chat_id=chat_id,
                        title=reg,
                        address="¿Qué planta hay en el invernadero?",
                        latitude=lat,
                        longitude=lon,
                        reply_markup=InlineKeyboardMarkup(button_list))
Example #30
0
def joined_chat(bot, update, job_queue):
    chat_id, chat_type, user_id, text, message = support.extract_update_info(
        update)
    new_chat_member = message.new_chat_members[
        0] if message.new_chat_members else None

    config = get_config()
    bot_alias = config['telegram']['bot_alias']

    if new_chat_member.username == bot_alias:
        if are_banned(user_id, chat_id):
            bot.leaveChat(chat_id=chat_id)
            return

        chat_title = message.chat.title
        chat_id = message.chat.id
        group = group_sql.get_real_group(chat_id)
        if group is None:
            group_sql.set_group(chat_id, message.chat.title)

        message_text = ("Si necesitais ayuda podéis lanzar chispas rojas c"
                        "on vuestra varita o utilizando el comando `/help`"
                        " para conocer todas las funciones. Aseguraos de v"
                        "er la ayuda para prefectos de los grupos, donde s"
                        "e explica en detalle todos los pasos que se deben"
                        " seguir.".format(escape_markdown(chat_title)))

        admin = get_admin(chat_id)
        if admin is not None and admin.admin_bot is True:
            set_admin_settings(chat_id, "admin_bot")
            message_text = message_text + "\n\n*Fawkes emprendió el vuelo.*"

        bot.sendMessage(chat_id=chat_id,
                        text=message_text,
                        parse_mode=telegram.ParseMode.MARKDOWN)

    elif new_chat_member.username != bot_alias:
        chat_id = message.chat.id
        user_id = update.effective_message.new_chat_members[0].id

        group = get_join_settings(chat_id)
        if group is not None:
            if group.delete_header:
                support.delete_message(chat_id, message.message_id, bot)

            if are_banned(user_id, user_id):
                bot.kickChatMember(chat_id, user_id)
                return

            user = get_user(user_id)
            if user is None and group.requirment is not ValidationRequiered.NO_VALIDATION.value:
                bot.kickChatMember(chat_id=chat_id,
                                   user_id=user_id,
                                   until_date=time.time() + 31)
                if group.val_alert is False:
                    output = "👌 Mago sin registrarse expulsado!"
                    bot.sendMessage(chat_id=chat_id,
                                    text=output,
                                    parse_mode=telegram.ParseMode.MARKDOWN)
                good_luck(bot, chat_id, message,
                          "El usuario no está registrado")
                return

            elif group.requirment is ValidationRequiered.VALIDATION.value and user.level is None:
                bot.kickChatMember(chat_id=chat_id,
                                   user_id=user_id,
                                   until_date=time.time() + 31)
                if group.val_alert is False:
                    output = "👌 Mago infiltrado expulsado!"
                    bot.sendMessage(chat_id=chat_id,
                                    text=output,
                                    parse_mode=telegram.ParseMode.MARKDOWN)
                good_luck(bot, chat_id, message,
                          "El usuario no está registrado")
                try:
                    bot.sendMessage(
                        chat_id=user_id,
                        text="❌ Debes validarte para entrar en este grupo",
                        parse_mode=telegram.ParseMode.MARKDOWN)
                except Exception:
                    pass
                return

            elif group.requirment is ValidationRequiered.PROFESSOR.value and user.profession is not Professions.PROFESSOR.value:
                bot.kickChatMember(chat_id=chat_id,
                                   user_id=user_id,
                                   until_date=time.time() + 31)
                if group.val_alert is False:
                    output = "👌 Mago infiltrado expulsado!"
                    bot.sendMessage(chat_id=chat_id,
                                    text=output,
                                    parse_mode=telegram.ParseMode.MARKDOWN)
                good_luck(bot, chat_id, message,
                          "El usuario no está registrado")
                try:
                    bot.sendMessage(
                        chat_id=user_id,
                        text="❌ Debes validarte para entrar en este grupo",
                        parse_mode=telegram.ParseMode.MARKDOWN)
                except Exception:
                    pass
                return

            elif group.requirment is ValidationRequiered.MAGIZOOLOGIST.value and user.profession is not Professions.MAGIZOOLOGIST.value:
                bot.kickChatMember(chat_id=chat_id,
                                   user_id=user_id,
                                   until_date=time.time() + 31)
                if group.val_alert is False:
                    output = "👌 Mago infiltrado expulsado!"
                    bot.sendMessage(chat_id=chat_id,
                                    text=output,
                                    parse_mode=telegram.ParseMode.MARKDOWN)
                good_luck(bot, chat_id, message,
                          "El usuario no está registrado")
                try:
                    bot.sendMessage(
                        chat_id=user_id,
                        text="❌ Debes validarte para entrar en este grupo",
                        parse_mode=telegram.ParseMode.MARKDOWN)
                except Exception:
                    pass
                return

            elif group.requirment is ValidationRequiered.AUROR.value and user.profession is not Professions.AUROR.value:
                bot.kickChatMember(chat_id=chat_id,
                                   user_id=user_id,
                                   until_date=time.time() + 31)
                if group.val_alert is False:
                    output = "👌 Mago infiltrado expulsado!"
                    bot.sendMessage(chat_id=chat_id,
                                    text=output,
                                    parse_mode=telegram.ParseMode.MARKDOWN)
                good_luck(bot, chat_id, message,
                          "El usuario no está registrado")
                try:
                    bot.sendMessage(
                        chat_id=user_id,
                        text="❌ Debes validarte para entrar en este grupo",
                        parse_mode=telegram.ParseMode.MARKDOWN)
                except Exception:
                    pass
                return

            elif group.requirment is ValidationRequiered.GRYFFINDOR.value and user.house is not Houses.GRYFFINDOR.value:
                bot.kickChatMember(chat_id=chat_id,
                                   user_id=user_id,
                                   until_date=time.time() + 31)
                if group.val_alert is False:
                    output = "👌 Mago infiltrado expulsado!"
                    bot.sendMessage(chat_id=chat_id,
                                    text=output,
                                    parse_mode=telegram.ParseMode.MARKDOWN)
                good_luck(bot, chat_id, message,
                          "El usuario no está registrado")
                try:
                    bot.sendMessage(
                        chat_id=user_id,
                        text="❌ Debes validarte para entrar en este grupo",
                        parse_mode=telegram.ParseMode.MARKDOWN)
                except Exception:
                    pass
                return

            elif group.requirment is ValidationRequiered.HUFFLEPUFF.value and user.house is not Houses.HUFFLEPUFF.value:
                bot.kickChatMember(chat_id=chat_id,
                                   user_id=user_id,
                                   until_date=time.time() + 31)
                if group.val_alert is False:
                    output = "👌 Mago infiltrado expulsado!"
                    bot.sendMessage(chat_id=chat_id,
                                    text=output,
                                    parse_mode=telegram.ParseMode.MARKDOWN)
                good_luck(bot, chat_id, message,
                          "El usuario no está registrado")
                try:
                    bot.sendMessage(
                        chat_id=user_id,
                        text="❌ Debes validarte para entrar en este grupo",
                        parse_mode=telegram.ParseMode.MARKDOWN)
                except Exception:
                    pass
                return

            elif group.requirment is ValidationRequiered.RAVENCLAW.value and user.house is not Houses.RAVENCLAW.value:
                bot.kickChatMember(chat_id=chat_id,
                                   user_id=user_id,
                                   until_date=time.time() + 31)
                if group.val_alert is False:
                    output = "👌 Mago infiltrado expulsado!"
                    bot.sendMessage(chat_id=chat_id,
                                    text=output,
                                    parse_mode=telegram.ParseMode.MARKDOWN)
                good_luck(bot, chat_id, message,
                          "El usuario no está registrado")
                try:
                    bot.sendMessage(
                        chat_id=user_id,
                        text="❌ Debes validarte para entrar en este grupo",
                        parse_mode=telegram.ParseMode.MARKDOWN)
                except Exception:
                    pass
                return

            elif group.requirment is ValidationRequiered.SLYTHERIN.value and user.house is not Houses.SLYTHERIN.value:
                bot.kickChatMember(chat_id=chat_id,
                                   user_id=user_id,
                                   until_date=time.time() + 31)
                if group.val_alert is False:
                    output = "👌 Mago infiltrado expulsado!"
                    bot.sendMessage(chat_id=chat_id,
                                    text=output,
                                    parse_mode=telegram.ParseMode.MARKDOWN)
                good_luck(bot, chat_id, message,
                          "El usuario no está registrado")
                try:
                    bot.sendMessage(
                        chat_id=user_id,
                        text="❌ Debes validarte para entrar en este grupo",
                        parse_mode=telegram.ParseMode.MARKDOWN)
                except Exception:
                    pass
                return

            if group.max_members is not None and group.max_members > 0 and bot.get_chat_members_count(
                    chat_id) >= group.max_members:
                if group.val_alert is False:
                    output = "❌ El número máximo de integrantes en el grupo ha sido alcanzado"
                    sent = bot.sendMessage(
                        chat_id=chat_id,
                        text=output,
                        parse_mode=telegram.ParseMode.MARKDOWN)
                    delete_object = support.DeleteContext(
                        chat_id, sent.message_id)
                    job_queue.run_once(support.callback_delete,
                                       10,
                                       context=delete_object)
                time.sleep(2)
                bot.kickChatMember(chat_id=chat_id,
                                   user_id=user_id,
                                   until_date=time.time() + 31)
                return

            if (not exists_user_group(user_id, chat_id)):
                set_user_group(user_id, chat_id)
            else:
                join_group(user_id, chat_id)

            if has_rules(chat_id):
                bot.restrict_chat_member(chat_id,
                                         user_id,
                                         until_date=0,
                                         can_send_messages=False,
                                         can_send_media_messages=False,
                                         can_send_other_messages=False,
                                         can_add_web_page_previews=False)

            if get_welc_pref(chat_id):
                sent = send_welcome(bot, update)
                if sent is not None and group.delete_cooldown is not None and group.delete_cooldown > 0:
                    delete_object = support.DeleteContext(
                        chat_id, sent.message_id)
                    job_queue.run_once(support.callback_delete,
                                       group.delete_cooldown,
                                       context=delete_object)
            '''
            if group.val_alert and (user is None or user.level is None):
                sent = bot.sendMessage(
                    chat_id=chat_id,
                    text="",
                    parse_mode=telegram.ParseMode.MARKDOWN
                )
                if sent is not None:
                    delete_object = support.DeleteContext(chat_id, sent.message_id)
                    job_queue.run_once(
                        support.callback_delete, 
                        group.delete_cooldown or 60,
                        context=delete_object
                    )
            '''
            ladmin = get_particular_admin(chat_id)
            if ladmin is not None and ladmin.welcome:
                admin = get_admin_from_linked(chat_id)
                if admin is not None and admin.welcome and admin.admin_bot:
                    config = get_config()
                    adm_bot = Bot(token=config["telegram"]["admin_token"])
                    replace_pogo = support.replace(
                        user_id, message.from_user.first_name, admin=True)
                    message_text = (
                        "ℹ️ {}\n👤 {} ha entrado en el grupo").format(
                            message.chat.title, replace_pogo)
                    adm_bot.sendMessage(chat_id=admin.id,
                                        text=message_text,
                                        parse_mode=telegram.ParseMode.MARKDOWN)
                elif admin is not None and admin.welcome:
                    replace_pogo = support.replace(
                        user_id, message.from_user.first_name, admin=True)
                    message_text = (
                        "ℹ️ {}\n👤 {} ha entrado en el grupo").format(
                            message.chat.title, replace_pogo)
                    bot.sendMessage(chat_id=admin.id,
                                    text=message_text,
                                    parse_mode=telegram.ParseMode.MARKDOWN)