public static void Main() { Native.Csharp.Sdk.Cqp.CQApi.Sender = new TaskReceiver(); //传递假的container Register(FakeCoolQ); //注册假的CQ CQApi = new CQApi(404233); CQLog = new CQLog(404233); //取得注册的接口 Startup = FakeCoolQ.Resolve <ICQStartup>("酷Q启动事件"); GroupMessage = FakeCoolQ.Resolve <IGroupMessage>("群消息处理"); //触发假的启动事件 Startup.CQStartup(null, new CQStartupEventArgs(CQApi, CQLog, 0, 0, "startup", "CQStartup", 0)); //启动Tcp监听线程 Thread t = new Thread(new ThreadStart(WebProcess.Listening)); t.Start(); //触发假的群聊事件 if (NotTestInputing) { return; } while (true) { string content = Console.ReadLine(); Console.WriteLine($"↓ 你:\n{content}"); GroupMessage.GroupMessage(null, new CQGroupMessageEventArgs(CQApi, CQLog, 0, 0, "groupmessage", "CQGroupMessage", 0, 0, msgid, GroupID, QQID, "", content, false)); msgid++; } }
public static void Launch() { #if LOCAL_DEBUG #else Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("~该dll已经正常编译,不可启动调试。~"); Console.ReadLine(); return; #endif Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("~机器人本地测试工具~"); Console.WriteLine("特殊指令:\n%setqq <qq> 设置测试用的QQ号\n%setgroup <group> 设置测试用的群号\n"); Console.Write("输入测试用的QQ号:"); QQID = long.Parse(Console.ReadLine()); Console.Write("输入测试用的群号:"); GroupID = long.Parse(Console.ReadLine()); //传递假的container CQMain.Register(FakeCoolQ); //注册假的CQ CQApi = new CQApi(new Sdk.Cqp.Model.AppInfo("local_debuger", 0, 9, "local_debuger", "1.0.0", 10, "", "", 404233)); CQLog = new CQLog(404233); //取得注册的接口 Startup = FakeCoolQ.Resolve <ICQStartup>("酷Q启动事件"); GroupMessage = FakeCoolQ.Resolve <IGroupMessage>("群消息处理"); //触发假的启动事件 Startup.CQStartup(null, new CQStartupEventArgs(CQApi, CQLog, 0, 0, "startup", "CQStartup", 0)); //触发假的群聊事件 while (true) { Console.ForegroundColor = ConsoleColor.White; Console.Write("QQ" + QQID + "@" + GroupID + ">"); string content = Console.ReadLine(); if (content.StartsWith("%")) { string[] p = content.Split(' '); if (p[0] == "%setqq") { QQID = long.Parse(p[1]); } if (p[0] == "%setgroup") { GroupID = long.Parse(p[1]); } } else { GroupMessage.GroupMessage(null, new CQGroupMessageEventArgs(CQApi, CQLog, 0, 0, "groupmessage", "CQGroupMessage", 0, 0, msgid, GroupID, QQID, "", content, false)); msgid++; } } }