Skip to content

A modern and small API wrapper for the AlexFlipnote API

License

Notifications You must be signed in to change notification settings

lavgup/alexflipnote.go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

alexflipnote.go

A modern and small API wrapper for the AlexFlipnote API. It handles authorization and everything needed to access and use the API.

Example usage

Simple

package main

import (
    "fmt"
    alexflipnote "github.com/lavgup/alexflipnote.go"
)

func main() {
    client := alexflipnote.NewClient("TOKEN")
    
    body, err := client.Facts("butch and sundance are back, baby!")
    if err != nil {
        fmt.Println(err)
    }
    
    // WARNING: This will spam your console
    fmt.Printf("Received bytes: %s", body)
}

Image

package main

import (
    "fmt"
    alexflipnote "github.com/lavgup/alexflipnote.go"
    "net/url"
)

func main() {
    client := alexflipnote.NewClient("TOKEN")
    
    imageUrl := "https://cdn.discordapp.com/avatars/441164156016787486/7a9cc8980bed842503c451efc79b74f7.png"
    parsedUrl, err := url.Parse(imageUrl)
    if err != nil {
        fmt.Println(err)
    }
    
    body, err := client.AmIAJoke(parsedUrl)
    if err != nil {
        fmt.Println(err)
    }
    
    // WARNING: This will spam your console
    fmt.Printf("Received bytes: %s", body)
}

The image returns are of type []byte, so to send it via discordgo, wrap it with a Buffer e.g session.ChannelFileSend(id, "image.png", bytes.NewBuffer(image)).

Endpoints which return JSON are converted to maps.

About

A modern and small API wrapper for the AlexFlipnote API

Topics

Resources

License

Stars

Watchers

Forks

Languages