Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I need to make a telegram bot in python, I wrote all the code, but for some reason it doesn't work

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)

Help me figure it out, maybe something needs to be tweaked. Thank you in advance!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
465 views
Welcome To Ask or Share your Answers For Others

1 Answer

等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...