-->

telegram bot - keep questions and answers

2020-07-21 06:18发布

问题:

My telegram bot is a dialog and it needs to keep the questions and the answers (like TriviaBot). What is the best (most efficient) method to do this? A database with the user id as key?

There is a lot of telegram bots, but where are examples with the source code to get ideas?

回答1:

Your question is not really related to the telegram bot API. You are essentially asking: I have an application that has to keep an history of user interactions, how to do this (efficient)?

To answer that: you could use a database and insert an entry for each conversation using an unique identifier. Since telegram has a chat_id for each conversation, you could use that. Depending on what you are exactly trying to store, you should choose how to store it. (an entry for each answer, or for each conversation or ...)

If you program in python, you can use the python wrapper called python-telegram-bot to make things easier

Examples are here: https://github.com/leandrotoledo/python-telegram-bot#examples



回答2:

You can use force_reply and frequently ask whatever you want and store answers in any kind of database. Please refer to its doc : refrence
and a simple answer on : force reply description