在Python中接收电报机器人输入的消息

发布于 2025-01-22 12:55:31 字数 1606 浏览 0 评论 0原文

我正在尝试创建一个接收某些应用程序名称作为输入的机器人,并告诉您是否已下载它们。如果未下载它们,它们将包含在列表中,以后可以使用特定命令查看。对机器人来说是新手,我对这个主题一无所知,您能帮我吗? 非常感谢,这是我的脚本:

    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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文