• Как пересылать сообщения пользователя?

    @Emin777 Автор вопроса
    используя этот код получается что он отправляет в группу сообщение с этой строки bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id,
    text="Введите ник", reply_markup=keyboard)
  • Как исправить ошибку 'NoneType' object has no attribute 'chat'?

    @Emin777 Автор вопроса
    Вот полный список кода:

    import telebot
    from telebot import types

    token = "-----------------------"
    bot = telebot.TeleBot(token)

    @bot.message_handler(content_types=["text"])
    def handle_text(message):
    keyboardmain = types.InlineKeyboardMarkup(row_width=2)
    first_button = types.InlineKeyboardButton(text="********", callback_data="first")
    second_button = types.InlineKeyboardButton(text="********", callback_data="second")
    keyboardmain.add(first_button, second_button)
    bot.send_message(message.chat.id, "*************", reply_markup=keyboardmain)

    @bot.callback_query_handler(func=lambda call: True)
    def query_handler(call):
    if call.data == "mainmenu":
    keyboardmain = types.InlineKeyboardMarkup(row_width=2)
    first_button = types.InlineKeyboardButton(text="******", callback_data="first")
    second_button = types.InlineKeyboardButton(text="*******", callback_data="second")
    keyboardmain.add(first_button, second_button)
    bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="**********",
    reply_markup=keyboardmain)

    if call.data == "first":
    keyboard = types.InlineKeyboardMarkup()
    rele1 = types.InlineKeyboardButton(text="12:00", callback_data="a")
    rele2 = types.InlineKeyboardButton(text="16:00", callback_data="b")
    rele3 = types.InlineKeyboardButton(text="20:00", callback_data="d")
    rele4 = types.InlineKeyboardButton(text="24:00", callback_data="c")
    backbutton = types.InlineKeyboardButton(text="back", callback_data="mainmenu")
    keyboard.add(rele1, rele2, rele3, rele4, backbutton)
    bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id,
    text="*********",
    reply_markup=keyboard)

    if call.data == "a":
    keyboard = types.InlineKeyboardMarkup()
    rele1 = types.InlineKeyboardButton(text="**********", callback_data="1")
    backbutton = types.InlineKeyboardButton(text="back", callback_data="mainmenu")
    keyboard.add(rele1, backbutton)
    bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id,
    text="***********",
    reply_markup=keyboard)

    if call.data == "1":
    keyboard = types.InlineKeyboardMarkup()
    rele1 = types.InlineKeyboardButton(text="*******", callback_data="2")
    backbutton = types.InlineKeyboardButton(text="back", callback_data="a")
    keyboard.add(rele1, backbutton)
    bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id,
    text="***********t",
    reply_markup=keyboard)

    elif call.data == "2":
    keyboard = types.InlineKeyboardMarkup()
    rele1 = types.InlineKeyboardButton(text="**********", callback_data="3")
    backbutton = types.InlineKeyboardButton(text="back", callback_data="a")
    keyboard.add(rele1, backbutton)
    bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id,
    text="***********",
    reply_markup=keyboard)
    bot.answer_callback_query(callback_query_id=call.id, show_alert=True,
    text="**************")
    msg = "Пользователь {} написал \"{}\".".format(message.chat.id, message.messag_id)
    bot.send_message('-1000000000000', msg)

    @bot.callback_query_handler(func=lambda call: True)
    def query_handler(call):
    if call.data == "second":
    keyboard = types.InlineKeyboardMarkup()
    rele1 = types.InlineKeyboardButton(text="another layer", callback_data="gg")
    backbutton = types.InlineKeyboardButton(text="back", callback_data="mainmenu")
    keyboard.add(rele1, backbutton)
    bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="replaced text",
    reply_markup=keyboard)

    elif call.data == "3":
    bot.answer_callback_query(callback_query_id=call.id, show_alert=True, text="**************")
    keyboard3 = types.InlineKeyboardMarkup()
    button = types.InlineKeyboardButton(text="lastlayer", callback_data="ll")
    keyboard3.add(button)
    bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="last layer",
    reply_markup=keyboard3)

    if __name__ == "__main__":
    bot.polling(none_stop=True)

    Вот полный список ошибки:
    2020-08-06 02:14:48,154 (util.py:68 WorkerThread2) ERROR - TeleBot: "AttributeError occurred, args=("'NoneType' object has no attribute 'chat'",)
    Traceback (most recent call last):
    File "C:\Users\99455\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\util.py", line 62, in run
    task(*args, **kwargs)
    File "C:/Users/99455/PycharmProjects/untitled3/main.py", line 67, in handle_text
    msg = "Пользователь {} написал \"{}\".".format(message.chat.id, message.messag_id)
    AttributeError: 'NoneType' object has no attribute 'chat'
    "
    Traceback (most recent call last):
    File "", line 1, in
    File "C:\Program Files\JetBrains\PyCharm Community Edition 2020.1.2\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_umd.py", line 197, in runfile
    pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
    File "C:\Program Files\JetBrains\PyCharm Community Edition 2020.1.2\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
    File "C:/Users/99455/PycharmProjects/untitled3/main.py", line 91, in
    bot.polling(none_stop=True)
    File "C:\Users\99455\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\__init__.py", line 427, in polling
    self.__threaded_polling(none_stop, interval, timeout)
    File "C:\Users\99455\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\__init__.py", line 451, in __threaded_polling
    self.worker_pool.raise_exceptions()
    File "C:\Users\99455\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\util.py", line 111, in raise_exceptions
    six.reraise(self.exc_info[0], self.exc_info[1], self.exc_info[2])
    File "C:\Users\99455\AppData\Local\Programs\Python\Python38-32\lib\site-packages\six.py", line 693, in reraise
    raise value
    File "C:\Users\99455\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\util.py", line 62, in run
    task(*args, **kwargs)
    File "C:/Users/99455/PycharmProjects/untitled3/main.py", line 67, in handle_text
    msg = "Пользователь {} написал \"{}\".".format(message.chat.id, message.messag_id)
    AttributeError: 'NoneType' object has no attribute 'chat'
  • Как переслать сообщение в Телеграм Боте?

    @Emin777 Автор вопроса
    Михаил Трайнин, Все сработало. Большое тебе спасибо выручил.
  • Как перенаправить сообщение пользователя после запроса никнейма в телеграмм группу?

    @Emin777 Автор вопроса
    Я чайник в этом деле. Просто нужно что бы после сообщения «Введите никнейм» бот перенаправил ответ пользователя.