电报机器人不想对命令做出反应

时间:2019-08-22 23:30:20

标签: python-3.x telegram-bot

我创建了一个电报机器人,当我启动时它不想对命令做出反应

我尝试过函数式编程,但是除了尝试使用OOP使变量返回另一个函数外,我不明白如何将其返回到另一个函数,并且它可以工作但对命令没有反应

class TelegramBot():
    def __init__(self):

    self.Numberphone = ""
    self.family_name = ""
    self.name = ""
    self.given_name = ""
    self.distributor_id = ""
    self.userID = ""
    self.lastname = ""
    self.firstname = ""
    self.newphone = ""

    self.orders = []

    self.AllSumaDebts = []
    self.AllOverdueDebts = []


    self.ordersname = []
    self.ID = ''

    self.name = ''

    self.text = ''
    self.end_string = ''
    self.one = ''
    self.IDsroutes = []
    self.Namereponsibleroutes = []
    self.ListNamereponsibleroutes = []
    self.ListIDresponsibleroutes = []
    self.IDresponsibs = []
    self.Nameresponsibs = ''
    self.alltext = []
    self.today = ""
    self.datainjson = ""
    self.answearIDforTask = ""

@bot.message_handler(commands=['start'])
def send_welcome(self,message):
    db = Client.TelegramUsers

    coll = db.Users
    ID_user = message.from_user.id
    print(ID_user)

    searchdata = {"telegram_contact.phone_number": ID_user}

    search = coll.find_one(searchdata)
    print(search)
    for key in self.InfoAboutUser:
        self.InfoAboutUser['distributor_id'] = ""
        self.InfoAboutUser['given_name'] = ""
        self.InfoAboutUser['family_name'] = ""
        self.InfoAboutUser['middle_name'] = ""
        self.InfoAboutUser['name'] = ""
        self.InfoAboutUser['id'] = ""
        self.InfoAboutUser['telegram_contact']['phone_number'] = ""
        self.InfoAboutUser['telegram_contact']['first_name'] = ""
        self.InfoAboutUser['telegram_contact']['last_name'] = ""
        self.InfoAboutUser['telegram_contact']['user_id'] = ""

    pprint(self.InfoAboutUser)

    keyboard = telebot.types.ReplyKeyboardMarkup(row_width=1, resize_keyboard=True, one_time_keyboard=True)
    contact = telebot.types.KeyboardButton("Send your contact", request_contact=True)
    keyboard.add(contact)

    self.InfoAboutUser['telegram_contact']['user_id'] = message.from_user.id

    self.InfoAboutUser['telegram_contact']['last_name'] = message.from_user.last_name
    self.InfoAboutUser['telegram_contact']['first_name'] = message.from_user.first_name
    self.firstname = message.from_user.first_name
    pprint(self.InfoAboutUser)
    bot.send_chat_action(message.chat.id, 'typing')

    bot.send_message(message.chat.id, "send your contack", reply_markup=keyboard)

我不了解Python中的OOP,因此我在GitHub上找到了一些代码并将其作为示例。

0 个答案:

没有答案