Categories > Coding > C# >

{RELEASE} GitHub Gist API

Posts: 2099

Threads: 10

Joined: Sep, 2020

Reputation: 62

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);
        }
    }
  • 0

Discord : Doctor Doom#0550

Posts: 1430

Threads: 71

Joined: May, 2022

Reputation: 20

Replied

null/null

https://cdn.discordapp.com/emojis/902316292013445140.png

  • 0

i use arch btw

Posts: 1479

Threads: 95

Joined: Oct, 2019

Reputation: 103

Replied

Vouch Vortex Writes Big Brain Code.

  • 0

SeizureSalad

i love femboys

Posts: 1159

Threads: 79

Joined: Mar, 2021

Reputation: 40

Replied

why are you giving this to skids?!?!?!!?!! now they gonna be releasing mor shi features that are skdiddd lfafwhaofaf

  • 0

"Questionable intellegence, but I like the mystery" - CubeFaces

https://cdn.discordapp.com/attachments/1136067487847415848/1138948596679589898/sig.png

pepsi

PePsIDeveloper

vip

Posts: 309

Threads: 6

Joined: Apr, 2021

Reputation: 16

Replied

No vector is not sucky

  • 0

https://cdn.discordapp.com/attachments/661621789591470090/1013919752294498314/Untitled_1366_768_px_1546_202_px_2.gif

Posts: 1479

Threads: 95

Joined: Oct, 2019

Reputation: 103

Replied

@pepsi It Do Kinda Be.

  • 0

Posts: 2099

Threads: 10

Joined: Sep, 2020

Reputation: 62

Replied

@SeizureSalad was my main goal honestly lol

  • 0

Discord : Doctor Doom#0550

SeizureSalad

i love femboys

Posts: 1159

Threads: 79

Joined: Mar, 2021

Reputation: 40

Replied

@0x777_ but you is are has to make the releases shi so the skids eat it up and make mroe  hsji releases

  • 0

"Questionable intellegence, but I like the mystery" - CubeFaces

https://cdn.discordapp.com/attachments/1136067487847415848/1138948596679589898/sig.png

Posts: 2099

Threads: 10

Joined: Sep, 2020

Reputation: 62

Replied

@SeizureSalad I don't care lol

  • 0

Discord : Doctor Doom#0550

MrMikeCox

Mike Cox

Posts: 16

Threads: 2

Joined: Jul, 2022

Reputation: -2

Replied

imagine not disposing

  • 0

prochanell3345

JJSPLOITonTop

Posts: 19

Threads: 0

Joined: Aug, 2022

Reputation: -11

Replied

vouch

 

 

oh, Content length must be 10-5000 chars

  • 0

https://cdn.discordapp.com/attachments/968475002263466005/1006138303726227466/pedhurt.png

Users viewing this thread:

( Members: 0, Guests: 1, Total: 1 )