this is my code, it works perfectly except last if statement. i want to when the list members become 0 the bot send this message: "No One"
this code work perfectly,when the list reaches 2 bot say: fix. but when it reaches 0 it doesnt say anything!
from telegram.ext import Updater , CommandHandler , Filters ,
CommandHandler , MessageHandler
from telegram import MessageEntity
from telegram import ParseMode , InputTextMessageContent
updater = Updater("989165404:AAF8DEjyunwrb88-1G8w62cGItzXj1J618g")
list = []
wordsm=["m"]
wordsn=["n"]
def msg_filter(bot , update):
if any (i in update.message.text for i in wordsm):
list.append("{}".format(update.message.from_user.first_name))
bot.send_message(chat_id = update.message.chat_id , text =
"\n".join(list))
if len(list)==2:
bot.send_message(chat_id = update.message.chat_id , text = "FiX!")
if any (j in update.message.text for j in wordsn):
list.remove("{}".format(update.message.from_user.first_name))
bot.send_message(chat_id = update.message.chat_id , text =
"\n".join(list))
if len(list)==0:
bot.send_message(chat_id = update.message.chat_id , text = "No
One")
print(list)
print(len(list))
updater.dispatcher.add_handler(MessageHandler(Filters.text
,msg_filter ))
updater.start_polling()
Aucun commentaire:
Enregistrer un commentaire