using System;
using System.Collections.Generic;
using System.IO;
using System.Text.Json;
using System.Threading;

namespace WeChatMessageRecovery
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("WeChat Message Recovery Tool");
            Console.WriteLine("Contact QQ: 771811549");

            // 模拟消息存储
            MessageStore messageStore = new MessageStore();
            messageStore.SaveMessage("user1", "Hello, this is a test message.");
            messageStore.SaveMessage("user2", "Another message for testing.");
            
            // 模拟消息撤回
            messageStore.DeleteMessage("user1");

            // 模拟找回撤回的消息
            string recoveredMessage = messageStore.RecoverMessage("user1");
            if (recoveredMessage != null)
            {
                Console.WriteLine("Recovered Message: " + recoveredMessage);
            }
            else
            {
                Console.WriteLine("No message found for user1");
            }

            // Keep console window open
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
    }

    public class MessageStore
    {
        private Dictionary<string, string> messages;
        private string logFilePath = "messages.json";

        public MessageStore()
        {
            messages = new Dictionary<string, string>();
            LoadMessages();
        }

        public void SaveMessage(string user, string message)
        {
            messages[user] = message;
            SaveMessages();
        }

        public void DeleteMessage(string user)
        {
            if (messages.ContainsKey(user))
            {
                messages.Remove(user);
                SaveMessages();
            }
        }

        public string RecoverMessage(string user)
        {
            if (messages.ContainsKey(user))
            {
                return messages[user];
            }
            else
            {
                return null;
            }
        }

        private void SaveMessages()
        {
            string json = JsonSerializer.Serialize(messages);
            File.WriteAllText(logFilePath, json);
        }

        private void LoadMessages()
        {
            if (File.Exists(logFilePath))
            {
                string json = File.ReadAllText(logFilePath);
                messages = JsonSerializer.Deserialize<Dictionary<string, string>>(json);
            }
        }
    }
}
  1. Program类:主要负责模拟消息的保存、删除和恢复操作。
  2. MessageStore类:负责消息的存储和恢复操作。它将消息保存到一个JSON文件中,并在删除消息时更新文件。
  3. 消息恢复:模拟撤回消息的恢复操作,通过查找已保存的消息实现。

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部