代码拉取完成,页面将自动刷新
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using RestSharp;
using RestSharp.Authenticators;
using System;
using System.Threading;
namespace github_control
{
class Program
{
private static RestClient Client;
private static int LastCount = 0;
private static string LastUser = "";
private static string access_token = "";
private static (int,string) Check()
{
var request = new RestRequest("", DataFormat.Json);
request.AddObject(new
{
access_token,
});
var response = Client.Get(request);
var stars = (int)JsonConvert.DeserializeObject<JObject>(response.Content)["stargazers_count"];
request = new RestRequest("stargazers", DataFormat.Json);
request.AddObject(new
{
access_token,
page = stars,
per_page = 1
});
response = Client.Get(request);
var user = (string)JsonConvert.DeserializeObject<JArray>(response.Content)[0]["name"];
return (stars,user);
}
private static void SetName(string name)
{
var request = new RestRequest("", DataFormat.Json);
request.AddObject(new
{
access_token,
name
});
var r = Client.Patch(request);
Console.WriteLine(r.Content);
}
static void Main(string[] args)
{
Client = new RestClient("https://gitee.com/api/v5/repos/chenxuuu/instresting-repo");
while (true)
{
try
{
var (s, u) = Check();
if (s != LastCount || u != LastUser)
{
LastCount = s;
LastUser = u;
SetName($"{u}和其他{s - 1}位小伙伴给了这个项目星星哦");
Console.WriteLine($"name changed:{u}和其他{s - 1}位小伙伴给了这个项目星星哦");
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
Thread.Sleep(10000);
}
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。