def list_pics(bot, update, args): logging.debug("%s %s" % (bot, update)) chat_id, chat_type, user_id, text, message = extract_update_info(update) output = "Listado de tablas:" count = 0 if args is None or len(args) != 1: for k in __TABLAS_JSON["tablas"]: count = count + 1 output = output + "\n\nTitle: {1}\nKeywords: {2}\nID: `{0}`".format( k["id"], k["name"], k["keywords"]) if count == 5: bot.sendMessage(chat_id=chat_id, text=output, parse_mode=telegram.ParseMode.MARKDOWN) count = 0 output = "" else: for k in __TABLAS_JSON["tablas"]: if args[0] in k["keywords"]: count = count + 1 output = output + "\n\nTitle: {1}\nKeywords: {2}\nID: `{0}`".format( k["id"], k["name"], k["keywords"]) if count == 5: bot.sendMessage(chat_id=chat_id, text=output, parse_mode=telegram.ParseMode.MARKDOWN) count = 0 output = "" if count != 0: bot.sendMessage(chat_id=chat_id, text=output, parse_mode=telegram.ParseMode.MARKDOWN)
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)
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")
def potato_process(bot, update): (chat_id, chat_type, user_id, text, message) = support.extract_update_info(update) if (chat_type == "private"): bot.sendMessage( chat_id=chat_id, text='🥔')
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)
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
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)
def whosaid_cmd(bot, update): chat_id, chat_type, user_id, text, message = support.extract_update_info( update) question = randint(0, len(who_json) - 1) b1 = "g*whosaid_success" b2 = "g*whosaid_fail" b3 = "g*whosaid_fail" b4 = "g*whosaid_fail" markup = [[ InlineKeyboardButton(text=who_json[question]["reply"], callback_data=b1) ], [ InlineKeyboardButton(text=who_json[question]["others"][0], callback_data=b2) ], [ InlineKeyboardButton(text=who_json[question]["others"][1], callback_data=b3) ], [ InlineKeyboardButton(text=who_json[question]["others"][2], callback_data=b4) ]] shuffle(markup) bot.sendMessage(chat_id=chat_id, text='Quién dijo...\n\n"' + who_json[question]["question"] + '"\n\n', disable_notification=True, reply_markup=InlineKeyboardMarkup(markup))
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 send_news(bot, update): chat_id, chat_type, user_id, text, message = support.extract_update_info( update) if chat_type != "channel": return if not news_sql.is_news_provider(chat_id): return time.sleep(60) groups = news_sql.get_news_consumers(chat_id) if groups is None: return exceptions_users = [] for k in groups: time.sleep(0.2) try: bot.forwardMessage(chat_id=k.user_id, from_chat_id=chat_id, message_id=message.message_id) except Exception: exceptions_users.append(k.user_id) logging.info('sendingMessageTo:FAILURE->: %s', k.user_id) for k in exceptions_users: news_sql.rm_all_news_subscription(k)
def grag_cmd(bot, update): chat_id, chat_type, user_id, text, message = support.extract_update_info( update) colours = [] for k in range(5): colour = get_gragea_colour(colours) colours.append(colour) sel1 = colours[0] sel2 = colours[1] sel3 = colours[2] sel4 = colours[3] sel5 = colours[4] b1 = "g*gra_" + sel1 + "_" + sel1 + "_" + sel2 + "_" + sel3 + "_" + sel4 + "_" + sel5 b2 = "g*gra_" + sel2 + "_" + sel1 + "_" + sel2 + "_" + sel3 + "_" + sel4 + "_" + sel5 b3 = "g*gra_" + sel3 + "_" + sel1 + "_" + sel2 + "_" + sel3 + "_" + sel4 + "_" + sel5 b4 = "g*gra_" + sel4 + "_" + sel1 + "_" + sel2 + "_" + sel3 + "_" + sel4 + "_" + sel5 b5 = "g*gra_" + sel5 + "_" + sel1 + "_" + sel2 + "_" + sel3 + "_" + sel4 + "_" + sel5 texto = "Alguien ha abierto una bolsa de grageas de todos los sabores. ¿Quieres una?" markup = [[InlineKeyboardButton(text=sel1, callback_data=b1)], [InlineKeyboardButton(text=sel2, callback_data=b2)], [InlineKeyboardButton(text=sel3, callback_data=b3)], [InlineKeyboardButton(text=sel4, callback_data=b4)], [InlineKeyboardButton(text=sel5, callback_data=b5)]] bot.sendMessage(chat_id=chat_id, text=texto, disable_notification=True, reply_markup=InlineKeyboardMarkup(markup))
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)
def whosaid_cmd(bot, update): try: chat_id, chat_type, user_id, text, message = support.extract_update_info(update) except: 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 question = randint(0, len(who_json)-1) b1 = "g*whosaid_success" b2 = "g*whosaid_fail" b3 = "g*whosaid_fail" b4 = "g*whosaid_fail" markup = [ [InlineKeyboardButton(text=who_json[question]["reply"], callback_data=b1)], [InlineKeyboardButton(text=who_json[question]["others"][0], callback_data=b2)], [InlineKeyboardButton(text=who_json[question]["others"][1], callback_data=b3)], [InlineKeyboardButton(text=who_json[question]["others"][2], callback_data=b4)]] shuffle(markup) bot.sendMessage( chat_id=chat_id, text='Quién dijo...\n\n"' + who_json[question]["question"] + '"\n\n', disable_notification=True, reply_markup=InlineKeyboardMarkup(markup))
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))
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.")
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." )
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)
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)
def new_pic(bot, update, args=None): logging.debug("%s %s" % (bot, update)) chat_id, chat_type, user_id, text, message = extract_update_info(update) if args is None or len(args) < 3: return if message.reply_to_message is None or message.reply_to_message.photo is None: return with open('/var/local/profdumbledore/json/tablas.json') as f: data = json.load(f) name = "" while args[0] != "-": name = name + args[0] del args[0] del args[0] tabla_id = "{}".format(uuid4()) data['tablas'].insert( 0, { "id": tabla_id, "name": name, "file_id": update.message.reply_to_message.photo[-1]["file_id"], "keywords": args }) with open('/var/local/profdumbledore/json/tablas.json', 'w') as outfile: json.dump(data, outfile) reload_tablas() output = "Nueva tabla añadida.\nID: `{}`\nNombre: *{}*".format( tabla_id, name) txt = name.replace(" ", "_") keyboard = [[ InlineKeyboardButton(text="✅ Si", callback_data='tabla_new_{}'.format(txt)), InlineKeyboardButton(text="❌ No", callback_data='tabla_rm') ]] reply_markup = InlineKeyboardMarkup(keyboard) bot.sendMessage(chat_id=chat_id, text=output, reply_markup=reply_markup, parse_mode=telegram.ParseMode.MARKDOWN)
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)
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)
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")
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))
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))
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)
def set_nanny(bot, update, args=None): chat_id, chat_type, user_id, text, message = support.extract_update_info( update) chat = update.effective_chat user = update.effective_user msg = update.effective_message if not support.is_admin(chat_id, user_id, bot): return args = msg.text.split(None, 1) if len(args) >= 2: offset = len(args[1]) - len(msg.text) text, buttons = support.button_markdown_parser( args[1], entities=msg.parse_entities(), offset=offset) set_nanny_reply(chat_id, text) msg.reply_text("Mensaje del modo biblioteca guardado correctamente") else: set_nanny_reply(chat_id, None) msg.reply_text("Mensaje del modo biblioteca por defecto activado")
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)
def games_cmd(bot, update): (chat_id, chat_type, user_id, text, message) = support.extract_update_info(update) if are_banned(user_id, chat_id): return group_message_counter(chat_id) cfg = config.get_config() if chat_id != int(cfg["telegram"]["spain_id"]): return user = get_user(user_id) if user is None: return if last_run(chat_id, 'games'): return if (group_message_counter(chat_id, read_only=True) is randrange(40, 70)) or (group_message_counter(chat_id, read_only=True) >= 70): group_message_counter(chat_id, reset=True) game_list = [grag_cmd, whosaid_cmd] choice(game_list)(bot, update)
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)