Exemplo n.º 1
0
 private void SerOpenRemind_Tick(object sender, EventArgs e)
 {
     timer.Enabled = false;
     for (int i = 0; i < Config.serList.GetLength(0); i++)
     {
         bool flag = Config.serList[i, 3] != "1";
         if (!flag)
         {
             string   ip    = Config.serList[i, 2];
             string[] array = Config.serList[i, 4].Split(new char[]
             {
                 '|'
             });
             string text    = string.Empty;
             string bigSer  = Config.serList[i, 0];
             string serName = Config.serList[i, 1];
             if (Jx3OpenTell.IsOpen(ip, 3724))
             {
                 text = CQCode.SendLink("开服监控", CQCode.GetQQHead(_mahuaApi.GetLoginQq()), bigSer + " " + serName + " 开服了!");
                 array.Where(p => p != "List").ToList().ForEach(p => { _mahuaApi.SendGroupMessage(p, text); });
                 Config.serList[i, 3] = "0";
                 Config.serList[i, 4] = "List";
             }
         }
     }
     timer.Enabled = true;
 }
Exemplo n.º 2
0
        public void GoServerQuery(string clu, string serverstr)
        {
            string serName = serverstr.Trim();
            string ip      = string.Empty;
            string bigSer  = string.Empty;

            for (int i = 0; i < Config.serList.GetLength(0); i++)
            {
                if (serName.Equals(Config.serList[i, 1]))
                {
                    ip     = Config.serList[i, 2];
                    bigSer = Config.serList[i, 0];
                    string content = Jx3OpenTell.IsOpen(ip, 3724) ? (bigSer + " " + serName + "\r\n开") : (bigSer + " " + serName + "\r\n关");
                    _mahuaApi.SendGroupMessage(clu, CQCode.SendLink("开服查询", CQCode.GetQQHead(_mahuaApi.GetLoginQq()), content));
                    return;
                }
                else
                {
                    if (i == Config.serList.GetLength(0) - 1)
                    {
                        _mahuaApi.SendGroupMessage(clu, " 对不起,没有找到服务器 (づ╥﹏╥)づ");
                    }
                }
            }
        }
Exemplo n.º 3
0
        public static void SayGoodHandle(CQGroupMessageEventArgs e)
        {
            //解析参数
            CQCode cqat = e.FromQQ.CQCode_At();
            var    qq   = e.FromQQ.Id;

            //获取个人信息
            if (!Game.Players.ContainsKey(qq))
            {
                FixStroy.WarnNoCreateUser(e);
                return;
            }
            var p = Game.Players[qq];

            p.SetEIn(e);

            //展示信息
            p.XW += 1;
            foreach (var c in Common.Word)
            {
                if (e.Message.Text.Contains(c))
                {
                    e.FromGroup.SendGroupMessage(cqat, " ", "夸群主的都是好人!修为+1");
                    return;
                }
            }
        }
Exemplo n.º 4
0
        //获取今日状况
        private static void GetTodayMes(CQGroupMessageEventArgs e, Player p)
        {
            CQCode cqat = e.FromQQ.CQCode_At();

            int    code;
            string name;

            //如果已经查询过
            if (Game.IntRecord.Get("上次查询节日信息") == DateTime.Now.DayOfYear)
            {
                code = Game.IntRecord.Get("节日代码");
                name = Game.StrRecord.Get("节日名");
            }
            else
            {
                //格式形如:2020-10-1
                var            url = @"http://holiday.zhusaidong.cn/api.php?date=" + $"{DateTime.Now.Year}-{DateTime.Now.Month}-{DateTime.Now.Day}";
                HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);

                HttpWebResponse resp = (HttpWebResponse)req.GetResponse();

                string html   = new StreamReader(resp.GetResponseStream()).ReadToEnd();
                var    RESULT = Regex.Match(html, "\"code\":(\\d).*\"Name\":\"(.*?)\"");
                code = int.Parse(RESULT.Groups[1].Value);
                name = RESULT.Groups[2].Value;
                //e.FromGroup.SendGroupMessage(cqat, " ", $"{code}{name}");
                Game.IntRecord.Set("上次查询节日信息", DateTime.Now.DayOfYear);
            }

            if (code == 1)
            {
                p.XW += 100;
                e.FromGroup.SendGroupMessage(cqat, " ", $"{name}快乐!100点修为已经送入你的账户~");
            }
        }
Exemplo n.º 5
0
 public override void ProcessRequset(GroupMessageReceivedContext msg, AnalysisMsg nowModel)
 {
     if (Config.ConfigModel.IsFuncOpen("签到"))
     {
         if (msg.Message == "签到")
         {
             var    signEnt = DALSign.GetSign(msg.FromQq);
             bool   signed  = false;
             string content = $"给小可爱10个赞!\r\n麻花疼:每天每Q最多点500赞~先到先得!";
             if (signEnt != null)
             {
                 signed = (signEnt.LastSign.Date == DateTime.Now.Date);
                 if (signed)
                 {
                     content = $"您于{signEnt.LastSign.ToShortTimeString()}在{(signEnt.SignGid == msg.FromGroup ? "本群" : "隔壁群")}签过到了!\r\n没有多的赞惹TuT";
                 }
             }
             if (!signed)
             {
                 SendLike(msg.FromQq);
                 DALSign.SetSign(msg.FromQq, msg.FromGroup);
             }
             _mahuaApi.SendGroupMessage(msg.FromGroup).
             Text(CQCode.SendLink(signed ? "您签过到了!" : "签到成功!", CQCode.GetQQHead(msg.FromQq), content))
             .Done();
             return;
         }
     }
     successor.ProcessRequset(msg, nowModel);
 }
Exemplo n.º 6
0
        public CQCode GetRandCos()
        {
            //https://moe.ci/api.php https://moe.ci/Store/03-808P/0448.jpg
            var url = HttpNet.GetRedirectUrl("https://moe.ci/api.php");

            return(CQCode.CQImage(url, useCache: true));
        }
Exemplo n.º 7
0
        public void OpenTwitterMonitor()
        {
            var function = new Action <TweeterMonitor, Tweet>(async delegate(TweeterMonitor sender, Tweet tweet)
            {
                var content = GetTweetContent(tweet);
                content.Insert(0, CQCode.CQText($"您监控的{sender.Mark}有新的推文了\n"));
                var sendConfig = _config.Items.Single(c => c.Mark.ToString() == sender.Mark);
                if (sendConfig.Group != null)
                {
                    foreach (var item in sendConfig.Group)
                    {
                        await _soraApi.SendGroupMessage(item, content);
                    }
                }

                if (sendConfig.Private != null)
                {
                    foreach (var item in sendConfig.Private)
                    {
                        await _soraApi.SendPrivateMessage(item, content);
                    }
                }
            });
            var     client  = new WebClient();
            Twitter twitter = new Twitter(ref client);

            foreach (var tw in _config.Items.Select(item => new TweeterMonitor(item.Mark.ToString(), twitter)
            {
                TimeInterval = 60
            }))
            {
                tw.NewTweetEvent += function;
                tw.Start();
            }
        }
Exemplo n.º 8
0
        public void GoServerRemind(string clu, string serverstr)
        {
            string serName = serverstr.Trim();
            string bigSer  = string.Empty;

            for (int i = 0; i < Config.serList.GetLength(0); i++)
            {
                if (serName.Equals(Config.serList[i, 1]))
                {
                    bool existflag = false;
                    bigSer = Config.serList[i, 0];
                    Config.serList[i, 3] = "1";
                    string[] cluList = Config.serList[i, 4].Split('|');
                    foreach (var istr in cluList)
                    {
                        if (istr == clu + "")
                        {
                            existflag = true;
                        }
                    }
                    if (!existflag)
                    {
                        Config.serList[i, 4] += "|" + clu;
                    }
                    _mahuaApi.SendGroupMessage(clu, CQCode.SendLink("开服监控", CQCode.GetQQHead(_mahuaApi.GetLoginQq()), "已为您开启 " + serName + "的监控~请关注群信息,将第一时间通知到群。"));
                    timer.Enabled = true;
                    return;
                }
                else if (i == Config.serList.GetLength(0) - 1)
                {
                    _mahuaApi.SendGroupMessage(clu, " 对不起,没有找到服务器 (づ╥﹏╥)づ \n监控开启失败");
                }
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// 预处理消息队列
        /// </summary>
        /// <param name="content">消息数据</param>
        internal static List <CQCode> ToCQCodeList(this object[] content)
        {
            if (content == null)
            {
                throw new ArgumentNullException(nameof(content));
            }
            List <CQCode> msgList = new();

            foreach (var msgObj in content)
            {
                switch (msgObj)
                {
                case CQCode cqCode:
                    msgList.Add(cqCode);
                    break;

                case IEnumerable <CQCode> cqCodes:
                    msgList.AddRange(cqCodes);
                    break;

                default:
                    msgList.Add(CQCode.CQText(msgObj.ToString()));
                    break;
                }
            }

            return(msgList);
        }
Exemplo n.º 10
0
        /// <summary>
        /// 用于处理传入指令
        /// </summary>
        public async void GetChat()
        {
            ConfigManager configManager = new ConfigManager(HsoEventArgs.LoginUid);

            configManager.LoadUserConfig(out UserConfig userConfig);
            if (CheckGroupBlock(userConfig))
            {
                return;
            }
            if (CheckInCD.isInCD(HsoEventArgs.SourceGroup, HsoEventArgs.Sender))
            {
                await HsoEventArgs.SourceGroup.SendGroupMessage(CQCode.CQAt(HsoEventArgs.Sender), "你是不是只会要色图");

                return;
            }

            //检查色图文件夹大小
            if (IOUtils.GetHsoSize() >= userConfig.HsoConfig.SizeLimit * 1024 * 1024)
            {
                Log.Warning("Hso", "色图文件夹超出大小限制,将清空文件夹");
                Directory.Delete(IOUtils.GetHsoPath(), true);
            }

            await GiveMeSetu(userConfig.HsoConfig);
        }
Exemplo n.º 11
0
 private void SerOpenRemind_Tick(object sender, EventArgs e)
 {
     timer.Enabled = false;
     for (int i = 0; i < Config.serList.GetLength(0); i++)
     {
         bool flag = Config.serList[i, 3] != "1";
         if (!flag)
         {
             string   ip    = Config.serList[i, 2];
             string[] array = Config.serList[i, 4].Split(new char[]
             {
                 '|'
             });
             string text  = string.Empty;
             string str   = Config.serList[i, 0];
             string str2  = Config.serList[i, 1];
             bool   flag2 = !Jx3OpenTell.IsOpen(ip, 3724);
             if (!flag2)
             {
                 text = CQCode.SendLink("开服监控", CQCode.GetQQHead(_mahuaApi.GetLoginQq()), str + " " + str2 + " 开服了!");
                 for (int j = 1; j < array.Length; j++)
                 {
                     _mahuaApi.SendGroupMessage(array[j], text);
                 }
                 Config.serList[i, 3] = "0";
                 Config.serList[i, 4] = "List";
             }
         }
     }
     timer.Enabled = true;
 }
Exemplo n.º 12
0
        public static async ValueTask <CQCode> Image(string url, CQFileType type = default, IHttpClientFactory httpClientFactory = default)
        {
            HttpClient client;

            byte[] data;
            switch (type)
            {
            case CQFileType.Url:
                return(CQCode.CQImage(url));

            case CQFileType.Base64:
                client = httpClientFactory == default ? new HttpClient() : httpClientFactory.CreateClient("default");
                data   = await client.GetByteArrayAsync(url);

                return(CQCode.CQImage("base64://" + Convert.ToBase64String(data)));

            case CQFileType.File:
                Uri uri = new(url);
                client = httpClientFactory == default ? new HttpClient() : httpClientFactory.CreateClient("default");
                data   = await client.GetByteArrayAsync(uri);

                var filePath = ImageCachePath + HashHelp.MD5Encrypt(data) + Path.GetExtension(uri.Segments.Last());
                await File.WriteAllBytesAsync(filePath, data);

                return(CQCode.CQImage(new Uri(filePath).AbsoluteUri));

            default:
                return(null);
            }
        }
Exemplo n.º 13
0
        public static void LearnHandle(CQGroupMessageEventArgs e)
        {
            //解析参数
            CQCode cqat = e.FromQQ.CQCode_At();
            var    mes  = e.Message.Text;

            //
            if (mes == "教学")
            {
                e.FromGroup.SendGroupMessage(cqat, " ", @"很高兴你打开了教学~
1.请尝试输入[签到],来开始游戏
2.未来你可能会对一些游戏机制感到困惑,你可以随时回到这儿来查看
3.使用[教学#词条]来查看收录了哪些词条");
            }
            if (mes == "教学#词条")
            {
                e.FromGroup.SendGroupMessage(cqat, " ", @"1.[判定]");
            }
            //获取个人信息
            e.FromGroup.SendGroupMessage(cqat, " ", @"这是一个关于判定的教学
            1.游戏中有所有涉及随机数的地方,都需要判定
            2.例如[乞灵境]的渡劫概率就只有40%
            3.当你在判定的时候,会抛出一个百面骰,上面会随机展示一个数字
            4.例如抛出了42,这是一个比40大的数字,那么很可惜,你渡劫会失败
            5.但如果你幸运数值为4,那么42-4=38才是你的真实数字~,你的渡劫会成功");
        }
Exemplo n.º 14
0
 /// <summary>
 /// 触发加分
 /// </summary>
 /// <param name="eventArgs"></param>
 /// <param name="userConfig"></param>
 /// <returns></returns>
 private async ValueTask TriggerCute(GroupMessageEventArgs eventArgs, UserConfig userConfig)
 {
     if (new Random().Next(1, 100) is 66)
     {
         var user = _userServices.QueryById(q => q.QNumber == eventArgs.SenderInfo.UserId.ObjToString());
         var rank = new Random().Next(1, 10);
         if (user == null)
         {
             await eventArgs.Reply(CQCode.CQAt(eventArgs.SenderInfo.UserId), $"未找到{userConfig.ConfigModel.NickName}任何记录,奖励下发失败~");
         }
         else
         {
             user.Rank          += rank;
             user.LastModifyTime = DateTime.Now;
             _userServices.Update(user);
             _logsServices.Insert(new SignLogs()
             {
                 CmdType    = CmdType.BonusPoints,
                 LogContent = $"[可爱]指令赠送{rank}分",
                 ModifyRank = rank,
                 Uid        = eventArgs.SenderInfo.UserId.ObjToString()
             });
             await eventArgs.Reply(CQCode.CQAt(eventArgs.SenderInfo.UserId), $"看{userConfig.ConfigModel.NickName}这么可爱,就奖励{userConfig.ConfigModel.NickName}{rank}分~");
         }
     }
 }
Exemplo n.º 15
0
 public static void CheckMethod()
 {
     while (true)
     {
         Thread.Sleep(CheckSpan);
         lock (_lock)
         {
             Task.Run(async() =>
             {
                 var now  = DateTime.Now;
                 var bots = Program.QQServer.GetBotList();
                 var msgs = await TipMessageService.GetTipMessages(TipMessage.TipTargetType.QQGroup, now);
                 foreach (var msg in msgs)
                 {
                     foreach (var bot in bots)
                     {
                         var api = Program.QQServer.GetSoraApi(bot);
                         if (await api.CheckHasGroup(msg.TargetID))
                         {
                             ConsoleLog.Debug("TipMessage", $"Send tip message to group {msg.TargetID} with bot {bot}");
                             var m = new ArrayList
                             {
                                 "[Tip Message]",
                                 Environment.NewLine
                             };
                             int n = 0;
                             int i = msg.Message.IndexOf("[@all]", n);
                             while (i < msg.Message.Length && i >= n)
                             {
                                 m.Add(msg.Message[n..i]);
                                 m.Add(CQCode.CQAtAll());
                                 i = msg.Message.IndexOf("[@all]", n = i + 6);
                             }
                             m.Add(msg.Message[n..]);
Exemplo n.º 16
0
        public void GoServerQuery(string clu, string str)
        {
            bool   flag = false;
            string text = str.Trim();
            string ip   = string.Empty;
            string str2 = string.Empty;

            for (int i = 0; i < Config.serList.GetLength(0); i++)
            {
                bool flag2 = text.Equals(Config.serList[i, 1]);
                if (flag2)
                {
                    ip   = Config.serList[i, 2];
                    str2 = Config.serList[i, 0];
                    string content = Jx3OpenTell.IsOpen(ip, 3724) ? (str2 + " " + text + "\r\n开") : (str2 + " " + text + "\r\n关");
                    _mahuaApi.SendGroupMessage(clu, CQCode.SendLink("开服查询", CQCode.GetQQHead(_mahuaApi.GetLoginQq()), content));
                    flag = true;
                }
                else
                {
                    bool flag3 = !flag && i == Config.serList.GetLength(0) - 1;
                    if (flag3)
                    {
                        _mahuaApi.SendGroupMessage(clu, " 对不起,没有找到服务器 (づ╥﹏╥)づ");
                    }
                }
            }
        }
Exemplo n.º 17
0
        public static void InhomeHandle(CQGroupMessageEventArgs e)
        {
            //解析参数
            CQCode cqat  = e.FromQQ.CQCode_At();
            var    qq    = e.FromQQ.Id;
            var    codes = e.Message.CQCodes;

            //获取个人信息
            if (!Game.Players.ContainsKey(qq))
            {
                FixStroy.WarnNoCreateUser(e);
                return;
            }
            var p = Game.Players[qq];

            p.SetEIn(e);

            if (p.LevelNum < 6)
            {
                p.SendMes($"境界达到问灵境才可以闭关");
                return;
            }

            //执行闭关
            p.StatusStr.Set("闭关", "true");

            p.StatusInt.Set("入关年", DateTime.Now.Year);

            p.StatusInt.Set("入关月", DateTime.Now.Month);
            p.StatusInt.Set("入关日", DateTime.Now.Day);
            p.SendMes("你已经开始闭关,闭关期间,你无法进行各种活动。如果你是考生,祝你考试顺心如意;如果你要好好工作了~希望你可以实现自己的梦想!");
        }
Exemplo n.º 18
0
        /// <summary>
        /// 发送私聊消息
        /// </summary>
        /// <param name="userId">发送目标用户id</param>
        /// <param name="message">消息</param>
        /// <returns>
        /// <para><see cref="APIStatusType"/> API执行状态</para>
        /// <para><see langword="messageId"/> 消息ID</para>
        /// </returns>
        public async ValueTask <(APIStatusType apiStatus, int messageId)> SendPrivateMessage(long userId, params object[] message)
        {
            if (userId < 10000)
            {
                throw new ArgumentOutOfRangeException($"{nameof(userId)} too small");
            }
            if (message.Length == 0)
            {
                throw new NullReferenceException(nameof(message));
            }
            //消息段列表
            List <CQCode> msgList = new List <CQCode>();

            foreach (object msgObj in message)
            {
                if (msgObj is CQCode cqCode)
                {
                    msgList.Add(cqCode);
                }
                else if (msgObj is IEnumerable <CQCode> cqCodes)
                {
                    msgList.AddRange(cqCodes);
                }
                else
                {
                    msgList.Add(CQCode.CQText(msgObj.ToString()));
                }
            }
            return(((APIStatusType apiStatus, int messageId)) await ApiInterface.SendPrivateMessage(this.ConnectionGuid, userId, msgList));
        }
Exemplo n.º 19
0
        /// <summary>
        /// 获取酷Q "音乐自定义" 代码
        /// </summary>
        /// <param name="url">分享链接, 点击后进入的页面 (歌曲介绍)</param>
        /// <param name="musicUrl">歌曲链接, 音频链接 (mp3链接)</param>
        /// <param name="title">标题, 建议12字以内</param>
        /// <param name="content">简介, 建议30字以内</param>
        /// <param name="imageUrl">封面图片链接, 留空为默认</param>
        /// <exception cref="ArgumentException">参数: url 或 musicUrl 是空字符串或为 null</exception>
        /// <returns>返回 <see cref="CQCode"/> 对象</returns>
        public static CQCode CQCode_DIYMusic(string url, string musicUrl, string title = null, string content = null, string imageUrl = null)
        {
            if (string.IsNullOrEmpty(url))
            {
                throw new ArgumentException("分享链接不能为空", "url");
            }

            if (string.IsNullOrEmpty(musicUrl))
            {
                throw new ArgumentException("歌曲链接不能为空", "musicUrl");
            }

            CQCode code = new CQCode(
                CQFunction.Music,
                new KeyValuePair <string, string> ("type", "custom"),
                new KeyValuePair <string, string> ("url", url),
                new KeyValuePair <string, string> ("audio", musicUrl));

            if (!string.IsNullOrEmpty(title))
            {
                code.Items.Add("title", title);
            }

            if (!string.IsNullOrEmpty(content))
            {
                code.Items.Add("content", content);
            }

            if (!string.IsNullOrEmpty(imageUrl))
            {
                code.Items.Add("imageUrl", imageUrl);
            }
            return(code);
        }
Exemplo n.º 20
0
        /// <summary>
        /// 获取酷Q "链接分享" 代码
        /// </summary>
        /// <param name="url">分享的链接</param>
        /// <param name="title">显示的标题, 建议12字以内</param>
        /// <param name="content">简介信息, 建议30字以内</param>
        /// <param name="imageUrl">分享的图片链接, 留空则为默认图片</param>
        /// <exception cref="ArgumentException">参数: url 是空字符串或为 null</exception>
        /// <returns>返回 <see cref="CQCode"/> 对象</returns>
        public static CQCode CQCode_ShareLink(string url, string title, string content, string imageUrl = null)
        {
            if (string.IsNullOrEmpty(url))
            {
                throw new ArgumentException("分享的链接为空", "url");
            }

            CQCode code = new CQCode(
                CQFunction.Share,
                new KeyValuePair <string, string> ("url", url));

            if (!string.IsNullOrEmpty(title))
            {
                code.Items.Add("title", title);
            }
            if (!string.IsNullOrEmpty(content))
            {
                code.Items.Add("content", content);
            }
            if (!string.IsNullOrEmpty(imageUrl))
            {
                code.Items.Add("image", imageUrl);
            }

            return(code);
        }
Exemplo n.º 21
0
 public override void ProcessRequset(GroupMessageReceivedContext msg, AnalysisMsg nowModel)
 {
     if (Config.ConfigModel.IsFuncOpen("查日常"))
     {
         WeiBoContentItem item = new WeiBoContentItem();
         if (nowModel.What == "查日常")
         {
             if (lastestItem != null)
             {
                 item = lastestItem.Time.Date == DateTime.Now.Date ? lastestItem : WeiboTool.GetWeiboByUid("1761587065", "1076031761587065", "#剑网3江湖百晓生#").OrderByDescending(p => p.Time).FirstOrDefault(); //WeiboTool.GetWeiBoTopicContentV1("剑网3江湖百晓生", "剑网3官方微博").FirstOrDefault();
             }
             else
             {
                 item = WeiboTool.GetWeiboByUid("1761587065", "1076031761587065", "#剑网3江湖百晓生#").OrderByDescending(p => p.Time).FirstOrDefault();//WeiboTool.GetWeiBoTopicContentV1("剑网3江湖百晓生", "剑网3官方微博").OrderByDescending(p => p.Time).FirstOrDefault();
             }
             if (item == null)
             {
                 _mahuaApi.SendGroupMessage(msg.FromGroup, "[日常]QAQ查询失败,请联系管理员");
             }
             else
             {
                 if (nowModel.Who == "文")
                 {
                     _mahuaApi.SendGroupMessage(msg.FromGroup).Text("[日常]来自 " + item.Author + ":").Newline().Text(item.ContentStr).Newline().Text(@"本信息由新浪微博-剑网3江湖百晓生-超话提供").Done();
                 }
                 else
                 {
                     _mahuaApi.SendGroupMessage(msg.FromGroup).Text(CQCode.SendLink("查日常-" + item.Time.ToShortDateString(), item.Pic, item.ContentStr.Replace("#剑网3江湖百晓生#", "").Trim(), item.Pic)).Done();
                 }
             }
         }
     }
     successor.ProcessRequset(msg, nowModel);
 }
Exemplo n.º 22
0
        public static async void GetIllustDetail(SoraMessage e, int id)
        {
            var detail = await Illust.Get(id);

            if (detail == null)
            {
                await e.ReplyToOriginal("数据获取失败,请稍后再试");
            }
            else
            {
                ArrayList msg = new();
                foreach (var img in detail.Images)
                {
                    msg.Add(CQCode.CQImage(ImageUrls.ToPixivCat(img.Medium)));
                }
                msg.Add(new StringBuilder().AppendLine()
                        .AppendLine(detail.Title)
                        .AppendLine($"Author: {detail.Author}")
                        .AppendLine(detail.Caption)
                        .AppendLine($"Tags: {string.Join(" | ", detail.Tags)}")
                        .AppendLine($"Publish Date: {detail.CreateDate:yyyy-MM-dd hh:mm:ss}")
                        .AppendLine($"Bookmarks: {detail.TotalBookmarks} Comments:{detail.TotalComments} Views:{detail.TotalView}")
                        .Append(detail.Url)
                        .ToString());
                await e.Reply(msg.ToArray());

                await e.RemoveCoins(5);
            }
        }
Exemplo n.º 23
0
        /// <summary>
        /// 获取CQ码中的图片网址
        /// </summary>
        /// <param name="imageCQCode">需要解析的图片CQ码</param>
        /// <returns></returns>
        public static string GetImageURL(string imageCQCode)
        {
            string    path  = MainSave.ImageDirectory + CQCode.Parse(imageCQCode)[0].Items["file"] + ".cqimg";
            IniConfig image = new IniConfig(path);

            image.Load();
            return(image.Object["image"]["url"].ToString());
        }
Exemplo n.º 24
0
 /// <summary>
 /// 私聊处理
 /// </summary>
 public static async ValueTask PrivateMessageParse(object sender, PrivateMessageEventArgs privateMessage)
 {
     //简单的机器人响应
     if (privateMessage.Message.RawText.Equals("在"))
     {
         await privateMessage.Sender.SendPrivateMessage(CQCode.CQImage("https://i.loli.net/2020/11/02/2OgZ1M6YNV5kntS.gif"));
     }
 }
Exemplo n.º 25
0
 /// <summary>
 /// 收到群消息
 /// </summary>
 /// <param name="sender">事件来源</param>
 /// <param name="e">事件参数</param>
 public void GroupMessage(object sender, CQGroupMessageEventArgs e)
 {
     if (e.Message.Text.Length >= 4 && e.Message.Text.StartsWith(".龙约"))
     {
         CQCode cqat = e.FromQQ.CQCode_At();
         e.FromGroup.SendGroupMessage(cqat, " 找到结果如下,数据仅供参考\n" + DragaliaLost.chaincoab(e.Message.Text));
     }
 }
Exemplo n.º 26
0
        public static void ShowStatusHandle(CQGroupMessageEventArgs e)
        {
            //解析参数
            CQCode cqat = e.FromQQ.CQCode_At();

            //展示信息
            e.FromGroup.SendGroupMessage(cqat, " ", Face.RandomFace(), Game.IntRecord.Report());
        }
Exemplo n.º 27
0
        /// <summary>
        /// 数据库发生错误时的消息提示
        /// </summary>
        public static async ValueTask DatabaseFailedTips(GroupMessageEventArgs groupEventArgs)
        {
            await groupEventArgs.SourceGroup.SendGroupMessage(CQCode.CQAt(groupEventArgs.Sender.Id),
                                                              "\r\nERROR",
                                                              "\r\n数据库错误");

            ConsoleLog.Error("database", "database error");
        }
Exemplo n.º 28
0
        static async Task SendGif(SoraMessage e, Image <Rgba32> gif)
        {
            var file = Path.GetTempFileName();

            SaveGif(gif, file);
            await e.Reply(CQCode.CQImage(file));

            await e.RemoveCoins(5);
        }
Exemplo n.º 29
0
        private string GetResultStr(bool sendImg = false)
        {
            string rs;
            int    star3Count = 0;
            int    star2Count = 0;
            int    star1Count = 0;
            int    pigStone   = 0;
            string star3Name  = string.Empty;

            if (GetResult.ContainsKey(1) && GetResult[1] != null)
            {
                foreach (var temp in GetResult[1])
                {
                    star1Count += temp.Value;
                    pigStone   += temp.Value;
                }
            }
            if (GetResult.ContainsKey(2) && GetResult[1] != null)
            {
                foreach (var temp in GetResult[2])
                {
                    star2Count += temp.Value;
                    pigStone   += temp.Value * 10;
                }
            }
            if (GetResult.ContainsKey(3) && GetResult[3] != null)
            {
                int i = 1;
                foreach (var temp in GetResult[3])
                {
                    star3Count += temp.Value;
                    pigStone   += temp.Value * 50;
                    star3Name  += temp.Key + "×" + temp.Value + (i++ % 3 == 0?"\n":"  ");
                }
            }
            string ImgP = string.Empty;
            CQCode imgC = null;

            if (sendImg)
            {
                ImgP = GetResultImg();
                if (ImgP != null)
                {
                    imgC = CQApi.CQCode_Image(ImgP);
                    ImgP = imgC.ToSendString();
                }
                else
                {
                    ImgP = string.Empty;
                }
            }
            return(rs = "素敵な仲間が増えますよ!\n" + ImgP +
                        MyString.str["恭喜骑士君获得"] + "\n" +
                        star3Name + "\n" +
                        "★★★×" + star3Count + "★★×" + star2Count + "★×" + star1Count + "\n" +
                        MyString.str["获得母猪石×"] + pigStone);
        }
Exemplo n.º 30
0
        public static int CQ_sendGroupMsg(int authcode, long groupid, IntPtr msg)
        {
            if (Save.GroupList.TroopList.Any(x => x.GroupId == groupid) is false)
            {
                LogHelper.WriteLog(LogLevel.Warning, "消息无法投递", $"此账号未加入群 {groupid} ,无法发送消息");
            }
            Stopwatch sw = new Stopwatch();

            sw.Restart();
            string        text       = msg.ToString(GB18030);
            string        textBackup = msg.ToString(GB18030);
            string        url        = $@"{Save.url}v1/LuaApiCaller?qq={Save.curentQQ}&funcname=SendMsg";
            JObject       data;
            List <CQCode> cqCodeList = CQCode.Parse(text);

            if (text.Contains("[CQ:image") || text.Contains("[CQ:record"))
            {
                data = new JObject
                {
                    { "toUser", groupid },
                    { "sendToType", 2 },
                    { "groupid", 0 },
                    { "fileMd5", "" },
                    { "atUser", 0 }
                };
            }
            else
            {
                url += "V2";
                data = new JObject
                {
                    { "ToUserUid", groupid },
                    { "SendToType", 2 }
                };
            }
            CQCodeHelper.Progeress(cqCodeList, ref data, ref text);
            string pluginname = appInfos.Find(x => x.AuthCode == authcode).Name;

            if (Save.TestPluginsList.Any(x => x == pluginname))
            {
                Save.TestPluginChatter.Invoke(new System.Windows.Forms.MethodInvoker(() =>
                {
                    Save.TestPluginChatter.SelectionColor = Color.Green;
                    Save.TestPluginChatter.AppendText($"[{DateTime.Now:HH:mm:ss}] 插件发送消息: {textBackup}\n");
                }));
                return(0);
            }
            else
            {
                int logid = LogHelper.WriteLog(LogLevel.InfoSend, pluginname, "[↑]发送消息", $"群号:{groupid} 消息:{msg.ToString(GB18030)}", "处理中...");
                WebAPI.SendRequest(url, data.ToString());
                sw.Stop();
                LogHelper.UpdateLogStatus(logid, $"√ {sw.ElapsedMilliseconds / (double)1000:f2} s");
                return(Save.MsgList.Count + 1);
            }
        }