public async Task <bool> NewFriendApply(MiraiHttpSession session, INewFriendApplyEventArgs e)
        {
            await session.HandleNewFriendApplyAsync(e, FriendApplyAction.Deny, "略略略");

            // 把整个事件信息直接作为第一个参数即可, 然后根据自己需要选择一个 FriendApplyAction 枚举去处理请求
            // 你也可以暂存 INewFriendApplyEventArgs e, 之后再调用 session 处理
            return(false);
        }
示例#2
0
        static async Task Main(string[] args)
        {
            var lines = File.ReadAllLines("students.csv", Encoding.UTF8);

            foreach (var line in lines.Where(l => l.NotNullNorWhiteSpace()))
            {
                var sp    = line.Split(',');
                var id    = sp[0];
                var stdid = sp[1];
                var name  = sp[2];
                PreRegisteredStudents.Add(new Student(null, id.ToInt(), stdid, name));
            }

            var options = new MiraiHttpSessionOptions("127.0.0.1", 8080, Config.Instance.AuthCode);
            var qq      = Config.Instance.QQ;

            mirai = new MiraiHttpSession();

            await mirai.ConnectAsync(options, qq);

            mirai.FriendMessageEvt  += OnFriendMessage;
            mirai.NewFriendApplyEvt += (sender, eventArgs) =>
            {
                mirai.HandleNewFriendApplyAsync(eventArgs, FriendApplyAction.Allow, "略略略");
                Thread.Sleep(5000);
                SendPrivate(eventArgs.FromQQ.ToString(), $"使用[注册 名字]来注册 如输入 '注册 小明' \n" +
                            $"使用[上传图片]来开始上传图片, 在输入上传图片后 发送的下一张图片将会被保存.\n" +
                            $"以上内容均不包含括号'[]'\n" +
                            $"Written by Cyl18 2020 https://github.com/Cyl18/");
                return(Task.FromResult(true));
            };
            mirai.DisconnectedEvt += async(sender, exception) =>
            {
                while (true)
                {
                    try
                    {
                        await mirai.ConnectAsync(options, qq); // 连到成功为止, QQ号自填, 你也可以另行处理重连的 behaviour

                        return(true);
                    }
                    catch (Exception)
                    {
                        await Task.Delay(1000);
                    }
                }
            };

            while (true)
            {
                if (await Console.In.ReadLineAsync() == "exit")
                {
                    return;
                }
            }
        }
示例#3
0
        public async Task <bool> NewFriendApply(MiraiHttpSession session, INewFriendApplyEventArgs e)
        {
            await session.HandleNewFriendApplyAsync(e, FriendApplyAction.Allow);

            return(true);
        }
示例#4
0
        private static async System.Threading.Tasks.Task <bool> Session_NewFriendApplyEvt(MiraiHttpSession sender, INewFriendApplyEventArgs e)
        {
            await session.HandleNewFriendApplyAsync(e, FriendApplyAction.Allow);

            return(false);
        }
示例#5
0
 public static Task HandleNewFriendApplyAsync(IApplyResponseArgs args, FriendApplyAction action)
 => session.HandleNewFriendApplyAsync(args, action);