Python电报机器人对话方法不工作

Python电报机器人对话方法不工作,python,telegram-bot,python-telegram-bot,Python,Telegram Bot,Python Telegram Bot,我正在为一个收入/支出项目写一份报告 我使用以下代码编写此代码: 当我使用/start时,它会一直工作,直到Bot说: Ok 现在将您的用户名发送给我 在这之后,它需要返回注册您的用户名,但它不会返回 但是我可以访问/cancel命令。 我需要知道为什么这个脚本不调用regUser函数?好的,我发现了两个错误,解决了我的问题 在调节器中: 首先,我在双引号之间使用了chat\u id, 第二,我用大写字母U代替Updater #!/usr/bin/python # -*- Coding : UT

我正在为一个收入/支出项目写一份报告

我使用以下代码编写此代码:

当我使用
/start
时,它会一直工作,直到Bot说:

Ok

现在将您的用户名发送给我

在这之后,它需要返回
注册您的用户名
,但它不会返回

但是我可以访问
/cancel
命令。
我需要知道为什么这个脚本不调用
regUser
函数?

好的,我发现了两个错误,解决了我的问题

在调节器中:

首先,我在双引号之间使用了
chat\u id
, 第二,我用大写字母
U
代替
Updater

#!/usr/bin/python
# -*- Coding : UTF-8 -*-

from telegram import ReplyKeyboardMarkup, ReplyKeyboardRemove
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters, ConversationHandler
from settings.conf import conf

conf = conf()
updater = Updater(str(conf.token()))
SETUP ,USERNAME = range(2)

def start_method(bot, update):
    """ Start Command """

    startList = [["Register New Account","Integrate An Account"]]

    chat_id = update.message.chat_id
    replyText = update.message.text

    text = """Hello And Welcome To [Bestoon](http://bestoon.ir).
This Bot Helps You Easily Access Your [Bestoon](http://bestoon.ir) Account.
Now, How Can I Help You?
"""
    bot.sendChatAction(chat_id, "TYPING")
    update.message.reply_text(text, parse_mode="Markdown",reply_markup=ReplyKeyboardMarkup(startList, one_time_keyboard=True))
    return SETUP

def setup(bot, update):
    """Initialize The User Account For The First Time"""
    chat_id = update.message.chat_id

    if update.message.text == "Register New Account":
        bot.sendChatAction(chat_id, "TYPING")
        register_text = """Ok.
Now Send Me Your Bestoon Username.
"""
        update.message.reply_text(register_text,reply_markup=ReplyKeyboardRemove())
        print "Going For Username"
        return USERNAME

    elif update.message.text == "Integrate An Account":
        bot.sendChatAction(chat_id, "TYPING")
        update.message.reply_text("Sorry, Can\'t Integrate Now!", reply_markup=ReplyKeyboardRemove())
        bot.sendMessage(update.message.chat_id, "Bye!")
        return ConversationHandler.END

    else:
        bot.sendChatAction(chat_id, "TYPING")
        update.message.reply_text("Invalid Command!")

def regUser(bot, Update):
    chat_id = update.message.chat_id
    bot.sendChatAction("chat_id", "TYPING")
    update.message.reply_text("Registering Your Username")
    return ConversationHandler.END

def cancel(bot, update):
    bot.sendMessage(update.message.chat_id, "Bye!")
    return ConversationHandler.END

conv_handler = ConversationHandler(
    entry_points = [CommandHandler('start', start_method)],

    states = {
        SETUP: [MessageHandler(Filters.text, setup)],
        USERNAME: [MessageHandler(Filters.text, regUser)]

    },

    fallbacks = [CommandHandler('cancel', cancel)]
)
updater.dispatcher.add_handler(conv_handler)

########## Starting Bot ##########
updater.start_polling()
updater.idle()