コード例 #1
0
        public static void SendMessage(CommonMessageResponse resp)
        {
            var msg = (resp.EnableAt && resp.MessageType != MessageType.Private ? new At(resp.UserId) + " " : "") +
                      resp.Message;
            var info = SessionInfo[resp.Identity] == null
                ? $"{resp.Identity.Type}{resp.Identity.Id}"
                : SessionInfo[resp.Identity].Name;
            string status;

            switch (resp.MessageType)
            {
            case MessageType.Group:
                status = CqApi.SendGroupMessageAsync(resp.GroupId, msg).Status;
                break;

            case MessageType.Discuss:
                status = CqApi.SendDiscussMessageAsync(resp.DiscussId, msg).Status;
                break;

            case MessageType.Private:
                status = CqApi.SendPrivateMessageAsync(resp.UserId, msg).Status;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            Message(string.Format("({0}) 我: {{status: {1}}}\r\n  {2}", info, status, CqCode.DecodeToString(msg)));
        }
コード例 #2
0
ファイル: DragonDetectorAlpha.cs プロジェクト: lsahi/Daylily
        /// <summary>
        /// 核心识别by sahuang
        /// </summary>
        private void RunDetector(object pathList)
        {
            var list = (List <string>)pathList;

            foreach (var fullPath in list)
            {
                try
                {
                    //Thread.Sleep(6000);
                    //continue;
                    if (_proc != null)
                    {
                        if (!_proc.HasExited)
                        {
                            _proc.Kill();
                        }
                        _proc = null;
                    }

                    _proc = new Process
                    {
                        StartInfo =
                        {
                            FileName  = "python3", // python3 dragon-detection.py "root"
                            Arguments =
                                $"{Path.Combine(Domain.CurrentDirectory, "dragon", "dragon-detection.py")} \"{fullPath}\"",
                            CreateNoWindow         = true,
                            UseShellExecute        = false,
                            WindowStyle            = ProcessWindowStyle.Hidden,
                            RedirectStandardOutput = true, // 重定向标准输出
                            RedirectStandardError  = true  // 重定向错误输出
                                                           //StartInfo.StandardOutputEncoding = Encoding.UTF8;
                        }
                    };

                    _proc.OutputDataReceived += ProcOutputReceived;
                    _proc.ErrorDataReceived  += ProcErrorReceived;

                    Logger.Origin("正在调用中");
                    _proc.Start();
                    _proc.BeginOutputReadLine();
                    _proc.BeginErrorReadLine();

                    _proc.WaitForExit();
                    ProcExited();
                }
                catch (Exception ex)
                {
                    Logger.Exception(ex);
                }
                finally
                {
                    _totalCount--;
                }
            }

            if (_currentCount <= 0)
            {
                return;
            }

            //CqApi.SetGroupBan(group, user, rnd.Next(1, 100 * dragonCount + 1) * 60);
            if (_group != "133605766")
            {
                CqApi.SendGroupMessageAsync(_group, new At(_user) + " 你龙了?");
            }
            else
            {
                CqApi.DeleteMessage(_messageId);
            }
            if (_currentCount <= 1)
            {
                return;
            }
            Thread.Sleep(8000);
            CqApi.SetGroupBan(_group, _user, Rnd.Next(1, 100 * _currentCount + 1) * 60);
            //CqApi.SendGroupMessageAsync(group, "而且有好多张,送你" + dragonCount + "倍套餐!!");
        }