Skip to content

Instantly share code, notes, and snippets.

@SilverCory
Last active May 28, 2019 10:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SilverCory/65663c6049d1cc72e2a07f141b0b1f0c to your computer and use it in GitHub Desktop.
Save SilverCory/65663c6049d1cc72e2a07f141b0b1f0c to your computer and use it in GitHub Desktop.
Draw a penis in glance
package main
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"net/http"
"reflect"
"strconv"
"time"
)
var bots1 = []int{1, 2, 3, 4, 5, 33, 34, 35, 36, 37, 65, 66, 67, 68, 69, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 225, 226, 227, 228, 229, 257, 258, 259, 260, 261, 289, 290, 291, 292, 293}
var bots2 = []int{183, 184, 218, 251, 333, 334, 335}
const GLANCE_URL = "https://glance.example.com/webhook/[key]/"
const (
ColourBackground = 0
ColourPenis = 3
ColourCum = 4
)
func main() {
plusOne := true
for {
// Alternate penis colours for added memes.
penisColour := ColourPenis
plusOne = !plusOne
if plusOne {
penisColour = ColourPenis - 1
}
// Iterate over the total number of shards (355), and set the colour apropriately.
for i := 0; i < 355; i++ {
if inArray(i, bots1) {
go setGlance(i, penisColour, 0)
} else if inArray(i, bots2) {
go setGlance(i, ColourCum, 0)
} else {
go setGlance(i, ColourBackground, 0)
}
}
fmt.Println("Done!")
time.Sleep(time.Minute)
}
}
// ShardUpdate is the carrier for a shard update
type ShardUpdate struct {
ID int
Status int
Bot int
}
func setGlance(ID, Status, Bot int) (err error) {
data, err := json.Marshal(&ShardUpdate{ID, Status, Bot})
if err != nil {
return
}
byteBuf := new(bytes.Buffer)
byteBuf.Write(data)
resp, err := http.Post(GLANCE_URL, "meme", byteBuf)
if err != nil {
return
}
if resp.StatusCode != 202 {
err = errors.New("status code was invalid " + strconv.Itoa(resp.StatusCode) + ": " + resp.Status)
}
return
}
// inArray will check if a value is in the supplied array/slice.
func inArray(val int, array []int) bool {
for _, v := range array {
if v == val {
return true
}
}
return false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment