示例#1
0
def set_welcome(bot, update):
    chat_id, chat_type, user_id, text, message = support.extract_update_info(
        update)
    text, data_type, content, buttons = support.get_welcome_type(message)

    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 data_type is None:
        set_welc_preference(chat_id, False)
        bot.sendMessage(
            chat_id=chat_id,
            text="👌 Mensaje de bienvenida desactivado correctamente")
        return

    set_welc_preference(chat_id, True)
    set_custom_welcome(chat_id, content or text, data_type, buttons)
    bot.sendMessage(chat_id=chat_id,
                    text="👌 Mensaje de bienvenida guardado correctamente")
示例#2
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
示例#3
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
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))
示例#5
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."
        )
示例#6
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")
示例#7
0
def gh_btn(bot, update, job_queue):
    query = update.callback_query
    data = query.data
    user = update.effective_user
    user_id = query.from_user.id
    text = query.message.text
    chat_id = query.message.chat.id
    message_id = query.message.message_id
    name = query.message.venue.title
    lat = query.message.location.latitude
    lon = query.message.location.longitude
    coords = str(lat) + ", " + str(lon)

    if are_banned(user_id, chat_id):
        return

    queryData = data.split("_")
    userBtn = queryData[4]

    if userBtn == str(user_id) or support.is_admin(chat_id, user_id, bot):
        if queryData[1] == "addplant":
            bot.delete_message(chat_id=chat_id, message_id=message_id)

            poi_list = get_poi_list(chat_id, PortalType.GREENHOUSE.value)
            poi_sorted = sort_list(poi_list, coords)

            button_list = []
            if len(poi_sorted) >= 1:
                button_list.append([
                    InlineKeyboardButton(
                        poi_sorted[0].name,
                        callback_data='gh_addubi_{0}_{1}_{2}_{3}'.format(
                            poi_sorted[0].id, queryData[2], user_id,
                            queryData[3]))
                ])
            if len(poi_sorted) >= 2:
                button_list.append([
                    InlineKeyboardButton(
                        poi_sorted[1].name,
                        callback_data='gh_addubi_{0}_{1}_{2}_{3}'.format(
                            poi_sorted[1].id, queryData[2], user_id,
                            queryData[3]))
                ])
            if len(poi_sorted) >= 3:
                button_list.append([
                    InlineKeyboardButton(
                        poi_sorted[2].name,
                        callback_data='gh_addubi_{0}_{1}_{2}_{3}'.format(
                            poi_sorted[2].id, queryData[2], user_id,
                            queryData[3]))
                ])
            if len(poi_sorted) >= 4:
                button_list.append([
                    InlineKeyboardButton(
                        poi_sorted[3].name,
                        callback_data='gh_addubi_{0}_{1}_{2}_{3}'.format(
                            poi_sorted[3].id, queryData[2], user_id,
                            queryData[3]))
                ])
            if len(poi_sorted) >= 5:
                button_list.append([
                    InlineKeyboardButton(
                        poi_sorted[4].name,
                        callback_data='gh_addubi_{0}_{1}_{2}_{3}'.format(
                            poi_sorted[4].id, queryData[2], user_id,
                            queryData[3]))
                ])
            button_list.append([
                InlineKeyboardButton(
                    "❌ Cancelar",
                    callback_data='gh_cancel_._._{}'.format(user_id))
            ])

            plant = support.replace_plants(int(queryData[2]))

            bot.send_venue(chat_id=chat_id,
                           title=plant + " " + queryData[3],
                           address="¿En qué invernadero está plantado?",
                           latitude=lat,
                           longitude=lon,
                           reply_markup=InlineKeyboardMarkup(button_list))
            return
        elif queryData[1] == "addubi":
            userTime = datetime.strptime(queryData[5], '%H:%M')

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

            userDatetime = datetime.now().replace(hour=userTime.hour,
                                                  minute=userTime.minute,
                                                  second=0)
            userAsLocal = tz.localize(userDatetime)
            userAsLocal = userAsLocal.astimezone(pytz.utc)
            '''
            if datetime.now(pytz.utc) > userAsLocal:
                userAsLocal = userAsLocal + timedelta(days=1)
            '''

            userAsLocal15 = userAsLocal - timedelta(minutes=15)
            userAsLocalDeletePlant = userAsLocal + timedelta(minutes=30)
            userAsLocal15 = userAsLocal15.time()
            userAsLocalTime = userAsLocal.time()
            userAsLocalDPTime = userAsLocalDeletePlant.time()

            plant = support.replace_plants(int(queryData[3]))

            setPlant = set_plant(queryData[2], queryData[3], chat_id,
                                 userDatetime, userAsLocalDeletePlant)
            thePlant = get_plant(setPlant)

            poi = get_poi(queryData[2])
            ap_object = support.AlertPlantContext(
                chat_id,
                "¡Magos de *{0}*, en 15 minutos se podrá recoger *{1}* en [{2}](https://maps.google.com/maps?q={3},{4})!"
                .format(query.message.chat.title, plant, poi.name,
                        poi.latitude, poi.longitude), False, thePlant.id)
            job_queue.run_once(support.callback_AlertPlant,
                               userAsLocal15,
                               context=ap_object,
                               name="{}_plantJob15".format(thePlant.id))

            ap_object = support.AlertPlantContext(
                chat_id,
                "¡Magos de *{0}*, ya se puede recoger *{1}* en [{2}](https://maps.google.com/maps?q={3},{4})!"
                .format(query.message.chat.title, plant, poi.name,
                        poi.latitude, poi.longitude), True, thePlant.id)
            job_queue.run_once(support.callback_AlertPlant,
                               userAsLocalTime,
                               context=ap_object,
                               name="{}_plantJob".format(thePlant.id))
            dp_object = support.DeletePlantContext(thePlant.id)
            job_queue.run_once(support.callback_DeletePlant,
                               userAsLocalDPTime,
                               context=dp_object,
                               name="{}_plantJobDelete".format(thePlant.id))

            bot.delete_message(chat_id=chat_id, message_id=message_id)
            success_message = bot.sendMessage(
                chat_id=chat_id,
                text="🌱 Plantación añadida correctamente.",
                parse_mode=telegram.ParseMode.MARKDOWN)
            delete_object = support.DeleteContext(chat_id,
                                                  success_message.message_id)
            job_queue.run_once(support.callback_delete,
                               10,
                               context=delete_object)
            support.save_jobs(job_queue)
            return
        elif queryData[1] == "cancel":
            bot.delete_message(chat_id=chat_id, message_id=message_id)
            return
    else:
        bot.answer_callback_query(
            callback_query_id=query.id,
            text=
            "Sólo un administrador o el usuario que ha creado el aviso puede pulsar ese botón.",
            show_alert=True)
示例#8
0
def process_group_message(bot, update, job_queue):
    chat_id, chat_type, user_id, text, message = support.extract_update_info(
        update)
    msg = update.effective_message

    if are_banned(user_id, chat_id):
        return

    group = group_sql.get_group(chat_id)
    if group is None:
        group_sql.set_group(chat_id, message.chat.title)
    if not exists_user_group(user_id, chat_id):
        set_user_group(user_id, chat_id)

    message_counter(user_id, chat_id)
    if get_group_settings(chat_id).games == True and (chat_type == 'supergroup'
                                                      or chat_type == 'group'):
        games_cmd(bot, update)

    if text is None or msg.photo is None:
        if msg and msg.document:
            nanny.process_gif(bot, update, job_queue)
            return
        elif msg and msg.contact:
            nanny.process_contact(bot, update, job_queue)
            return
        elif msg and msg.game:
            nanny.process_game(bot, update, job_queue)
            return
        elif msg and msg.location or msg.venue:
            nanny.process_ubi(bot, update, job_queue)
            return
        elif msg and msg.photo:
            nanny.process_pic(bot, update, job_queue)
            return
        elif msg and msg.sticker:
            nanny.process_sticker(bot, update, job_queue)
            return
        elif msg and msg.voice or msg.audio:
            nanny.process_voice(bot, update, job_queue)
            return
        elif msg and msg.video or msg.video_note:
            nanny.process_video(bot, update, job_queue)
            return

    if msg and msg.entities and nanny.process_url(bot, update, job_queue):
        return

    if nanny.nanny_text(bot, user_id, chat_id, message, job_queue):
        return

    if text is not None and re.search("@admin(?!\w)", text) is not None:
        replace_pogo = support.replace(user_id,
                                       message.from_user.first_name,
                                       admin=True)

        chat_text = support.message_url(message, message.message_id,
                                        message.chat.title)

        message_text = (
            "ℹ️ {}\n👤 {} ha enviado una alerta a los administradores\n\nMensaje: {}"
        ).format(chat_text, replace_pogo, text)
        for admin in bot.get_chat_administrators(chat_id):
            user = get_user(admin.user.id)
            if user is not None and user.alerts:
                bot.sendMessage(chat_id=admin.user.id,
                                text=message_text,
                                parse_mode=telegram.ParseMode.MARKDOWN,
                                disable_web_page_preview=True)
        ladmin = get_particular_admin(chat_id)
        if ladmin is not None and ladmin.admin:
            admin = get_admin_from_linked(chat_id)
            if admin is not None and admin.admin 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👤 {} {}").format(
                    chat_text, replace_pogo, text)
                adm_bot.sendMessage(chat_id=admin.id,
                                    text=message_text,
                                    parse_mode=telegram.ParseMode.MARKDOWN,
                                    disable_web_page_preview=True)
            elif admin is not None and admin.admin:
                replace_pogo = support.replace(user_id,
                                               message.from_user.first_name,
                                               admin=True)
                message_text = ("ℹ️ {}\n👤 {} {}").format(
                    chat_text, replace_pogo, text)
                bot.sendMessage(chat_id=admin.id,
                                text=message_text,
                                parse_mode=telegram.ParseMode.MARKDOWN,
                                disable_web_page_preview=True)
def sighting_btn(bot, update):
    query = update.callback_query
    data = query.data
    user = update.effective_user
    username = query.from_user.username
    user_id = query.from_user.id
    text = query.message.text
    chat_id = query.message.chat.id
    message_id = query.message.message_id
    dataThings = data.split("_")
    lat = dataThings[2]
    lon = dataThings[3]

    if are_banned(user_id, chat_id):
        return

    user = get_user(user_id)

    if user is None:
        bot.answer_callback_query(
            query.id,
            "❌ Debes registrarte para usar esta función.",
            show_alert=True)
        return

    if re.match(r"^sighting_ubi_", data):
        bot.send_location(
            chat_id=user_id,
            latitude=lat,
            longitude=lon,
            reply_markup=InlineKeyboardMarkup([[
                InlineKeyboardButton(
                    text="📍 Google Maps",
                    url='https://maps.google.com/maps?q={0},{1}'.format(
                        lat, lon))
            ]]))
        return

    string = r'\n🕚 (\d\d:\d\d) - @{} \| (🙋‍♀️ ¡Está!|🙅‍♀️ No está...)'.format(
        username)
    text = re.sub(string, "", text)

    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()

    if re.match(r"^sighting_yes_", data):
        text = text + f"\n🕚 {groupTime.hour:02}:{groupTime.minute:02} - @{username} | 🙋‍♀️ ¡Está!"

    if re.match(r"^sighting_no_", data):
        text = text + f"\n🕚 {groupTime.hour:02}:{groupTime.minute:02} - @{username} | 🙅‍♀️ No está..."

    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))
        ]
    ]

    bot.edit_message_text(text=text,
                          chat_id=chat_id,
                          message_id=message_id,
                          reply_markup=InlineKeyboardMarkup(button_list),
                          disable_web_page_preview=True)
示例#10
0
def fort_btn(bot, update, job_queue):
    query = update.callback_query
    data = query.data
    user = update.effective_user
    username = query.from_user.username
    user_id = query.from_user.id
    text = query.message.text
    chat_id = query.message.chat.id
    message_id = query.message.message_id
    message = query.message
    markdown_text = query.message.text_markdown_urled

    if are_banned(user_id, chat_id):
        return

    user = get_user(user_id)
    if user is None:
        bot.answer_callback_query(
            query.id,
            "❌ Debes registrarte para usar esta función.",
            show_alert=True)
        return

    queryData = data.split("_")

    if len(queryData) == 5:
        if queryData[3] == str(user_id) or support.is_admin(
                chat_id, user_id, bot):
            if queryData[1] == "addubi":
                group = get_group(chat_id)
                group_tz = group.timezone
                tz = pytz.timezone(group_tz)

                try:
                    userTime = datetime.strptime(queryData[4], '%d/%H:%M')
                    userDatetime = datetime.now().replace(
                        day=userTime.day,
                        hour=userTime.hour,
                        minute=userTime.minute,
                        second=0)
                    dateText = f"el *{userDatetime.day}/{userDatetime.month}* a las *{userDatetime.hour:02}:{userDatetime.minute:02}*"
                except:
                    userTime = datetime.strptime(queryData[4], '%H:%M')
                    userDatetime = datetime.now().replace(
                        hour=userTime.hour, minute=userTime.minute, second=0)
                    dateText = f"a las *{userDatetime.hour:02}:{userDatetime.minute:02}*"

                userAsLocal = tz.localize(userDatetime)
                userAsLocal = userAsLocal.astimezone(pytz.utc)

                if datetime.now(pytz.utc) > userAsLocal:
                    userAsLocal = userAsLocal + timedelta(days=1)
                    userDatetime = userDatetime + timedelta(days=1)
                    dateText = f"el *{userDatetime.day}/{userDatetime.month}* a las *{userDatetime.hour:02}:{userDatetime.minute:02}*"

                userAsLocal30 = userAsLocal - timedelta(minutes=30)
                #userAsLocal30 = userAsLocal30.time()
                #userAsLocalTime = userAsLocal.time()

                userAsLocal = userAsLocal.replace(tzinfo=None)

                poi = get_poi(queryData[2])
                lat = poi.latitude
                lon = poi.longitude

                button_list = [[
                    (InlineKeyboardButton("🙋‍♀️ Voy",
                                          callback_data=f'fort_yes_{poi.id}')),
                    (InlineKeyboardButton(
                        "🕒 Tardo", callback_data=f'fort_late_{poi.id}')),
                    (InlineKeyboardButton("❌ No voy",
                                          callback_data=f'fort_no_{poi.id}'))
                ],
                               [(InlineKeyboardButton(
                                   "✅ Estoy",
                                   callback_data=f'fort_here_{poi.id}')),
                                (InlineKeyboardButton(
                                    "📍 Ubicación",
                                    callback_data=f'fort_ubi_{poi.id}')),
                                (InlineKeyboardButton(
                                    "⚠️ Aviso",
                                    callback_data=f'fort_alert_{poi.id}'))]]

                text = "Fortaleza en [{0}](https://maps.google.com/maps?q={1},{2}) {3}\n\nLista:".format(
                    poi.name, lat, lon, dateText)

                fort_msg = bot.sendMessage(
                    chat_id=chat_id,
                    text=text,
                    parse_mode=telegram.ParseMode.MARKDOWN,
                    disable_web_page_preview=True,
                    reply_markup=InlineKeyboardMarkup(button_list))

                chat_url = support.message_url(message, fort_msg.message_id,
                                               "desafío")

                f_object = support.AlertFortressContext(
                    chat_id,
                    f"¡Mago de *{message.chat.title}*, en 30 minutos tendrá lugar un {chat_url} que pondrá a prueba tus habilidades como mago en [{poi.name}](https://maps.google.com/maps?q={lat},{lon})!",
                    fort_msg.message_id, poi.id)
                job_queue.run_once(support.callback_AlertFortress,
                                   userAsLocal,
                                   context=f_object)

                support.save_jobs(job_queue)

                bot.delete_message(chat_id=chat_id, message_id=message_id)
                return

        else:
            bot.answer_callback_query(
                callback_query_id=query.id,
                text=
                "Sólo un administrador o el usuario que ha creado el aviso puede pulsar ese botón.",
                show_alert=True)
            return
    if queryData[1] == "cancel":
        if queryData[2] == str(user_id) or support.is_admin(
                chat_id, user_id, bot):
            bot.delete_message(chat_id=chat_id, message_id=message_id)
            return
        else:
            bot.answer_callback_query(
                callback_query_id=query.id,
                text=
                "Sólo un administrador o el usuario que ha creado el aviso puede pulsar ese botón.",
                show_alert=True)
            return

    poi_id = queryData[2]
    poi = get_poi(poi_id)
    lat = poi.latitude
    lon = poi.longitude

    button_list = [
        [(InlineKeyboardButton("🙋‍♀️ Voy",
                               callback_data=f'fort_yes_{poi.id}')),
         (InlineKeyboardButton("🕒 Tardo",
                               callback_data=f'fort_late_{poi.id}')),
         (InlineKeyboardButton("❌ No voy",
                               callback_data=f'fort_no_{poi.id}'))],
        [(InlineKeyboardButton("✅ Estoy",
                               callback_data=f'fort_here_{poi.id}')),
         (InlineKeyboardButton("📍 Ubicación",
                               callback_data=f'fort_ubi_{poi.id}')),
         (InlineKeyboardButton("⚠️ Aviso",
                               callback_data=f'fort_alert_{poi.id}'))]
    ]

    string = r'\n(🙋‍♀️|✅|🕒|❌) 🧙(\d|\d\d|\?\?) (🍮|⚔|🐾|📚)(\d|\d\d|\?\?) @{}'.format(
        username)

    if queryData[1] == "ubi":
        bot.send_venue(
            chat_id=user_id,
            title=poi.name,
            address=" ",
            latitude=lat,
            longitude=lon,
            reply_markup=InlineKeyboardMarkup([[
                InlineKeyboardButton(
                    text="📍 Google Maps",
                    url='https://maps.google.com/maps?q={0},{1}'.format(
                        lat, lon))
            ]]))
        return
    elif queryData[1] == "alert":
        if last_run(
                str(user_id) + str(chat_id) + str(message_id), 'fort_alert'):
            bot.answer_callback_query(
                callback_query_id=query.id,
                text=
                "Ya has enviado un ⚠️ Aviso, espera un rato para enviar otro.",
                show_alert=True)
            return
        if re.search(string, markdown_text):
            ent = message.parse_entities(["mention"])
            chat_url = support.message_url(message, message_id, "fortaleza")
            for mention in ent:
                username = message.parse_entity(mention)
                string = r'\n(🙋‍♀️|✅|🕒|❌) 🧙(\d|\d\d|\?\?) (🍮|⚔|🐾|📚)(\d|\d\d|\?\?) {}'.format(
                    username)
                search = re.search(string, markdown_text)
                if search.group(1) == "❌":
                    continue
                user = get_user_by_name(username[1:])
                btn_user = get_user(user_id)
                bot.sendMessage(
                    chat_id=user.id,
                    text=
                    f"Alerta para la {chat_url} en [{poi.name}](https://maps.google.com/maps?q={lat},{lon}) enviada por @{btn_user.alias}",
                    parse_mode=telegram.ParseMode.MARKDOWN,
                    disable_web_page_preview=True)
            bot.answer_callback_query(
                callback_query_id=query.id,
                text=
                "⚠️ Aviso enviado a todos los magos apuntados en la lista.",
                show_alert=True)
        else:
            bot.answer_callback_query(
                query.id,
                "❌ Debes apuntarte para poder enviar una alerta.",
                show_alert=True)
        return

    markdown_text = re.sub(string, "", markdown_text)

    if user is None or user.profession is Professions.NONE.value:
        text_prof = "🍮"
    elif user.profession is Professions.AUROR.value:
        text_prof = "⚔"
    elif user.profession is Professions.MAGIZOOLOGIST.value:
        text_prof = "🐾"
    elif user.profession is Professions.PROFESSOR.value:
        text_prof = "📚"

    text_level = ("{}".format(user.level) if user and user.level else "??")
    text_profession_level = ("{}".format(user.profession_level)
                             if user and user.profession_level else "??")

    if queryData[1] == "yes":
        text = markdown_text + f"\n🙋‍♀️ 🧙{text_level} {text_prof}{text_profession_level} @{username}"
    elif queryData[1] == "here":
        text = markdown_text + f"\n✅ 🧙{text_level} {text_prof}{text_profession_level} @{username}"
    elif queryData[1] == "late":
        text = markdown_text + f"\n🕒 🧙{text_level} {text_prof}{text_profession_level} @{username}"
    elif queryData[1] == "no":
        text = markdown_text + f"\n❌ 🧙{text_level} {text_prof}{text_profession_level} @{username}"

    bot.edit_message_text(text=text,
                          chat_id=chat_id,
                          message_id=message_id,
                          parse_mode=telegram.ParseMode.MARKDOWN,
                          reply_markup=InlineKeyboardMarkup(button_list),
                          disable_web_page_preview=True)