Exemplo n.º 1
0
 public static int Event_pluginStop()
 {
     QLAPI.CoUninitialize();
     QLAPI.Api_SendLog("Debug", "已停止", 0, ac);
     DataManager.Stop();
     return(0);
 }
Exemplo n.º 2
0
        public static int Event_GetNewMsg(int type, string GroupID, string FromQQ, string Msg, string MsgID)
        {
            QLAPI.Api_SendLog("收到信息", string.Format("type:{0},GroupID:{1},FromQQ:{2},Msg:{3},MsgID:{4}", type, GroupID, FromQQ, Msg, MsgID), 0, ac);
            if (Msg.IndexOf("s") > -1)
            {
                QLAPI.Api_SendMsg(type, GroupID, FromQQ, "您发送了带有s的字符串", ac);
            }
            return(MSG_CONTINUE);

            // MSG_INTERCEPT 代表拦截消息不传递到下一个插件,插件的优先级可以通过拖拽插件列表来调整
        }
Exemplo n.º 3
0
 public static int Event_pluginStart()
 {
     QLAPI.CoInitialize(0);
     QLAPI.Api_SendLog("Debug", "已启动", 0, ac);
     try
     {
         CommandCenter.ReloadManagers();
         DataManager.Init();
     }
     catch (Exception e)
     {
         QLAPI.Api_SendLog("Error", e.Message + e.StackTrace, 0, ac);
     }
     return(0);
 }
Exemplo n.º 4
0
        public static void ReloadManagers()
        {
            QLAPI.Api_SendLog("debug", "ReloadingManager", 0, QLMain.ac);
            //只能拿到直接继承的派生类,有需要的时候再改
            var managerTypes = Assembly.GetExecutingAssembly().GetTypes()
                               .Where(p => p.BaseType == typeof(BaseManager)).ToList();

            QLAPI.Api_SendLog("debug", $"found {managerTypes.Count} managers", 0, QLMain.ac);
            var managerWithCommands = managerTypes.Select(p => new
            {
                Type        = p,
                CommandList = p.GetCustomAttributes <CommandAttribute>().ToList()
            }).Where(p => p.CommandList.Any()).ToList();

            managerWithCommands.ForEach(p => { p.CommandList.ForEach(q => { Managers.Add(q.Command, p.Type); }); });
            QLAPI.Api_SendLog("debug", $"found {managerWithCommands.Count}", 0, QLMain.ac);
        }
Exemplo n.º 5
0
        public override async Task ExecuteAsync(List <string> command, EventSourceType sourceType, UserInfo qq, Group group, GroupMember member)
        {
            var name = "";

            if (sourceType == EventSourceType.Group)
            {
                if (member == null)
                {
                    QLAPI.Api_SendLog("debug", "Jrrp group member is null", 0, QLMain.ac);
                    return;
                }
                if (_disabledJrrpGroupNumbers.Contains(member.GroupNumber))
                {
                    return;
                }

                name = member.GroupName;
            }
            else if (sourceType == EventSourceType.Private || sourceType == EventSourceType.Friend)
            {
                if (qq == null)
                {
                    QLAPI.Api_SendLog("debug", "Jrrp qq is null", 0, QLMain.ac);
                    return;
                }
                name = qq.Name;
            }

            var isReroll = qq.ReRollStep == UserInfo.RerollStep.CanReroll;
            var rp       = GetJrrp(qq, isReroll);

            switch (qq.ReRollStep)
            {
            case UserInfo.RerollStep.None:
                MessageManager.Send(sourceType, name + "今天的人品值是:" + rp, qq: qq?.QQ, toGroupNo: member?.GroupNumber);
                return;

            case UserInfo.RerollStep.CanReroll:
                MessageManager.Send(sourceType, name + "今天的人品不太好,确定要看的话就再来一次吧", qq: qq?.QQ, toGroupNo: member?.GroupNumber);
                return;

            case UserInfo.RerollStep.RerollFaild:
                if (rp == 1)
                {
                    MessageManager.Send(sourceType, $"……", qq: qq?.QQ, toGroupNo: member?.GroupNumber);
                }
                else
                {
                    MessageManager.Send(sourceType, name + $"今天的人品值只有:{rp}", qq: qq?.QQ, toGroupNo: member?.GroupNumber);
                }
                return;

            case UserInfo.RerollStep.RerollSuccess:
                MessageManager.Send(sourceType, $"啊!对不起刚才是我失误了!{name}今天人品值应该是:{rp}", qq: qq?.QQ, toGroupNo: member?.GroupNumber);
                qq.ReRollStep = UserInfo.RerollStep.None;
                return;

            case UserInfo.RerollStep.RerollDevastated:
                if (rp == 1)
                {
                    MessageManager.Send(sourceType, $"……", qq: qq?.QQ, toGroupNo: member?.GroupNumber);
                }
                else
                {
                    MessageManager.Send(sourceType, $"都说了不想告诉你了嘛……{name}今天人品值只有:{rp}", qq: qq?.QQ, toGroupNo: member?.GroupNumber);
                }
                qq.ReRollStep = UserInfo.RerollStep.RerollFaild;
                return;
            }
        }
Exemplo n.º 6
0
 public static int Event_Initialization()
 {
     QLAPI.init();//初始化API,不可删除
     QLAPI.Api_SendLog("Debug", "成功", 0, ac);
     return(0);
 }
Exemplo n.º 7
0
        public static int Event_GetNewMsg(int type, string GroupID, string FromQQ, string Msg, string MsgID)
        {
            QLAPI.Api_SendLog("收到信息", string.Format("type:{0},GroupID:{1},FromQQ:{2},Msg:{3},MsgID:{4}", type, GroupID, FromQQ, Msg, MsgID), 0, ac);
            //if (Msg.IndexOf("s") > -1)
            //{
            //    QLAPI.Api_SendMsg(type, GroupID, FromQQ, "您发送了带有s的字符串", ac);
            //}

            EventSourceType?source = null;

            switch (type)
            {
            case 1:
                source = EventSourceType.Friend;
                break;

            case 2:
                source = EventSourceType.Group;
                break;

            case 3:
            case 5:
                break;

            case 4:
                source = EventSourceType.Discuss;
                break;

            case 6:
                source = EventSourceType.Private;
                break;
            }

            if (source.HasValue)
            {
                long?qq      = null;
                long?groupId = null;
                if (long.TryParse(FromQQ, out var tqq))
                {
                    qq = tqq;
                }
                if (long.TryParse(GroupID, out var tgroupId))
                {
                    groupId = tgroupId;
                }

                try
                {
                    CommandCenter.Execute(Msg, source.Value, qq, groupId);
                }
                catch (Exception e)
                {
                    QLAPI.Api_SendLog("Error", e.Message + e.StackTrace, 0, QLMain.ac);
                }
            }
            else
            {
                QLAPI.Api_SendLog("Error", "不支持的消息来源类型", 0, QLMain.ac);
            }

            return(MSG_CONTINUE);

            // MSG_INTERCEPT 代表拦截消息不传递到下一个插件,插件的优先级可以通过拖拽插件列表来调整
        }