javascript - How to get chat id in telegram bot without message from user? Is it even real?
问题描述
I am making a telegram bot who will work like schedule and it is deployed on heroku. When server is restarting, chat id is clearing and the bot is not working
So I have a question. Can I somehow get chat id without user message? And is it even real?
解决方案
你必须备份那些id和你的会话文件
会话文件包含有关您与电报的所有交互的信息(聊天、按摩......)
在服务器重新启动之前,保存会话文件记住保存会话文件并在重新启动后将它们再次复制到它们的目录中,就像机器人没有发生任何事情一样,因为所有内容都保存在这些文件中。
将您的机器人连接到数据库系统。mysql ,.....或者只是将聊天 id (或 peer id )编号(在更新数组中)保存到文件(txt , json ,...)中,然后在服务器重新启动后使用它们。
如果您丢失了会话文件,就好像机器人的内存被擦除了
推荐阅读
- node.js - NSolid SaaS 的不同计划包括哪些内容?
- azure - Azure Functions 触发器失败:函数的侦听器无法启动
- sas - 宏块或数据步之外的 SAS 宏功能
- mysql - 在 Presto/SQL 中用以前的非空值填充缺失的空值
- oauth-2.0 - Oauth2 密码授予类型 - 刷新令牌 - 使用代理
- r - 如何检查非整数向量是否是R中的算术级数
- javascript - Redux:如何用更好的代码获取状态
- python-3.x - 这是在python3中读写巨大的txt文件时的最佳实践吗?
- aws-cli - 尝试注册新的 QuickSight 用户时出现 InvalidParameterValueException
- javascript - 如何检测是否有任何输入为空?