Adium和Thunderbird-Chat可以通过访问聊天历史文件来获取接收和发送的对话历史。下面是一些代码示例来解决这个问题:
对于Adium:
import os
import sqlite3
def get_chat_history():
adium_folder = os.path.expanduser("~/.Adium")
chat_history_db = os.path.join(adium_folder, "Logs/Default/your_chat_account/your_chat_buddy/your_chat_buddy.db")
if os.path.exists(chat_history_db):
conn = sqlite3.connect(chat_history_db)
cursor = conn.cursor()
cursor.execute("SELECT sender, message FROM message")
rows = cursor.fetchall()
for row in rows:
sender, message = row
print(f"{sender}: {message}")
conn.close()
else:
print("Chat history database doesn't exist.")
get_chat_history()
对于Thunderbird-Chat:
import os
import sqlite3
def get_chat_history():
thunderbird_folder = os.path.expanduser("~/.thunderbird")
chat_history_db = os.path.join(thunderbird_folder, "random.default/your_chat_account/your_chat_buddy/your_chat_buddy.sqlite")
if os.path.exists(chat_history_db):
conn = sqlite3.connect(chat_history_db)
cursor = conn.cursor()
cursor.execute("SELECT sender, message FROM messages")
rows = cursor.fetchall()
for row in rows:
sender, message = row
print(f"{sender}: {message}")
conn.close()
else:
print("Chat history database doesn't exist.")
get_chat_history()
请注意,上述代码示例中的路径和数据库表名可能需要根据实际情况进行相应的更改。