0

我需要在 python 中制作一个电报机器人,我编写了所有代码,但由于某种原因它不起作用

import telebot
import os

bot = telebot.TeleBot("Token")
user_data = {}

@bot.message_handler(commands=['start', 'help'])
def process_description_step(message):
    try:
        user_id = message.from_user.id
        user = user_data[user_id]
        user.description = message.text

        file_photo = bot.get_file(user.photo_id)
        filename, file_extension = os.path.splitext(file_photo.file_path)

        downloaded_file_photo = bot.download_file(file_photo.file_path)

        src = 'photos/' + user.photo_id + file_extension
        with open(src, 'wb') as new_file:
            new_file.write(downloaded_file_photo)

        bot.send_message(message.chat.id, "Вы успешно зарегистрированны!")
        bot.send_message((user, 'Заявка от бота', bot.get_me().username), parse_mode="Markdown")
        bot.send_photo(user.photo_id)

    except Exception as e:
        bot.reply_to(message, 'oooops')


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

帮我弄清楚,也许需要调整一些东西。先感谢您!

4

0 回答 0