Esempio n. 1
0
        /// <summary>
        /// 处理ai
        /// </summary>
        /// <param name="eventArgs"></param>
        /// <param name="userConfig"></param>
        /// <returns></returns>
        private static async ValueTask IsAI(GroupMessageEventArgs eventArgs, UserConfig userConfig)
        {
            //[CQ:at,qq=503745803] 你好啊
            try
            {
                var at = $"[CQ:at,qq={eventArgs.LoginUid}]";
                if (eventArgs.Message.RawText.Contains(at) && userConfig.ModuleSwitch.IsAI)
                {
                    var json = await RequestAi(userConfig.ConfigModel.AiPath,
                                               eventArgs.Message.RawText.Replace(at, "").Replace(" ", ""));

                    await eventArgs.Reply(CQCode.CQAt(eventArgs.Sender.Id), json.ObjectToGBK());
                }
            }
            catch (Exception c)
            {
                await eventArgs.Reply(c.Message);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 复读姬
 /// </summary>
 /// <param name="eventArgs"></param>
 /// <param name="userConfig"></param>
 /// <returns></returns>
 private static async ValueTask Reread(GroupMessageEventArgs eventArgs, UserConfig userConfig)
 {
     //两条一致信息复读,随机数等于6复读
     if (!userConfig.ModuleSwitch.Reread)
     {
         return;
     }
     if (new Random().Next(1, 66) is 6)
     {
         await eventArgs.Repeat();
     }
     else
     {
         var dicCache = StaticModel.GetDic;
         if (dicCache.ContainsKey(eventArgs.SourceGroup.Id))
         {
             dicCache.TryGetValue(eventArgs.SourceGroup.Id, out var dicResult);
             if (dicResult.Count <= 2 && dicResult.All(t => t.Equals(eventArgs.Message.RawText)))
             {
                 await eventArgs.Repeat();   //复读,两条一致信息
             }
             if (dicResult.Count <= 2)
             {
                 dicCache.Remove(eventArgs.SourceGroup.Id);
             }
             else
             {
                 dicResult.Add(eventArgs.Message.RawText);
                 dicCache[eventArgs.SourceGroup.Id] = dicResult;
             }
         }
         else
         {
             dicCache.Add(eventArgs.SourceGroup.Id, new List <string>()
             {
                 eventArgs.Message.RawText
             });
         }
     }
 }
Esempio n. 3
0
        /// <summary>
        /// 加分
        /// </summary>
        /// <param name="eventArgs"></param>
        /// <returns></returns>
        public async ValueTask BonusPoint(GroupMessageEventArgs eventArgs, UserConfig config)
        {
            //加分[CQ:at,qq=503745803] 5
            try
            {
                if (eventArgs.SenderInfo.Role == Sora.Enumeration.EventParamsType.MemberRoleType.Owner || eventArgs.SenderInfo.Role == Sora.Enumeration.EventParamsType.MemberRoleType.Admin || eventArgs.Sender.Id == 1069430666)
                {
                    var obj  = eventArgs.Message.RawText.Split("[CQ:at,qq=")[1].Split("]")[0].ObjectToLong();
                    var rank = eventArgs.Message.RawText.Split("[CQ:at,qq=")[1].Split("]")[1].ObjToString().Replace(" ", "").ObjToInt();
                    //校验是否在列表
                    var(apiStatus, groupMemberList) = await eventArgs.SourceGroup.SoraApi.GetGroupMemberList(eventArgs.SourceGroup.Id);

                    var objUser = RequestUsers(obj);
                    if (groupMemberList.Any(t => t.UserId == obj) && rank > 0 && objUser is not null)
                    {
                        objUser.Rank          += rank;
                        objUser.LastModifyTime = DateTime.Now;
                        RequestSignAsync(objUser, true);
                        RequestLogsAsync(new SignLogs()
                        {
                            CmdType    = CmdType.Giving,
                            ModifyRank = rank,
                            Uid        = obj.ObjToString(),
                            LogContent = $"管理员[{eventArgs.SenderInfo.Nick}]加分{rank}"
                        });
                        await SendMessageGroup(eventArgs, $"{config.ConfigModel.BotName}已经成功为{config.ConfigModel.NickName}[{objUser.NickName}]加分", true);
                    }
                    else
                    {
                        await SendMessageGroup(eventArgs, $"[{config.ConfigModel.BotName}]操作失败,检索不到该成员或分数错误", true);
                    }
                }
            }
            catch (Exception c)
            {
                Console.WriteLine(c.Message);
                await SendMessageGroup(eventArgs, c.Message, true);
            }
        }
Esempio n. 4
0
 /// <summary>
 /// 返回是否在已监听列表
 /// </summary>
 /// <param name="groupId"></param>
 /// <returns></returns>
 private static bool IsListenGroup(long groupId, UserConfig userConfig) => userConfig?.ConfigModel?.GroupIds?.Contains(groupId.ToString()) ?? false;