pyTelegramBotAPI cannot use other libraries as I have already done many functions for this bot. I need to add a function to the bot with which it will be possible to save the text from the user and + then change this text, it is best to save all this in .txt. Please help if you can)
Answer # 1
In what sense should the text be saved? To get some text from the user use @ bot.message_handler or bot.register_next_step_handler, to change the message use bot.edit_message_text
If you just want to receive his message and record, then use @ bot.message_handler:
@ bot.message_handler (content_types= ["text"]) def write (message): text= message.text f= open ("writes.txt", "a") f.write (text) f.close ()
Answer # 2
It's very simple. When the user writes the command /write There was a storm yesterday, you need to separate the command and its arguments.
data= message.text data= data.replace ("/write", "")
Voila, you have all the rest of the text.
data= message.text data= data.split ("") data= data [1:]
Voila and you already have all the data, but in the form of a list. This is generally done by built-in library functions. I did not write on your library, but I used it in a more powerful aiogram. There is a built-in parameter args. You do not, and all arguments entered with the command are accepted. You can google if your library has it.
- number of keyboard buttons per line in keyboard under telebot python telegram message
- Trouble running telegram bot in Python!
- python : Sending PIL.Image image as document via pyTelegramBotApi
- How to make the bot respond to commands in the telegram channel. Python, Telebot
- How to randomly open photos in Telegram Bot in Python?
- python : Asynchronous loop while True
- python : Telegram bot listening to another bot
- python : Error in Pyrogram. How to decide?
- python : Getting data from invoice payment PyTelegramBotAPI
- python : What methods exist in ReplyKeyboardMarkup