public async Task <bool> GroupApply(MiraiHttpSession session, IGroupApplyEventArgs e) { try { Logger.Instance.AddLog(LogType.Info, "已收到来自" + e.FromQQ + "的申请, 申请资料为" + e.Message); if (e.Message.Contains("#")) { var cocid = e.Message.Split('\n').Last().Remove(0, 3).Replace(" ", ""); if (await AdminAPI.NewMember(cocid, new Data.ApplyEventArgs { EventArgs = e, Session = session })) { await session.HandleGroupApplyAsync(e, GroupApplyActions.Allow); await AdminAPI.ChangeNewMemberName(cocid, new Data.ApplyEventArgs() { EventArgs = e, Session = session }); return(true); } else { await session.HandleGroupApplyAsync(e, GroupApplyActions.Deny, "科技不足"); return(true); } } else { if (Directory.GetFiles("com.coc.groupadmin\\Blacklist").Any(x => x.EndsWith(e.FromQQ.ToString()))) { //在黑名单内,直接拒绝 await session.HandleGroupApplyAsync(e, GroupApplyActions.Deny, "已被拉黑"); return(true); } await session.HandleGroupApplyAsync(e, GroupApplyActions.Allow); await session.SendGroupMessageAsync(e.FromGroup, new AtMessage(e.FromQQ), new PlainMessage("新人请发玩家标签审核!")); return(true); } } catch (Exception ex) { if (ex is NullReferenceException) { if (Directory.GetFiles("com.coc.groupadmin\\Blacklist").Any(x => x.EndsWith(e.FromQQ.ToString()))) { //在黑名单内,直接拒绝 await session.HandleGroupApplyAsync(e, GroupApplyActions.Deny, "已被拉黑"); return(true); } await session.HandleGroupApplyAsync(e, GroupApplyActions.Allow); await session.SendGroupMessageAsync(e.FromGroup, new AtMessage(e.FromQQ), new PlainMessage("新人请发玩家标签审核!审核时玩家标签无效!")); return(true); } else { await session.SendGroupMessageAsync(e.FromGroup, new AtMessage(e.FromQQ), new PlainMessage(ex.Message)); return(true); } } }
public async Task <bool> GroupApply(MiraiHttpSession session, IGroupApplyEventArgs e) { await session.HandleGroupApplyAsync(e, GroupApplyActions.Allow, "欢迎"); return(false); }
public async Task <bool> BotInvitedJoinGroup(MiraiHttpSession session, IBotInvitedJoinGroupEventArgs e) { await session.HandleGroupApplyAsync(e, GroupApplyActions.Allow); return(true); }