在Python中接收电报机器人输入的消息
我正在尝试创建一个接收某些应用程序名称作为输入的机器人,并告诉您是否已下载它们。如果未下载它们,它们将包含在列表中,以后可以使用特定命令查看。对机器人来说是新手,我对这个主题一无所知,您能帮我吗? 非常感谢,这是我的脚本:
from email import message
from telegram.ext.updater import Updater
from telegram.update import Update
from telegram.ext.callbackcontext import CallbackContext
from telegram.ext.commandhandler import CommandHandler
from telegram.ext.messagehandler import MessageHandler
from telegram.ext.filters import Filters
updater = Updater("TOKEN", use_context=True)
def start(update: Update, context: CallbackContext):
update.message.reply_text(
"Benvenuto al bot per ricordare i nomi delle app fatte")
def help(update: Update, context: CallbackContext):
update.message.reply_text("Your Message")
def app_fatte_mamma(update: Update, context: CallbackContext):
update.message.reply_text("Come si chiama l'app che hai appena fatto?")
app_mamma=[""]
updater.dispatcher.add_handler(MessageHandler(update.message.text))
if not update.message.text in app_mamma:
app_mamma.append(update.message.text)
update.message.reply_text("Ho inserito l'app nell'elenco")
else:
update.message.reply_text("Hai già inserito quest'app")
updater.dispatcher.add_handler(CommandHandler('start', start))
updater.dispatcher.add_handler(CommandHandler('help', help))
updater.dispatcher.add_handler(CommandHandler('app_fatte_mamma', app_fatte_mamma))
updater.start_polling()
I'm trying to create a bot that receives the names of some applications as input and tells you if you have downloaded them or not. If they are not downloaded, they will be included in a list that can later be viewed with a specific command. Being new to bots, I know little about the subject, could you help me out?
Thanks a lot and this is my script:
from email import message
from telegram.ext.updater import Updater
from telegram.update import Update
from telegram.ext.callbackcontext import CallbackContext
from telegram.ext.commandhandler import CommandHandler
from telegram.ext.messagehandler import MessageHandler
from telegram.ext.filters import Filters
updater = Updater("TOKEN", use_context=True)
def start(update: Update, context: CallbackContext):
update.message.reply_text(
"Benvenuto al bot per ricordare i nomi delle app fatte")
def help(update: Update, context: CallbackContext):
update.message.reply_text("Your Message")
def app_fatte_mamma(update: Update, context: CallbackContext):
update.message.reply_text("Come si chiama l'app che hai appena fatto?")
app_mamma=[""]
updater.dispatcher.add_handler(MessageHandler(update.message.text))
if not update.message.text in app_mamma:
app_mamma.append(update.message.text)
update.message.reply_text("Ho inserito l'app nell'elenco")
else:
update.message.reply_text("Hai già inserito quest'app")
updater.dispatcher.add_handler(CommandHandler('start', start))
updater.dispatcher.add_handler(CommandHandler('help', help))
updater.dispatcher.add_handler(CommandHandler('app_fatte_mamma', app_fatte_mamma))
updater.start_polling()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论