public override int HandleImpl() { try { AttentionService attentionService = new AttentionService(); List <Attention> attList = attentionService.Query(fromQQ, "", ""); if (attList.Count == 0) { CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), "【查询成功】\n当前没有关注记录"); return(0); } String attListInMessage = "关注点:\n"; foreach (Attention att in attList) { String groupName = CQ.Api.GetGroupInfo(Convert.ToInt64(att.Group)).Name; attListInMessage += att.AttentionPoint + "\t群:" + groupName + "(" + att.Group + ")\n"; } attListInMessage = attListInMessage.Substring(0, attListInMessage.Length - 2); CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), attListInMessage); } catch (Exception e) { CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), "【查询失败】\n" + e); } return(0); }
public override int HandleImpl() { try { String[] temp = message.Split(' '); String OldAttentionPoint = temp[1]; String NewAttentionPoint = temp[2]; String GroupNum = temp[3]; AttentionService attentionService = new AttentionService(); if (!attentionService.Update(fromQQ, OldAttentionPoint, NewAttentionPoint, GroupNum)) { throw new Exception(); } CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), "更新关注成功!"); } catch (DbUpdateException e) { CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), "【无法更新】没有关注或者不是该群!"); } catch (IndexOutOfRangeException e) { CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), "【无法更新】请按照正确的格式输入\n更新关注 旧关注点 新关注点 群号"); } catch (Exception e) { CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), "【无法更新】数据库中没有此项"); } return(0); }
public override int HandleImpl() { try { String[] temp = message.Split(' '); String AttentionPoint = temp[1]; String GroupNum = temp[2]; //添加前先检测:1.群号是否为一串数字;2.该用户和本机器人是否都在群中; //如果不是就抛出异常 GroupMemberInfoCollection groupMemberInfoCollection = CQEventArgsArgs.CQApi.GetGroupMemberList(Convert.ToInt64(GroupNum)); int flag = 0; foreach (GroupMemberInfo groupMemberInfo in groupMemberInfoCollection) { if (groupMemberInfo.QQ.Id.Equals(Convert.ToInt64(fromQQ))) { flag += 1; } else if (groupMemberInfo.QQ.Id.Equals(Convert.ToInt64(botQQ))) { flag += 2; } } if (flag < 3) { throw new InvalidDataException(); } AttentionService attentionService = new AttentionService(); attentionService.Add(fromQQ, AttentionPoint, GroupNum); CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), "【添加成功】添加关注成功!"); } catch (IndexOutOfRangeException e) { CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), "【添加失败】添加关注的正确格式是 “添加关注 考试(内容) 1525468122(群号)"); } catch (DbUpdateException e) { CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), "【添加失败】数据库更新异常"); } catch (FormatException e) { CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), "【添加失败】群号中只能包含数字"); } catch (InvalidDataException e) { CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), "【添加失败】用户或机器人不在群聊中"); } catch (ArgumentOutOfRangeException e) { CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), "【添加失败】无效QQ群号"); } catch (Exception e) { CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), "【添加失败】\n" + e.Message); } return(0); }
public override int HandleImpl() { AttentionService attentionService = new AttentionService(); List <String> listeners = attentionService.Listening(message, fromGroup); foreach (String listener in listeners) { CQ.Api.SendPrivateMessage(Convert.ToInt64(listener), "群聊 " + fromGroup + " 中有您关注的消息:" + message); } return(0); }
private void allAttentionUserDataGridView_CellClick(object sender, DataGridViewCellEventArgs e) { AttentionService attentionService = new AttentionService(); if (allAttentionUserDataGridView.CurrentRow != null) { String listener = allAttentionUserDataGridView.CurrentRow.Cells[0].Value.ToString(); bindingSource_attention.DataSource = attentionService.Query(listener, "", ""); } bindingSource_attentionUser.ResetBindings(true); bindingSource_attentionUser.DataSource = attentionService.Listeners; }
private void tab4Init() { type_comboBox.SelectedIndex = 0; AttentionService attentionService = new AttentionService(); String listener = attentionService.Listeners.First().Listener.ToString(); bindingSource_attention.DataSource = attentionService.Query(listener, "", ""); bindingSource_attentionUser.DataSource = attentionService.Listeners; attentionDataGridView.DataSource = bindingSource_attention; allAttentionUserDataGridView.DataSource = bindingSource_attentionUser; bindingSource_attentionUser.ResetBindings(true); }
private void remove_attention_buttom_Click(object sender, EventArgs e) { AttentionService attentionService = new AttentionService(); if (attentionDataGridView.CurrentRow != null) { String listener = attentionDataGridView.CurrentRow.Cells[0].Value.ToString(); String group = attentionDataGridView.CurrentRow.Cells[1].Value.ToString(); String attention = attentionDataGridView.CurrentRow.Cells[2].Value.ToString(); attentionService.Remove(listener, attention, group); search_attention_buttom_Click(sender, e); } bindingSource_attentionUser.ResetBindings(true); bindingSource_attentionUser.DataSource = attentionService.Listeners; }
private void search_attention_buttom_Click(object sender, EventArgs e) { AttentionService attentionService = new AttentionService(); int index = type_comboBox.SelectedIndex; String searchText = textBox1.Text; String currentListener; if (allAttentionUserDataGridView.CurrentRow != null) { currentListener = allAttentionUserDataGridView.CurrentRow.Cells[0].Value.ToString(); } else { currentListener = attentionService.Listeners.First().ToString(); } switch (index) { case 0: if (searchText == "") { bindingSource_attention.DataSource = attentionService.Query(currentListener, "", ""); } else { bindingSource_attention.DataSource = attentionService.Query(searchText, "", ""); } break; case 1: bindingSource_attention.DataSource = attentionService.Query(currentListener, "", searchText); break; case 2: bindingSource_attention.DataSource = attentionService.Query(currentListener, searchText, ""); break; default: bindingSource_attention.DataSource = attentionService.Query(currentListener, "", ""); break; } bindingSource_attentionUser.ResetBindings(true); bindingSource_attentionUser.DataSource = attentionService.Listeners; }
public override int HandleImpl() { try { String[] temp = message.Split(' '); String AttentionPoint = temp[1]; String GroupNum = temp[2]; AttentionService attentionService = new AttentionService(); if (attentionService.Remove(fromQQ, AttentionPoint, GroupNum)) { CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), "删除关注成功!"); } else { CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), "【删除失败】只能删除已关注内容"); } } catch (Exception e) { CQ.Api.SendPrivateMessage(Convert.ToInt64(fromQQ), "无法删除:没有关注或者不是该群!"); } return(0); }