public void ProcessFriendMessage(PrivateMessageFromFriendReceivedContext context)
        {
            // 戳一戳
            _mahuaApi.SendPrivateMessage(context.FromQq)
            .Shake()
            .Done();
            // 嘤嘤嘤
            _mahuaApi.SendPrivateMessage(context.FromQq)
            .Text("嘤嘤嘤:")
            .Newline()
            .Text(context.Message)
            .Done();

            // 将好友信息会发给好友
            _mahuaApi.SendPrivateMessage(context.FromQq, context.Message);

            _mahuaApi.SendPrivateMessage(context.FromQq)
            .Image(@"D:\logo.png")
            .Done();

            // 异步发送消息,不能使用 _mahuaApi 实例,需要另外开启Session
            Task.Factory.StartNew(() =>
            {
                using (var robotSession = MahuaRobotManager.Instance.CreateSession())
                {
                    var api = robotSession.MahuaApi;
                    api.SendPrivateMessage(context.FromQq, "异步的嘤嘤嘤");
                }
            });
        }
Example #2
0
 public void ProcessFriendMessage(PrivateMessageFromFriendReceivedContext context)
 {
     if (context.Message.Contains("嬲"))
     {
         bool     flag = false;
         TimeSpan time = DateTime.Now - Helper.dateTimeCD;
         flag = time.TotalSeconds > Helper.timeCD;
         if (flag)
         {
             string imageUrl = Helper.GetPath();
             if (imageUrl == null)
             {
                 _mahuaApi.SendPrivateMessage(context.FromQq).Text("正在获取最新图片").Done();
             }
             else
             {
                 Helper.dateTimeCD = DateTime.Now;
                 _mahuaApi.SendPrivateMessage(context.FromQq).Image(imageUrl).Done();
                 System.GC.Collect();
             }
         }
         else
         {
             _mahuaApi.SendPrivateMessage(context.FromQq).Text(string.Format("正在冷却,剩余{0}秒", ((int)(Helper.timeCD - time.TotalSeconds)).ToString())).Done();
         }
     }
 }
        public void ProcessFriendMessage(PrivateMessageFromFriendReceivedContext context)
        {
            // todo 填充处理逻辑
            // 戳一戳
            _mahuaApi.SendPrivateMessage(context.FromQq)
            .Shake()
            .Done();

            var text = (string)HttpUtil.getRequest("https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&rsv_idx=1&tn=baidu&wd=webClient&oq=%25E9%2585%25B7Q&rsv_pq=fc6735c100016728&rsv_t=f98e4FBjAbOPAuiNKru1GtR2JHdAl0PJ1PT8D%2BKxtwA3VR8EP24z1XXo3OU&rqlang=cn&rsv_enter=1&inputT=4494&rsv_sug3=15&rsv_sug1=14&rsv_sug7=100&rsv_n=2&rsv_sug2=0&rsv_sug4=5179", "utf-8", "utf-8");

            // 嘤嘤嘤,换行,重复消息
            _mahuaApi.SendPrivateMessage(context.FromQq)
            .Text("我是机器人:\r\n" + text)
            .Newline()
            .Text(context.Message)
            .Done();


            // 异步发送消息,不能使用 _mahuaApi 实例,需要另外开启Session
            Task.Factory.StartNew(() =>
            {
                using (var robotSession = MahuaRobotManager.Instance.CreateSession())
                {
                    var api = robotSession.MahuaApi;
                    api.SendPrivateMessage(context.FromQq, "芝麻");
                    //var tex2t = (string)HttpUtil.getRequest("http://demo.zentao.net/api-getsessionid.json", "utf-8", "utf-8");
                    Task.Delay(5000).Wait();
                    //api.SendPrivateMessage(context.FromQq, tex2t+"开门");
                    //api.SendPrivateMessage(context.FromQq, text);
                }
            });

            // 不要忘记在MahuaModule中注册
        }
Example #4
0
        public override void ProcessRequset(PrivateMessageFromFriendReceivedContext msg, AnalysisMsg nowModel)
        {
            if (msg.FromQq == Config.ConfigModel.MasterQQ)
            {
                if (nowModel.What == "反馈")
                {
                    _mahuaApi.SendGroupMessage(nowModel.Who).Text($"{nowModel.How}").Newline().Text("[来自作者的反馈]").Done();
                    return;
                }
                if (nowModel.What == "个人反馈")
                {
                    _mahuaApi.SendPrivateMessage(nowModel.Who).Text($"{nowModel.How}").Newline().Text("[来自作者的反馈]").Done();
                    return;
                }

                if (nowModel.What == "设日常")
                {
                    Config.DefaltItem = new WeiBoContentItem
                    {
                        Author     = "帅气的作者手动创建",
                        Time       = Convert.ToDateTime(nowModel.Who),
                        ContentStr = nowModel.How,
                        Pic        = @"https://traceless.site/"
                    };
                }
            }

            successor.ProcessRequset(msg, nowModel);
        }
 public void ProcessFriendMessage(PrivateMessageFromFriendReceivedContext context)
 {
     if (context.Message?.Contains("收到回复") == true)
     {
         var msg = context.Message.Replace("收到回复", string.Empty);
         _mahuaApi.SendPrivateMessage(context.FromQq, msg);
     }
 }
Example #6
0
        public void ProcessFriendMessage(PrivateMessageFromFriendReceivedContext context)
        {
            if (dbContext.Managers.FirstOrDefault(u => u.Enable && u.Account.Equals(context.FromQq)) == null) // 非管理员
            {
                return;
            }

            _ = Run(context);
        }
        public void ProcessFriendMessage(PrivateMessageFromFriendReceivedContext context)
        {
            // 获取好友列表
            var friends = _mahuaApi.GetFriends();

            // 测试好友消息发送
            _mahuaApi.SendPrivateMessage(context.FromQq, "这条消息将写入到日志当中");

            // 测试设置公告接口,需要本QQ在目标群具备管理员权限
            _mahuaApi.SetNotice("610394020", "测试公告", friends);
        }
 public override void ProcessRequset(PrivateMessageFromFriendReceivedContext msg, AnalysisMsg nowModel)
 {
     if (Config.ConfigModel.IsFuncOpen("建议"))
     {
         if (nowModel.What == "建议")
         {
             _mahuaApi.SendPrivateMessage(Config.ConfigModel.MasterQQ).Text($"来自个人{msg.FromQq}:{nowModel.Who} {nowModel.How}").Done();
             return;
         }
     }
     successor.ProcessRequset(msg, nowModel);
 }
        public void ProcessFriendMessage(PrivateMessageFromFriendReceivedContext context)
        {
            _friendMessageStore.InsertAsync(new InsertFriendMessageInput
            {
                Message      = context.Message,
                Qq           = context.FromQq,
                ReceivedTime = context.SendTime
            }).GetAwaiter().GetResult();
            var count = _friendMessageStore.GetCountAsync().GetAwaiter().GetResult();

            _mahuaApi.SendPrivateMessage(context.FromQq, $"存储中已经存在{count}条好友信息。");
        }
Example #10
0
 public void ProcessFriendMessage(PrivateMessageFromFriendReceivedContext context)
 {
     try
     {
         AnalysisMsg nowModel = new AnalysisMsg(context.Message);
         _MenuApp.ProcessRequset(context, nowModel);
     }
     catch (Exception ex)
     {
         _mahuaApi.SendPrivateMessage(Config.ConfigModel.MasterQQ).Text(ex.ToString());
     }
     // 不要忘记在MahuaModule中注册
 }
 public override void ProcessRequset(PrivateMessageFromFriendReceivedContext msg, AnalysisMsg nowModel)
 {
     if (Config.ConfigModel.IsFuncOpen("个人菜单"))
     {
         if (msg.Message.Trim() == "菜单")
         {
             _mahuaApi.SendPrivateMessage(msg.FromQq).Text(Config.ConfigModel.PrivateMenuStr).Done();
             _mahuaApi.SendPrivateMessage(msg.FromQq).Text(CQCode.SendLink("小T完全手册", CQCode.GetQQHead(_mahuaApi.GetLoginQq()), "小T操作手册:最新最全的小T使用攻略", "https://traceless.site/index.php/archives/62/")).Done();
             return;
         }
     }
     successor.ProcessRequset(msg, nowModel);
 }
Example #12
0
        public void ProcessFriendMessage(PrivateMessageFromFriendReceivedContext context)
        {
            //判断发送的QQ是否来自管理员
            if (_admincontrol.IsAdmin(context.FromQq, context.Message))
            {
                string CallbackMes = _admincontrol.Admin2do(context.Message);
                _mahuaApi.SendPrivateMessage(context.FromQq, CallbackMes);
            }
            else
            {
                GiveQuan(context);
            }

            // 不要忘记在MahuaModule中注册
        }
Example #13
0
        public void ProcessFriendMessage(PrivateMessageFromFriendReceivedContext context)
        {
            if (context.FromQq == "472158246")
            {
                switch (context.Message)
                {
                case "直播姬起飞":
                    _livegirl.StartAsync().GetAwaiter().GetResult();
                    break;

                case "直播姬降落":
                    _livegirl.StopAsnyc().GetAwaiter().GetResult();
                    break;
                }
            }
        }
Example #14
0
        public override void ProcessRequset(PrivateMessageFromFriendReceivedContext msg, AnalysisMsg nowModel)
        {
            if (msg.FromQq == Config.ConfigModel.MasterQQ)
            {
                if (nowModel.What == "反馈")
                {
                    _mahuaApi.SendGroupMessage(nowModel.Who).Text($"{nowModel.How}").Newline().Text("[来自作者的反馈]").Done();
                    return;
                }
                if (nowModel.What == "个人反馈")
                {
                    _mahuaApi.SendPrivateMessage(nowModel.Who).Text($"{nowModel.How}").Newline().Text("[来自作者的反馈]").Done();
                    return;
                }
            }

            successor.ProcessRequset(msg, nowModel);
        }
Example #15
0
        public void ProcessFriendMessage(PrivateMessageFromFriendReceivedContext context)
        {
            // 戳一戳
            _mahuaApi.SendPrivateMessage(context.FromQq)
            .Shake()
            .Done();
            // 嘤嘤嘤
            _mahuaApi.SendPrivateMessage(context.FromQq)
            .Text("嘤嘤嘤:")
            .Newline()
            .Text(context.Message)
            .Done();

            // 将好友信息会发给好友
            _mahuaApi.SendPrivateMessage(context.FromQq, context.Message);

            _mahuaApi.SendPrivateMessage(context.FromQq)
            .Image(@"D:\logo.png")
            .Done();
        }
Example #16
0
 public override void ProcessRequset(PrivateMessageFromFriendReceivedContext msg, AnalysisMsg nowModel)
 {
     if (nowModel.What == "宠物")
     {
         if (nowModel.OrderCount > 1)
         {
             var url = Config.jx3ToolClass.GetPetCd(nowModel.Who, nowModel.How);
             if (url != "[宠物CD] 服务器不存在,请联系管理员!")
             {
                 _mahuaApi.SendPrivateMessage(msg.FromQq).Text(CQCode.SendLink("宠物CD-" + nowModel.Who, "http://file.yayaquanzhidao.com/logo.ico", "点击查看'" + nowModel.Who + "' 结果【来自:鸭鸭宠物CD查询】", url)).Done();
             }
             else
             {
                 _mahuaApi.SendPrivateMessage(msg.FromQq).Text(url).Done();
             }
             return;
         }
     }
     successor.ProcessRequset(msg, nowModel);
 }
Example #17
0
        private async Task Run(PrivateMessageFromFriendReceivedContext context)
        {
            context.Message = context.Message.Trim();

            var res = await _generatePrivateMsgDeal
                      .Run(context.Message, context.FromQq, (new Lazy <string>((() => _mahuaApi.GetLoginQq()))));

            if (res != null)
            {
                foreach (var item in res.Data)
                {
                    var msg = _mahuaApi.SendPrivateMessage(context.FromQq);
                    if (item.CallTa)
                    {
                        msg.Shake().Done();
                    }

                    msg.Text(item.Msg).Done();
                }
            }
        }
        public void ProcessFriendMessage(PrivateMessageFromFriendReceivedContext context)
        {
            Jitas  J    = new Jitas();
            string res  = "null";
            string com  = context.Message.Substring(0, 1);
            string ser  = context.Message.Replace("~", "");
            string ser1 = context.Message.Replace("*", "");

            if (context.Message == "帮助")
            {
                _mahuaApi.SendPrivateMessage(context.FromQq)
                .Text("EVE查询机器人使用说明")
                .Face("12").Newline()
                .Text("====物品查价功能").Face("151").Newline()
                .Text("|\t'*'+精确物品名称(宁静)\n|").Newline()
                .Text("|\t'~'+精确物品名称(晨曦)\n|").Newline()
                .Face("54").Text("更多功能请体验完整版").Face("54")
                .Done();
            }
            else if (com == "~")
            {
                res = J.esipriceget(ser);
                _mahuaApi.SendPrivateMessage(context.FromQq)
                .Text(ser + "晨曦:")
                .Newline()
                .Text(res)
                .Done();
            }
            else if (com == "*")
            {
                res = J.esipricegettqc(ser1);
                _mahuaApi.SendPrivateMessage(context.FromQq)
                .Text(ser1 + "宁静:")
                .Newline()
                .Text(res)
                .Done();
            }
        }
Example #19
0
 /// <summary>
 /// 发券
 /// </summary>
 /// <param name="context"></param>
 public static void GiveQuan(PrivateMessageFromFriendReceivedContext context)
 {
     Task.Factory.StartNew(() =>
     {
         RobotRemoteService.RobotRemoteService RrService = new RobotRemoteService.RobotRemoteService();
         using (var robotSession = MahuaRobotManager.Instance.CreateSession())
         {
             string ReturnMessage = string.Empty;
             var api          = robotSession.MahuaApi;
             string Message   = context.Message;
             string keyword   = GetKeyWord(Message);
             string resultUrl = @"http://52lequan.cn/index.php?r=l&kw=" + System.Web.HttpUtility.UrlEncode(keyword, System.Text.Encoding.UTF8);
             if (keyword != "NoKey")
             {
                 ReturnMessage = string.Format("关键词:{0}\n链接:{1}\n复制链接在浏览器中打开\n如果没有你想要的结果,点击右侧搜索全网", keyword, resultUrl);
             }
             else
             {
                 ReturnMessage = "没有识别出您想要的商品,请再输入\n我想要+商品名称\n进行搜索,如需人工服务,请联系所在群管理员";
             }
             api.SendPrivateMessage(context.FromQq, ReturnMessage);
         }
     });
 }
Example #20
0
 /// <summary>
 /// 私聊消息处理
 /// </summary>
 /// <param name="msg"></param>
 public abstract void ProcessRequset(PrivateMessageFromFriendReceivedContext msg, AnalysisMsg nowModel);
Example #21
0
        public void ProcessFriendMessage(PrivateMessageFromFriendReceivedContext context)
        {
            // todo 填充处理逻辑
            //throw new NotImplementedException();

            //功能介绍
            _mahuaApi.SendPrivateMessage(context.FromQq)
            .Text("通过和Repeater Breaker好友聊天,可以设置Repeater Breaker的运行模式")
            .Newline()
            .Text("使用以下命令,可以更改相应的运行特性")
            .Newline()
            .Text("设置复读检测次数 repeatTime=X X是3-10内的整数,是触发禁言所需的复读次数")
            .Newline()
            .Text("设置禁言时间 banTime=X X代表禁言时间,单位分钟")
            .Newline()
            .Text("调整执行模式 modeSet=X X取0、1、2,分别代表只禁言最后一个复读机,随机禁言一个复读机和禁言所有的复读机")
            .Done();

            //匹配命令类型的正则表达式
            Regex counter = new Regex("repeatTime");
            Regex ban     = new Regex("banTime");
            Regex mode    = new Regex("modeSet");

            //根据不同的输入命令调整相应的参数值
            if (counter.IsMatch(context.Message) == true)
            {
                int result = getDigit(context.Message);
                Newbe.Mahua.Plugins.RepeaterBreaker.MahuaEvents.Common.repeatExecuate = result;
                _mahuaApi.SendPrivateMessage(context.FromQq)
                .Text("复读次数检测阈值已调整为 ")
                .Text(Convert.ToString(result))
                .Done();
            }

            if (ban.IsMatch(context.Message) == true)
            {
                int result = getDigit(context.Message);
                Newbe.Mahua.Plugins.RepeaterBreaker.MahuaEvents.Common.execuateTime = result;
                _mahuaApi.SendPrivateMessage(context.FromQq)
                .Text("禁言时间已调整为 ")
                .Text(Convert.ToString(result))
                .Done();
            }

            if (mode.IsMatch(context.Message) == true)
            {
                int result = getDigit(context.Message);
                if (result < 0 || result > 2)
                {
                    _mahuaApi.SendPrivateMessage(context.FromQq)
                    .Text("设定执行模式错误:模式值只能为0,1,2中的一个!")
                    .Done();
                }
                else
                {
                    Newbe.Mahua.Plugins.RepeaterBreaker.MahuaEvents.Common.execuateMode = result;
                    switch (result)
                    {
                    case 0: _mahuaApi.SendPrivateMessage(context.FromQq)
                        .Text("执行模式已设置为 常规模式,只禁言最后一个复读机")
                        .Done(); break;

                    case 1: _mahuaApi.SendPrivateMessage(context.FromQq)
                        .Text("执行模式已设置为 随机模式,随机禁言一个复读机")
                        .Done(); break;

                    case 2: _mahuaApi.SendPrivateMessage(context.FromQq)
                        .Text("执行模式已设置为 强力模式,禁言全部复读机")
                        .Done(); break;
                    }
                }
            }
            // 不要忘记在MahuaModule中注册
        }
 public override void ProcessRequset(PrivateMessageFromFriendReceivedContext msg, AnalysisMsg nowModel)
 {
     return;
 }
Example #23
0
 public override void ProcessRequset(PrivateMessageFromFriendReceivedContext msg, AnalysisMsg nowModel)
 {
     successor.ProcessRequset(msg, nowModel);
 }
        //  private MessageController messageController = new MessageController();
        public void ProcessFriendMessage(PrivateMessageFromFriendReceivedContext context)
        {
            string message = context.Message;

            if (message == "" || message.Length == 0 || message == null)
            {
                return;
            }
            IDatabase redis = RedisHelper.getRedis();

            // 判断用户是否在缓冲中
            if (redis.StringGet(context.FromQq).IsNull)
            {
                redis.StringSet(context.FromQq, "flag");
                redis.KeyExpire(context.FromQq, new TimeSpan(10000000 * Convert.ToInt16(Constants.sleepTime)));
            }
            else
            {
                string tmpStr = "为防止造成刷屏,您每次使用机器人的时间间隔" + Constants.sleepTime + "秒哦!";
                _mahuaApi.SendPrivateMessage(context.FromQq, tmpStr);
                return;
            };
            if (message == null || message == "" || message.Length == 0)
            {
                //
            }
            else
            {
                MessageModel messageModel = MessageController.main(message, context.FromQq);
                string       tmpStr       = messageModel.SendMessage;
                bool         isAdmin      = messageModel.IsAdmin;
                if (isAdmin)
                {
                    // 判断是否为 公告指令
                    if (MessageConstant.GONG_GAO.Equals(messageModel.Code))
                    {
                        // 获取所有群信息
                        ModelWithSourceString <IEnumerable <GroupInfo> > modelWithSourceString = _mahuaApi.GetGroupsWithModel();
                        IEnumerable <GroupInfo> groupInfo = modelWithSourceString.Model;
                        foreach (var item in groupInfo)
                        {
                            _mahuaApi.SendGroupMessage(item.Group, tmpStr);
                            _mahuaApi.SendPrivateMessage(context.FromQq, "【" + item.Name + "】 " + item.Group + " 推送成功!");
                        }
                    }
                    // 判断是否为全体成员处理
                    else if (MessageConstant.AITE_ALL.Equals(messageModel.Code))
                    {
                        // 获取所有群信息
                        ModelWithSourceString <IEnumerable <GroupInfo> > modelWithSourceString = _mahuaApi.GetGroupsWithModel();
                        IEnumerable <GroupInfo> groupInfo = modelWithSourceString.Model;
                        tmpStr = "[CQ:at,qq=all]\n" + tmpStr;
                        foreach (var item in groupInfo)
                        {
                            _mahuaApi.SendGroupMessage(item.Group, tmpStr);
                            _mahuaApi.SendPrivateMessage(context.FromQq, "【" + item.Name + "】 " + item.Group + " 推送成功!");
                        }
                    }
                    // 更新金额
                    else if (MessageConstant.UPDATE_MONEY.Equals(messageModel.Code))
                    {
                        _mahuaApi.SendPrivateMessage(context.FromQq, messageModel.SendMessage);
                    }
                    // 群数量
                    else if (MessageConstant.QUN_TOTAL.Equals(messageModel.Code))
                    {
                        ModelWithSourceString <IEnumerable <GroupInfo> > modelWithSourceString = _mahuaApi.GetGroupsWithModel();
                        IEnumerable <GroupInfo> groupInfo = modelWithSourceString.Model;
                        int count = 0;
                        foreach (var item in groupInfo)
                        {
                            count++;
                        }
                        _mahuaApi.SendPrivateMessage(context.FromQq, "群数量:" + count.ToString());
                    }
                    else
                    {
                        if (tmpStr != "" && tmpStr.Length > 0)
                        {
                            _mahuaApi.SendPrivateMessage(context.FromQq, tmpStr);
                        }
                    }
                }
                else
                {
                    if (tmpStr != "" && tmpStr.Length > 0)
                    {
                        _mahuaApi.SendPrivateMessage(context.FromQq, tmpStr);
                    }
                }
            }
        }
Example #25
0
        public void ProcessFriendMessage(PrivateMessageFromFriendReceivedContext context)
        {
            // todo 填充处理逻辑
            //throw new NotImplementedException();

            //功能介绍
            _mahuaApi.SendPrivateMessage(context.FromQq)
            .Text("通过和Repeater Breaker好友聊天,可以设置Repeater Breaker的运行模式")
            .Newline()
            .Text("使用以下命令,可以更改相应的运行特性")
            .Newline()
            .Text("设置复读检测次数 repeatTime=X X是3-10内的整数,是触发禁言所需的复读次数")
            .Newline()
            .Text("设置禁言时间 banTime=X X代表禁言时间,单位分钟")
            .Newline()
            .Text("调整执行模式 modeSet=X X取0、1、2,分别代表只禁言最后一个复读机,随机禁言一个复读机,禁言所有的复读机")
            .Newline()
            .Text("RandMax=X 禁言随机阈值X")
            .Newline()
            .Text("RandMin=X 解禁随机阈值X")
            .Newline()
            .Text("i=X p=X 分别设置计数器和每小时解禁上限")
            .Done();

            //匹配命令类型的正则表达式
            Regex counter = new Regex("repeatTime");
            Regex ban     = new Regex("banTime");
            Regex mode    = new Regex("modeSet");
            Regex RandMax = new Regex("RandMax");
            Regex RandMin = new Regex("RandMin");
            Regex p       = new Regex("p");
            Regex i       = new Regex("i");

            //根据不同的输入命令调整相应的参数值
            if (counter.IsMatch(context.Message) == true)
            {
                int result = getDigit(context.Message);
                Common.repeatExecuate = result;
                _mahuaApi.SendPrivateMessage(context.FromQq)
                .Text("复读次数检测阈值已调整为 ")
                .Text(Convert.ToString(result))
                .Done();
            }

            if (ban.IsMatch(context.Message) == true)
            {
                int result = getDigit(context.Message);
                Common.execuateTime = result;
                _mahuaApi.SendPrivateMessage(context.FromQq)
                .Text("禁言时间已调整为 ")
                .Text(Convert.ToString(result))
                .Done();
            }

            if (mode.IsMatch(context.Message) == true)
            {
                int result = getDigit(context.Message);
                if (result < 0 || result > 2)
                {
                    _mahuaApi.SendPrivateMessage(context.FromQq)
                    .Text("设定执行模式错误:模式值只能为0,1,2中的一个!")
                    .Done();
                }
                else
                {
                    Common.execuateMode = result;
                    switch (result)
                    {
                    case 0: _mahuaApi.SendPrivateMessage(context.FromQq)
                        .Text("执行模式已设置为 常规模式,只禁言最后一个复读机")
                        .Done(); break;

                    case 1: _mahuaApi.SendPrivateMessage(context.FromQq)
                        .Text("执行模式已设置为 随机模式,随机禁言一个复读机")
                        .Done(); break;

                    case 2: _mahuaApi.SendPrivateMessage(context.FromQq)
                        .Text("执行模式已设置为 强力模式,禁言全部复读机")
                        .Done(); break;
                    }
                }
            }

            if (RandMax.IsMatch(context.Message) == true)
            {
                int result = getDigit(context.Message);
                Common.RandMax = result;
                _mahuaApi.SendPrivateMessage(context.FromQq)
                .Text("随机禁言概率已调整为")
                .Text(Convert.ToString(result))
                .Done();
            }

            if (RandMin.IsMatch(context.Message) == true)
            {
                int result = getDigit(context.Message);
                Common1.RandMin = result;
                _mahuaApi.SendPrivateMessage(context.FromQq)
                .Text("解禁概率已调整为")
                .Text(Convert.ToString(result))
                .Done();
            }

            if (p.IsMatch(context.Message) == true)
            {
                int result = getDigit(context.Message);
                Common1.p = result;
                _mahuaApi.SendPrivateMessage(context.FromQq)
                .Text("解禁次数上限已调整为")
                .Text(Convert.ToString(result))
                .Done();
            }

            if (i.IsMatch(context.Message) == true)
            {
                int result = getDigit(context.Message);
                Common1.i = result;
                _mahuaApi.SendPrivateMessage(context.FromQq)
                .Text("计数器已调整为")
                .Text(Convert.ToString(result))
                .Done();
            }
            if (context.FromQq == "384323693")
            {
                switch (context.Message)
                {
                case "直播姬起飞":
                    _livegirl.StartAsync().GetAwaiter().GetResult();
                    break;

                case "直播姬降落":
                    _livegirl.StopAsnyc().GetAwaiter().GetResult();
                    break;
                }
            }
            // 不要忘记在MahuaModule中注册
        }
 public void ProcessFriendMessage(PrivateMessageFromFriendReceivedContext context)
 {
     //将好友信息会发给好友
     _mahuaApi.SendPrivateMessage(context.FromQq, context.Message);
 }
Example #27
0
 /// <summary>
 /// 处理事件
 /// </summary>
 /// <param name="context"></param>
 public void ProcessFriendMessage(PrivateMessageFromFriendReceivedContext context)
 {
     //调用_mahuaApi实现将消息回发给好友的功能
     _mahuaApi.SendPrivateMessage(context.FromQq, context.Message);
 }
Example #28
0
 public void ProcessFriendMessage(PrivateMessageFromFriendReceivedContext context)
 {
     new PrivateMessage(context.FromQq, context.Message, PrivateMessage.TYPE.FRIEND);
 }
Example #29
0
        public void ProcessFriendMessage(PrivateMessageFromFriendReceivedContext context)
        {
            ///* --和群一样的功能 解开注释可以使用
            try
            {
                if (context.Message.Contains("mode_"))
                {
                    string key = context.Message.Replace("mode_", null);
                    _mahuaApi.SendPrivateMessage(context.FromQq).Text(string.Format("key:{0}", key)).Done();
                    if (Profile.Done.ContainsKey(key))
                    {
                        _mahuaApi.SendPrivateMessage(context.FromQq).Text(string.Format("包含key:{0}", key)).Done();
                        Dictionary <string, bool> tmpDone = new Dictionary <string, bool>(Profile.Done);
                        foreach (var item in tmpDone)
                        {
                            if (item.Key != key)
                            {
                                _mahuaApi.SendPrivateMessage(context.FromQq).Text(string.Format("key为false:{0}", item.Key)).Done();
                                Profile.Done[item.Key] = false;
                            }
                            else
                            {
                                _mahuaApi.SendPrivateMessage(context.FromQq).Text(string.Format("key为true:{0}", item.Key)).Done();
                                if (Profile.path[item.Key].Count <= 0)
                                {
                                    Profile.Done[item.Key] = false;
                                    try
                                    {
                                        _mahuaApi.SendPrivateMessage(context.FromQq).Text("路径正在加载,无法切换").Done();
                                    }
                                    catch (Exception ex)
                                    {
                                    }
                                }
                                else
                                {
                                    Profile.Done[item.Key] = true;
                                    try
                                    {
                                        _mahuaApi.SendPrivateMessage(context.FromQq).Text(string.Format("已切换到{0}模式,发送\"不够色!\"or \"不够色!\" or \"不够色\"获取", key)).Done();
                                    }
                                    catch (Exception ex)
                                    {
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        try
                        {
                            _mahuaApi.SendPrivateMessage(context.FromQq).Text(string.Format("不存在{0}模式", key)).Done();
                        }
                        catch (Exception ex)
                        {
                        }
                    }
                }
                else if (context.Message == ("关闭"))
                {
                    Dictionary <string, bool> tmpDone = new Dictionary <string, bool>(Profile.Done);
                    foreach (var item in tmpDone.Keys)
                    {
                        Profile.Done[item] = false;
                    }
                    try
                    {
                        _mahuaApi.SendPrivateMessage(context.FromQq).Text("已关闭").Done();
                    }
                    catch (Exception ex)
                    {
                    }
                }


                else if (context.Message == ("不够色!") || context.Message == ("不够色!") || context.Message == ("不够色"))
                {
                    bool flag = true;
                    if (flag)
                    {
                        if (Login.instance == null)
                        {
                            try
                            {
                                _mahuaApi.SendPrivateMessage(context.FromQq).Text("未开启").Done();
                            }
                            catch (Exception ex)
                            {
                            }
                        }
                        else
                        {
                            string key = null;
                            Dictionary <string, bool> tmpDone = new Dictionary <string, bool>(Profile.Done);
                            foreach (var item in tmpDone)
                            {
                                if (item.Value)
                                {
                                    key = item.Key;
                                    break;
                                }
                            }
                            if (key == null)
                            {
                                try
                                {
                                    _mahuaApi.SendPrivateMessage(context.FromQq).Text("未开启图片").Done();
                                }
                                catch (Exception ex)
                                {
                                }
                            }
                            else
                            {
                                Profile.currentIndex[key]++;
                                int index = Profile.currentIndex[key];
                                var path  = Profile.path[key];
                                if (index >= path.Count)
                                {
                                    try
                                    {
                                        _mahuaApi.SendPrivateMessage(context.FromQq).Text("目前无最新").Done();
                                    }
                                    catch (Exception ex)
                                    {
                                    }
                                }
                                else
                                {
                                    string imagePath = path[index];
                                    if (File.Exists(imagePath))
                                    {
                                        try
                                        {
                                            _mahuaApi.SendPrivateMessage(context.FromQq).Image(imagePath).Done();
                                        }
                                        catch (Exception ex)
                                        {
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        try
                        {
                            _mahuaApi.SendPrivateMessage(context.FromQq).Text("正在冷却").Done();
                        }
                        catch (Exception ex)
                        {
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _mahuaApi.SendPrivateMessage(context.FromQq).Text(ex.ToString()).Done();
            }
            //*/
        }