private void listView_clusterList_DoubleClick(object sender, EventArgs e) { ListViewItem item = listView_clusterList.FocusedItem; string clusterId = item.SubItems[0].Text; string clusterSwitch = SQLiteHandler.getClusterIsEnabled(clusterId); if (clusterSwitch == "0") { if (SQLiteHandler.setClusterIsEnabled(clusterId, 1)) { item.SubItems[2].Text = "开"; } else { Plugin.OnLog(clusterId + " setClusterIsEnabled failed..."); } } else if (clusterSwitch == "1") { if (SQLiteHandler.setClusterIsEnabled(clusterId, 0)) { item.SubItems[2].Text = "关"; } else { Plugin.OnLog(clusterId + " setClusterIsEnabled failed..."); } } else { if (clusterId == "0" || clusterId == "10000") { if (SQLiteHandler.addNewGroupInfo(clusterId, 0)) { item.SubItems[2].Text = "关"; } else { Plugin.OnLog(clusterId + " add new group info failed..."); } } else { if (SQLiteHandler.addNewGroupInfo(clusterId, 1)) { item.SubItems[2].Text = "开"; } else { Plugin.OnLog(clusterId + " add new group info failed..."); } } } }
private void initClustListData() { ListViewItem lvi; //先添加0(好友设置)和10000(默认群设置) string friendSwitch = SQLiteHandler.getClusterIsEnabled("0"); string defaultSwitch = SQLiteHandler.getClusterIsEnabled("10000"); lvi = new ListViewItem("0"); lvi.SubItems.Add("好友设置"); if (friendSwitch == "0") { lvi.SubItems.Add("关"); } else { lvi.SubItems.Add("开"); } lvi = listView_clusterList.Items.Add(lvi); lvi = new ListViewItem("10000"); lvi.SubItems.Add("默认群设置"); if (defaultSwitch == "0") { lvi.SubItems.Add("关"); } else { lvi.SubItems.Add("开"); } lvi = listView_clusterList.Items.Add(lvi); //获取群列表 ClusterList clusterlist = Plugin.Client.ClusterList; foreach (KeyValuePair <uint, ClusterInfo> kv in clusterlist) { ClusterInfo clusterInfo = kv.Value; string clusterId = kv.Key.ToString(); string clusterSwitch = SQLiteHandler.getClusterIsEnabled(clusterId); lvi = new ListViewItem(clusterId); lvi.SubItems.Add(clusterInfo.Name); if (clusterSwitch == "1") { lvi.SubItems.Add("开"); } else { lvi.SubItems.Add("关"); } lvi = listView_clusterList.Items.Add(lvi); } }
private void SDK_ReceiveClusterIM(object sender, ClusterIMEventArgs eventArgs) { // 判断是否已经被别的插件处理过 if (eventArgs.Cancel) { OnLog("已被其他插件使用,该插件不再处理"); return; } // 开始处理群消息 ClusterInfo clusterInfo = eventArgs.ClusterInfo; if (!clusterInfo.CanSend || SQLiteHandler.getClusterIsEnabled(clusterInfo.ClusterId.ToString()) != "1") { OnLog("本群未启用该功能"); return; } // 去除消息中的空格回车制表符等 string message = Regex.Replace(eventArgs.Message, "[\f\n\r\t\v\\s+]", ""); // 开始匹配查询功能 // 初版直接写死:查 种族值 宝可梦 if (message.StartsWith("查")) { Regex r = new Regex("查"); string msgContent = r.Replace(message, ""); int pokemonId; string sendStr; DataSet ds; if (int.TryParse(msgContent, out pokemonId)) { if (pokemonId > 0 && pokemonId < 10) { msgContent = "00" + pokemonId.ToString(); } else if (pokemonId >= 10 && pokemonId < 100) { msgContent = "0" + pokemonId.ToString(); } else if (pokemonId >= 100 && pokemonId <= 890) { msgContent = pokemonId.ToString(); } else { sendStr = "宝可梦编号不存在[1-890]"; sendQueryFailureClusterMsg(sendStr, CommonDefine.queryPokemonInfoIdFailure, eventArgs); return; } ds = SQLiteHandler.getPokemonInfoBySn(msgContent); } else { ds = SQLiteHandler.getPokemonInfoByName(msgContent); } if (ds.Tables.Count == 0 || (ds.Tables.Count == 1 && ds.Tables[0].Rows.Count == 0)) { sendStr = "宝可梦编号不存在[1-890]"; sendQueryFailureClusterMsg(sendStr, CommonDefine.queryPokemonInfoFailure, eventArgs); return; } foreach (DataTable dt in ds.Tables) { foreach (DataRow row in dt.Rows) { sendStr = "嘻嘻嘻,就不告诉你"; sendQuerySuccessClusterMsg(sendStr, CommonDefine.queryPokemonInfoSuccess, row, eventArgs); } } return; } else if (message.StartsWith("种族值")) { Regex r = new Regex("种族值"); string msgContent = r.Replace(message, ""); string sendStr = ""; foreach (string imgName in this.speciesStrengthImgList) { if (-1 != imgName.IndexOf(msgContent)) { sendStr = sendStr + imgName + ":[Image]" + string.Format("{0}\\speciesStrength\\{1}", this.Config.PokemonImageBaseDir, imgName) + "[/Image]\r\n"; } } if (sendStr == "") { sendStr = "[@QQ]请确定该宝可梦是否存在!"; } else { sendStr = "[@QQ]\r\n" + sendStr; } SendExtension.SendClusterIM(Client, eventArgs.ClusterInfo.ClusterId, PluginExtension.ReplaceVariable(eventArgs, sendStr, true)); eventArgs.Cancel = true; return; } else if (message.StartsWith("进化")) { Regex r = new Regex("进化"); string msgContent = r.Replace(message, ""); string sendStr = ""; if (File.Exists(string.Format("{0}\\evolveImg\\{1}.png", this.Config.PokemonImageBaseDir, msgContent))) { sendStr = sendStr + "[Image]" + string.Format("{0}\\evolveImg\\{1}.png", this.Config.PokemonImageBaseDir, msgContent) + "[/Image]\r\n"; } if (File.Exists(string.Format("{0}\\megaEvolveImg\\{1}.png", this.Config.PokemonImageBaseDir, msgContent))) { sendStr = sendStr + "超级进化:[Image]" + string.Format("{0}\\megaEvolveImg\\{1}.png", this.Config.PokemonImageBaseDir, msgContent) + "[/Image]\r\n"; } if (File.Exists(string.Format("{0}\\transformImg\\{1}.png", this.Config.PokemonImageBaseDir, msgContent))) { sendStr = sendStr + "形态变化:[Image]" + string.Format("{0}\\transformImg\\{1}.png", this.Config.PokemonImageBaseDir, msgContent) + "[/Image]\r\n"; } if (sendStr == "") { sendStr = "[@QQ]请确定该宝可梦是否存在!"; } else { sendStr = "[@QQ]\r\n" + sendStr; } SendExtension.SendClusterIM(Client, eventArgs.ClusterInfo.ClusterId, PluginExtension.ReplaceVariable(eventArgs, sendStr, true)); eventArgs.Cancel = true; return; } else if (message.StartsWith("弱点")) { Regex r = new Regex("弱点"); string msgContent = r.Replace(message, ""); string sendStr = ""; if (File.Exists(string.Format("{0}\\typeOpposite\\{1}_反转对战.png", this.Config.PokemonImageBaseDir, msgContent))) { sendStr = sendStr + "攻击:[Image]" + string.Format("{0}\\typeOpposite\\{1}_反转对战.png", this.Config.PokemonImageBaseDir, msgContent) + "[/Image]\r\n"; } if (File.Exists(string.Format("{0}\\typeOpposite\\{1}_一般.png", this.Config.PokemonImageBaseDir, msgContent))) { sendStr = sendStr + "防御:[Image]" + string.Format("{0}\\typeOpposite\\{1}_一般.png", this.Config.PokemonImageBaseDir, msgContent) + "[/Image]\r\n"; } if (sendStr == "") { sendStr = "[@QQ]请确定该宝可梦是否存在!"; } else { sendStr = "[@QQ]\r\n" + sendStr; } SendExtension.SendClusterIM(Client, eventArgs.ClusterInfo.ClusterId, PluginExtension.ReplaceVariable(eventArgs, sendStr, true)); eventArgs.Cancel = true; return; } }