简体   繁体   English

电报机器人数据存储

[英]Telegram-bot data storage

I'm developing a telegram bot which needs to store datas for each user. 我正在开发一个需要为每个用户存储数据的电报机器人。 Is there a way to store them directly into the phone or something particular or the only way is to save them server-side and call them back for every call? 有没有办法将它们直接存储到手机或特定的东西中,或者唯一的方法是将它们保存在服务器端并在每次呼叫时回拨它们?

Thanks 谢谢

I don't get what you want to do. 我不明白你想做什么。 A telegram bot is running on your server and does only reply or send messages to the user. 电报机器人正在您的服务器上运行,并且只回复或向用户发送消息。 When you want to save data for the user, you have to save it on the server. 如果要为用户保存数据,则必须将其保存在服务器上。 Assuming you are using C#, you could use a database or a simple Dictionary with the UserID as key and your data as the value. 假设您使用的是C#,您可以使用数据库或简单的Dictionary,其中UserID为键,数据为值。 Your bot can't run any code on the phone, so there is no possibility to save data there. 您的机器人无法在手机上运行任何代码,因此无法在那里保存数据。

Data storage handling can reside in the machine where the code telegram bot run. 数据存储处理可以驻留在运行代码电报机器人的机器中。 I developed telegram bot with node-telegram-bot-api . 我用node-telegram-bot-api开发了telegram bot。 For data storage i used mongodb (if you are using NodeJS can follow this guide). 对于数据存储我使用mongodb (如果你使用NodeJS可以按照本指南)。 If you will choose to use mongodb consider that you can use it with several frameworks/programming languages. 如果您选择使用mongodb,请考虑将其与多种框架/编程语言一起使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM