telegram bot - keep questions and answers

拥有回忆 提交于 2019-12-06 13:01:55

问题


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



来源:https://stackoverflow.com/questions/31912730/telegram-bot-keep-questions-and-answers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!