Categories > Coding > C# >
{RELEASE} GitHub Gist API
Posted
Wrote this ages ago for Nihon so here lol, using Octcokit.net
Don't care if the code is unoptimized suck my nut tard.
public class gist_integration
{
/* Nihon and vivian :weary:, vector sucks. Credits to null */
public string token;
public GitHubClient client;
public gist_integration(string _token)
{
token = _token;
client = new GitHubClient(new ProductHeaderValue("test-app"))
{
Credentials = new Credentials(token)
};
}
public KeyValuePair<string, GistFile> get_gist(string id) =>
client.Gist.Get(id).Result.Files.FirstOrDefault();
public IReadOnlyList<Gist> get_allgist() =>
client.Gist.GetAll().GetAwaiter().GetResult();
public IReadOnlyList<Gist> get_allgist(string user) =>
client.Gist.GetAllForUser(user).GetAwaiter().GetResult();
public void upload_gist(
string name, string content, string desc, bool _public = false)
{
var gist = new NewGist()
{
Description = desc,
Public = _public,
};
gist.Files.Add(name, content);
Process.Start(client.Gist.Create(gist).GetAwaiter().GetResult().HtmlUrl);
Console.WriteLine($"gist created, title : {name} content : {content}");
}
public void delete_gist(string id)
{
client.Gist.Delete(id);
Console.WriteLine($"gist deleted : {id}");
}
public void edit_gist(string new_file_name, string new_content)
{
var updateGist = new GistUpdate
{
Description = "my newly updated gist"
};
var gistFileUpdate = new GistFileUpdate
{
NewFileName = new_file_name,
Content = new_content
};
updateGist.Files.Add("myGistTestFile.cs", gistFileUpdate);
client.Gist.Edit("1", updateGist);
}
}
Discord : Doctor Doom#0550
i use arch btw
Replied
Vouch Vortex Writes Big Brain Code.
Cancel
Post
Replied
why are you giving this to skids?!?!?!!?!! now they gonna be releasing mor shi features that are skdiddd lfafwhaofaf
Cancel
Post
"Questionable intellegence, but I like the mystery" - CubeFaces
https://cdn.discordapp.com/attachments/1136067487847415848/1138948596679589898/sig.png
Replied
No vector is not sucky
Cancel
Post
https://cdn.discordapp.com/attachments/661621789591470090/1013919752294498314/Untitled_1366_768_px_1546_202_px_2.gif
Discord : Doctor Doom#0550
Replied
@0x777_ but you is are has to make the releases shi so the skids eat it up and make mroe hsji releases
Cancel
Post
"Questionable intellegence, but I like the mystery" - CubeFaces
https://cdn.discordapp.com/attachments/1136067487847415848/1138948596679589898/sig.png
Discord : Doctor Doom#0550
Replied
imagine not disposing
Cancel
Post
Replied
vouch
oh, Content length must be 10-5000 chars
Cancel
Post
https://cdn.discordapp.com/attachments/968475002263466005/1006138303726227466/pedhurt.png
Users viewing this thread:
( Members: 0, Guests: 1, Total: 1 )
Cancel
Post