예제 #1
0
        public async Task <bool> ProcessAsync(CQApiClient client, MessageEvent me, long srcid)
        {
            const string keyword = "/debug";

            if (Global.msgFilter(me.message, false, s => s.TrimStart().StartsWith(keyword)))
            {
                foreach (var ele in me.message.data)
                {
                    if (ele is ElementText)
                    {
                        await client.SendRequestAsync(new SetGroupBanRequest(srcid, me.sender.user_id, 10L));
                    }
                }
            }

            return(false);
        }
예제 #2
0
        public async Task <bool> ProcessAsync(CQApiClient client, MessageEvent me, long srcid)
        {
            const string keyword0 = "管理员";
            const string keyword1 = "狗管理";
            const string keyword2 = "来一份";
            const string keyword3 = "禁言";
            const string keyword4 = "分";
            const string keyword5 = "小时";
            const string keyword6 = "天";
            bool         isGroup  = me is cqhttp.Cyan.Events.CQEvents.GroupMessageEvent;

            if (Global.msgFilter(me.message, !isGroup, s => s.TrimStart().StartsWith(keyword0)) ||
                Global.msgFilter(me.message, !isGroup, s => s.TrimStart().StartsWith(keyword1)))
            {
                if (Global.msgFilter(me.message, !isGroup, s => s.TrimStart().Contains(keyword2)) &&
                    Global.msgFilter(me.message, !isGroup, s => s.TrimStart().Contains(keyword3)))
                {
                    foreach (var ele in me.message.data)
                    {
                        if (ele is ElementText)
                        {
                            if ((ele as ElementText).text.Contains(keyword4) || (ele as ElementText).text.Contains(keyword5) || (ele as ElementText).text.Contains(keyword6))
                            {
                                string txt    = (ele as ElementText).text.TrimStart();
                                int    k2leng = txt.IndexOf(keyword2);
                                string txt0   = txt.Remove(0, k2leng + 3);
                                string txt1   = "0";
                                string txt2   = null;
                                int    btype  = 0;
                                long   aleng  = 0;
                                long   aleng0 = 0;
                                if (txt0.Contains(keyword4) && !txt0.Contains(keyword5) &&
                                    !txt0.Contains(keyword6))
                                {
                                    btype = 1;
                                    int k4leng = txt0.IndexOf(keyword4);
                                    txt1 = txt0.Remove(k4leng);
                                }
                                else if (!txt0.Contains(keyword4) && txt0.Contains(keyword5) &&
                                         !txt0.Contains(keyword6))
                                {
                                    btype = 2;
                                    int k5leng = txt0.IndexOf(keyword5);
                                    txt1 = txt0.Remove(k5leng);
                                }
                                else if (!txt0.Contains(keyword4) && !txt0.Contains(keyword5) &&
                                         txt0.Contains(keyword6))
                                {
                                    btype = 3;
                                    int k6leng = txt0.IndexOf(keyword6);
                                    txt1 = txt0.Remove(k6leng);
                                }
                                else if (txt0.Contains(keyword4) && txt0.Contains(keyword5) &&
                                         !txt0.Contains(keyword6))
                                {
                                    await client.SendMessageAsync(me.messageType, srcid,
                                                                  new Message(new ElementAt(me.sender.user_id), new ElementText(" 暂时不支持同时定义分钟和小时")));
                                }
                                else if (!txt0.Contains(keyword4) && txt0.Contains(keyword5) &&
                                         txt0.Contains(keyword6))
                                {
                                    await client.SendMessageAsync(me.messageType, srcid,
                                                                  new Message(new ElementAt(me.sender.user_id), new ElementText(" 暂时不支持同时定义小时和天数")));
                                }
                                else if (txt0.Contains(keyword4) && !txt0.Contains(keyword5) &&
                                         txt0.Contains(keyword6))
                                {
                                    await client.SendMessageAsync(me.messageType, srcid,
                                                                  new Message(new ElementAt(me.sender.user_id), new ElementText(" 暂时不支持同时定义分钟和天数")));
                                }
                                else if (txt0.Contains(keyword4) && txt0.Contains(keyword5) &&
                                         txt0.Contains(keyword6))
                                {
                                    await client.SendMessageAsync(me.messageType, srcid,
                                                                  new Message(new ElementAt(me.sender.user_id), new ElementText(" 暂时不支持同时定义分钟和小时和天数")));
                                }

                                if (btype == 0)
                                {
                                    return(false);
                                }

                                if (btype == 1)
                                {
                                    try
                                    {
                                        aleng0 = long.Parse(txt1);
                                        if (aleng0 > 43200)
                                        {
                                            aleng0 = 43200;
                                        }

                                        if (aleng0 < 0)
                                        {
                                            btype = 4;
                                        }
                                        aleng = aleng0 * 60;
                                        txt2  = "分钟";
                                    }
                                    catch (Exception)
                                    {
                                        btype = 4;
                                    }
                                }
                                else if (btype == 2)
                                {
                                    try
                                    {
                                        aleng0 = long.Parse(txt1);
                                        if (aleng0 > 720)
                                        {
                                            aleng0 = 720;
                                        }

                                        if (aleng0 < 0)
                                        {
                                            btype = 4;
                                        }
                                        aleng = aleng0 * 60 * 60;
                                        txt2  = "小时";
                                    }
                                    catch (Exception)
                                    {
                                        btype = 4;
                                    }
                                }
                                else if (btype == 3)
                                {
                                    try
                                    {
                                        aleng0 = long.Parse(txt1);
                                        if (aleng0 > 30)
                                        {
                                            aleng0 = 30;
                                        }

                                        if (aleng0 < 0)
                                        {
                                            btype = 4;
                                        }
                                        aleng = aleng0 * 60 * 60 * 24;
                                        txt2  = "天";
                                    }
                                    catch (Exception)
                                    {
                                        btype = 4;
                                    }
                                }

                                if (btype == 4)
                                {
                                    aleng = 3600;
                                    await client.SendMessageAsync(me.messageType, srcid,
                                                                  new Message(new ElementAt(me.sender.user_id), new ElementText($" 居然调戏我w,先咬死!")));

                                    await client.SendRequestAsync(new SetGroupBanRequest(srcid, me.sender.user_id, aleng));

                                    return(true);
                                }

                                await client.SendMessageAsync(me.messageType, srcid,
                                                              new Message(new ElementAt(me.sender.user_id), new ElementText($" 您点的{aleng0}{txt2}禁言套餐已到,请尽情享用")));

                                await client.SendRequestAsync(new SetGroupBanRequest(srcid, me.sender.user_id, aleng));

                                return(true);
                            }
                        }
                    }
                }
            }

            return(false);
        }
예제 #3
0
        public async Task <bool> ProcessAsync(CQApiClient client, MessageEvent me, long srcid)
        {
            const string keyword  = "/lotteryban";
            const string keyword1 = "/lob";
            double       dts      = (DateTime.Now.ToUniversalTime() - new DateTime(1970, 1, 1)).TotalSeconds;
            long         bts      = (long)dts;

            if (islbing && cts + 420 < bts)
            {
                islbing = false;
                currentList_.Clear();
            }
            bool isGroup = me is cqhttp.Cyan.Events.CQEvents.GroupMessageEvent;

            if (Global.msgFilter(me.message, !isGroup, s => s.TrimStart().StartsWith(keyword)))
            {
                if (islbing)
                {
                    await client.SendMessageAsync(me.messageType, srcid, new Message(new ElementText("已经有禁言抽奖正在进行咯!\n(或许不是这个群的)")));

                    return(true);
                }

                if (!islbing)
                {
                    islbing = true;
                    lbqun   = srcid;
                    currentList_.Add(me.sender.user_id);
                    double ats = (DateTime.Now.ToUniversalTime() - new DateTime(1970, 1, 1)).TotalSeconds;
                    cts = (long)ats;
                    await client.SendMessageAsync(me.messageType, srcid, new Message(new ElementAt(me.sender.user_id),
                                                                                     new ElementText(" 发起了1分钟的禁言抽奖(1/5)\n" +
                                                                                                     "各位快输入「/lob」参与吧!(7分钟后没达到人数自动关闭)")));

                    return(true);
                }
            }

            if (Global.msgFilter(me.message, !isGroup, s => s.TrimStart().StartsWith(keyword1)))
            {
                if (islbing && srcid == lbqun)
                {
                    foreach (var qqid in currentList_)
                    {
                        if (qqid == me.sender.user_id)
                        {
                            await client.SendMessageAsync(me.messageType, srcid,
                                                          new Message(new ElementAt(me.sender.user_id), new ElementText(" 你已经在名单里了哦~")));

                            return(false);
                        }
                    }
                    currentList_.Add(me.sender.user_id);
                    if (currentList_.Count == 5)
                    {
                        int rroll0 = rand_.Next(1, 100);
                        int rroll1 = rand_.Next(1, 100);
                        int rroll2 = rand_.Next(1, 100);
                        int rroll3 = rand_.Next(1, 100);
                        int rroll4 = rand_.Next(1, 100);
                        int winnum = 0;


                        for (int i = 100; i > 1; i--)
                        {
                            if (rroll0 == i)
                            {
                                winnum = 0;
                                break;
                            }

                            if (rroll1 == i)
                            {
                                winnum = 1;
                                break;
                            }

                            if (rroll2 == i)
                            {
                                winnum = 2;
                                break;
                            }

                            if (rroll3 == i)
                            {
                                winnum = 3;
                                break;
                            }

                            if (rroll4 == i)
                            {
                                winnum = 4;
                                break;
                            }
                        }

                        await client.SendMessageAsync(me.messageType, srcid,
                                                      new Message(new ElementText("禁言1分钟抽奖开奖啦!\n"),
                                                                  new ElementAt(currentList_[0]), new ElementText($" 的点数为[{rroll0}]\n"),
                                                                  new ElementAt(currentList_[1]), new ElementText($" 的点数为[{rroll1}]\n"),
                                                                  new ElementAt(currentList_[2]), new ElementText($" 的点数为[{rroll2}]\n"),
                                                                  new ElementAt(currentList_[3]), new ElementText($" 的点数为[{rroll3}]\n"),
                                                                  new ElementAt(currentList_[4]), new ElementText($" 的点数为[{rroll4}]\n"),
                                                                  new ElementText("点数最大的是:"), new ElementAt(currentList_[winnum]),
                                                                  new ElementText("恭喜这位群友获得1分钟禁言礼包~")));

                        await client.SendRequestAsync(new SetGroupBanRequest(srcid, currentList_[winnum], 60L));

                        islbing = false;
                        currentList_.Clear();
                        return(true);
                    }
                    await client.SendMessageAsync(me.messageType, srcid,
                                                  new Message(new ElementAt(me.sender.user_id),
                                                              new ElementText($" 也参与到禁言抽奖啦!({currentList_.Count}/5)\n" + "还没有参与的群友们赶紧输入「/lob」参与吧!")));

                    return(true);
                }

                if (!islbing)
                {
                    await client.SendMessageAsync(me.messageType, srcid,
                                                  new Message(new ElementText("目前还没有禁言抽奖活动进行哦!")));

                    return(true);
                }
            }

            return(false);
        }