Example #1
0
 public static void LiveName(string comm, long group)
 {
     Task.Run(() =>
     {
         try
         {
             var data1 = HttpUtils.SearchLive(comm);
             if (data1 == null)
             {
                 Program.SendGroupMessage($"搜索不到直播间:{comm}", group);
                 return;
             }
             var data2 = data1["data"]["result"]["live_room"] as JArray;
             if (data2.Count == 0)
             {
                 Program.SendGroupMessage($"搜索:{comm} 没有结果", group);
                 return;
             }
             string room = data2[0]["roomid"].ToString();
             data1       = HttpUtils.GetLive(room);
             if (data1 == null)
             {
                 Program.SendGroupMessage($"获取不到直播间:{room}", group);
                 return;
             }
             string temp1 = LivePicGen.Gen(data1);
             Program.Log($"已生成{temp1}");
             Program.SendGroupImage(temp1, group);
         }
         catch (Exception e)
         {
             Program.Error(e);
         }
     });
 }
Example #2
0
 public static void LiveUser(string comm, long group)
 {
     Task.Run(() =>
     {
         try
         {
             var data1 = HttpUtils.GetLiveUID(comm);
             if (data1 == null)
             {
                 Program.SendGroupMessage($"获取不到用户直播间:{comm}", group);
                 return;
             }
             string room = data1["data"]["roomid"].ToString();
             data1       = HttpUtils.GetLive(room);
             if (data1 == null)
             {
                 Program.SendGroupMessage($"获取不到直播间:{room}", group);
                 return;
             }
             string temp1 = LivePicGen.Gen(data1);
             Program.Log($"已生成{temp1}");
             Program.SendGroupImage(temp1, group);
         }
         catch (Exception e)
         {
             Program.Error(e);
         }
     });
 }
Example #3
0
        private static void GetLive(KeyValuePair <string, List <long> > item)
        {
            var item1 = item.Key;

            Program.Log($"检查用户{item1}直播");
            var obj1 = HttpUtils.GetLiveUID(item1);

            Thread.Sleep(ConfigUtils.Config.CheckDelay);
            if (!IsRun)
            {
                return;
            }
            if (obj1 == null)
            {
                return;
            }
            var obj2 = (int)obj1["data"]["roomStatus"];

            if (obj2 == 0)
            {
                return;
            }
            bool obj3 = (int)obj1["data"]["liveStatus"] == 1;

            if (ConfigUtils.UidLast.Live.ContainsKey(item1))
            {
                if (ConfigUtils.UidLast.Live[item1] == obj3)
                {
                    return;
                }
                else
                {
                    ConfigUtils.UidLast.Live[item1] = obj3;
                }
                save = true;
            }
            else
            {
                ConfigUtils.UidLast.Live.Add(item1, obj3);
                save = true;
            }
            if (!obj3)
            {
                return;
            }

            var data1 = HttpUtils.GetLive(obj1["data"]["roomid"].ToString());

            if (data1 == null)
            {
                return;
            }
            string temp1 = LivePicGen.Gen(data1);

            Program.Log($"已生成{temp1}");
            foreach (var item2 in item.Value)
            {
                Program.SendGroupImage(temp1, item2);
            }
        }
Example #4
0
 static void Main(string[] args)
 {
     RunLocal = AppContext.BaseDirectory;
     logs     = new Logs(RunLocal);
     Reload();
     if (ConfigUtils.Config.RunQQ == 0 || ConfigUtils.Config.RunGroup.Count == 0)
     {
         Console.WriteLine("运行QQ和运行群未设置,请设置后重启");
         Console.Read();
         return;
     }
     RobotConfig = new()
     {
         IP          = ConfigUtils.Config.IP,
         Port        = ConfigUtils.Config.Port,
         Name        = "BotBiliBili",
         Pack        = new() { 49 },
         RunQQ       = ConfigUtils.Config.RunQQ,
         Time        = 10000,
         CallAction  = Message,
         LogAction   = Log,
         StateAction = State
     };
     robot = new();
     robot.Set(RobotConfig);
     robot.Start();
     CheckThread.Start();
     while (true)
     {
         string   temp = Console.ReadLine();
         string[] arg  = temp.Split(' ');
         if (arg[0] == "stop")
         {
             CheckThread.Stop();
             HttpUtils.Cancel();
             robot.Stop();
             return;
         }
         else if (arg[0] == "test")
         {
             if (arg.Length < 2)
             {
                 Error("错误的参数");
                 continue;
             }
             if (arg[1] == "video")
             {
                 if (arg.Length != 3)
                 {
                     Error("错误的参数");
                     continue;
                 }
                 if (arg[2].StartsWith("AV"))
                 {
                     var data = HttpUtils.GetVideoA(arg[2]);
                     VideoPicGen.Gen(data);
                     Log("已生成");
                 }
                 else if (arg[2].StartsWith("BV"))
                 {
                     var data = HttpUtils.GetVideoB(arg[2]);
                     VideoPicGen.Gen(data);
                     Log("已生成");
                 }
                 else
                 {
                     Error("不正确的视频号");
                     continue;
                 }
             }
             else if (arg[1] == "dynamic")
             {
                 if (arg.Length != 3)
                 {
                     Error("错误的参数");
                     continue;
                 }
                 var data = HttpUtils.GetDynamic(arg[2]);
                 DynamicPicGen.Gen(data);
                 Log("已生成");
             }
             else if (arg[1] == "duser")
             {
                 if (arg.Length != 3)
                 {
                     Error("错误的参数");
                     continue;
                 }
                 var data = HttpUtils.GetDynamicUid(arg[2]);
                 DynamicPicGen.Gen(data);
                 Log("已生成");
             }
             else if (arg[1] == "live")
             {
                 if (arg.Length != 3)
                 {
                     Error("错误的参数");
                     continue;
                 }
                 var data = HttpUtils.GetLive(arg[2]);
                 LivePicGen.Gen(data);
                 Log("已生成");
             }
             else if (arg[1] == "nuser")
             {
                 if (arg.Length != 3)
                 {
                     Error("错误的参数");
                     continue;
                 }
                 var data1 = HttpUtils.SearchUser(arg[2]);
                 if (data1 == null)
                 {
                     Error($"搜索不到用户:{arg[2]}");
                     return;
                 }
                 var data2 = data1["data"]["result"] as JArray;
                 if (data2.Count == 0)
                 {
                     Error($"搜索:{arg[2]} 没有结果");
                     return;
                 }
                 string id = data2[0]["mid"].ToString();
                 data1 = HttpUtils.GetDynamicUid(id);
                 if (data1 == null)
                 {
                     Error($"获取不到动态:{id}");
                     return;
                 }
                 string temp1 = DynamicPicGen.Gen(data1);
                 Program.Log($"已生成{temp1}");
             }
         }
         else if (arg[0] == "reload")
         {
             Reload();
             Log("已重读");
         }
     }
 }