[英]How to get a session_id, its start and end time and bot_id in python with Telegram Bot API?
I'm making a Telegram Bot in Python with the help of Telegram Bot API.在 Telegram Bot API 的帮助下,我正在 Python 中制作 Telegram Bot。 So I want to keep some information about the Telegram Chat in SQLite database and i need to get message_id, message_time, session_id, session_start_time, session_end_time, message_text and user/bot_id.
所以我想在 SQLite 数据库中保留一些关于电报聊天的信息,我需要获取 message_id、message_time、session_id、session_start_time、session_end_time、message_text 和 user/bot_id。 So I've found how to get message_id, message_time, message_text and user_id.
所以我找到了如何获取 message_id、message_time、message_text 和 user_id。 But can't find how to get the other.
但是找不到其他方法。
conn = sqlite3.connect("emojic_database.db")
cur = conn.cursor()
tconv = lambda x: time.strftime("%H:%M:%S %d.%m.%Y", time.localtime(x))
cur.execute("INSERT INTO messages (mes_id, mes_time, ses_id, mes_text, user_id)\
VALUES (?,?,?,?,?)", (message.message_id, tconv(message.date), ???, message.text, message.from_user.id)
cur.execute("INSERT INTO sessions (ses_id, start_time, end_time)\
VALUES (?,?,?)", (???))
conn.close()
Or maybe I have to use another API?或者也许我必须使用另一个 API? Any help appreciated.
任何帮助表示赞赏。
Have you considered a usage of any library builded upon the Telegram API?您是否考虑过使用基于 Telegram API 构建的任何库? Development will go much faster and those library's documentations also help to understand Telegram API.
开发将 go 更快,这些库的文档也有助于理解 Telegram API。
Check for example:检查例如:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.