Example #1
0
 public static void SearchVideo(string name, long group)
 {
     Task.Run(() =>
     {
         try
         {
             var data1 = HttpUtils.SearchVideo(name);
             if (data1 == null)
             {
                 Program.SendGroupMessage($"搜索不到视频:{name}", group);
                 return;
             }
             var data2 = data1["data"]["result"] as JArray;
             if (data2.Count == 0)
             {
                 Program.SendGroupMessage($"搜索:{name} 没有结果", group);
                 return;
             }
             string bid = data2[0]["bvid"].ToString();
             data1      = HttpUtils.GetVideoB(bid);
             if (data1 == null)
             {
                 Program.SendGroupMessage($"获取视频:{bid}", group);
                 return;
             }
             string temp1 = VideoPicGen.Gen(data1);
             Program.Log($"已生成{temp1}");
             Program.SendGroupImage(temp1, group);
         }
         catch (Exception e)
         {
             Program.Error(e);
         }
     });
 }
Example #2
0
 public static void VideoBV(string video, long group)
 {
     Task.Run(() =>
     {
         try
         {
             var data1 = HttpUtils.GetVideoB(video);
             if (data1 == null)
             {
                 Program.SendGroupMessage($"获取不到视频:{video}", group);
                 return;
             }
             string temp1 = VideoPicGen.Gen(data1);
             Program.Log($"已生成{temp1}");
             Program.SendGroupImage(temp1, group);
         }
         catch (Exception e)
         {
             Program.Error(e);
         }
     });
 }
Example #3
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("已重读");
         }
     }
 }