示例#1
0
        public void ProcessGroupMessage(GroupMessageReceivedContext context)
        {
            var ats = CQNumberHelper.GetAtQQ(context.Message)?.ToList();

            if (ats != null && ats.Contains(_mahuaApi.GetLoginQq()) && (context.Message.Contains("--help") || context.Message.Contains("-h")))
            {
                _mahuaApi.SendGroupMessageExtension(context.FromGroup, RuntimeConfig.Config.HelpText);
            }
        }
示例#2
0
        public void ProcessGroupMessage(GroupMessageReceivedContext context)
        {
            var content = context.Message;
            var ats     = CQNumberHelper.GetAtQQ(context.Message)?.ToList();

            if (ats == null || !ats.Contains(_mahuaApi.GetLoginQq()))
            {
                return;
            }

            var m = regex_date.Match(content);

            if (!m.Success || m.Length == 0)
            {
                return;
            }
            DateTime date    = DateTime.Now;
            string   dateStr = m.Groups[1].Value;

            switch (dateStr)
            {
            case "今日":
            case "今天":
                date = DateTime.Today;
                break;

            case "昨日":
            case "昨天":
                date = DateTime.Today.AddDays(-1);
                break;

            default:
                date = new DateTime(date.Year, int.Parse(m.Groups[3].Value), int.Parse(m.Groups[4].Value));
                break;
            }


            foreach (var item in RuntimeConfig.Config.GroupEventSerach)
            {
                if (!context.Message.Contains(item.Key))
                {
                    continue;
                }
                var logs = SearchEventLog(item, date, context.FromGroup);
                if (logs != null)
                {
                    SendMessage(logs.Data?.Items, logs.Data?.Total ?? 0, item, date, context.FromGroup);
                }
            }
        }
        public void ProcessGroupMessage(GroupMessageReceivedContext context)
        {
            var ats = CQNumberHelper.GetAtQQ(context.Message)?.ToList();

            if (ats != null && ats.Contains(_mahuaApi.GetLoginQq()))
            {
                if (context.Message.Contains("上传图片"))
                {
                    var result = UploadImageAsync(context).GetAwaiter().GetResult();
                    if (!string.IsNullOrEmpty(result))
                    {
                        _mahuaApi.SendGroupMessageExtension(context.FromGroup, result);
                        ILog logger = LogProvider.GetCurrentClassLogger();
                        logger.Info(result);
                    }
                }
            }
        }
示例#4
0
        public void ProcessGroupMessage(GroupMessageReceivedContext context)
        {
            var managerQQ = RuntimeConfig.Config.ManagerQq.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            var message   = context.Message;
            var fromQQ    = context.FromQq;
            var group     = context.FromGroup;
            var loginQQ   = _mahuaApi.GetLoginQq();

            if (managerQQ.Any(x => x == fromQQ))
            {
                var ats = CQNumberHelper.GetAtQQ(context.Message)?.ToList();
                if (!ats?.Any(x => x == loginQQ) ?? false)
                {
                    return;
                }
                //解除禁言
                if (message.IndexOf("解除禁言") > -1)
                {
                    foreach (var item in ats.Where(x => x != loginQQ))
                    {
                        _mahuaApi.RemoveBanGroupMember(group, item);
                    }
                }
                else
                {
                    var m = banRegex.Match(message);
                    //禁言
                    if (m.Success)
                    {
                        var time = Convert.ToDouble(m.Groups[1].Value);
                        foreach (var item in ats?.Where(x => x != loginQQ))
                        {
                            _mahuaApi.BanGroupMember(context.FromGroup, item, TimeSpan.FromMinutes(time));
                        }
                        return;
                    }
                    //修改复读禁言时间
                    m = repeatBanTimeChangeRegex.Match(message);
                    if (m.Success)
                    {
                        var time = Convert.ToDouble(m.Groups[1].Value);
                        if (time > 0)
                        {
                            RuntimeConfig.Config.RepeatMessageBanDuration = time;
                            RuntimeConfig.Save(AppSetting.ConfigFilePath, RuntimeConfig.Config.ToJosn());
                        }
                        return;
                    }
                    //修改复读禁言概率
                    m = repeatBanProbabilityChangeRegex.Match(message);
                    if (m.Success)
                    {
                        var time = Convert.ToDouble(m.Groups[1].Value);
                        if (time > 0)
                        {
                            RuntimeConfig.Config.RepeatMessageBanProbability = time;
                            RuntimeConfig.Save(AppSetting.ConfigFilePath, RuntimeConfig.Config.ToJosn());
                        }
                        return;
                    }
                }
            }
        }