Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Braile = &framework.Command{ Name: "braile", PermissionRequired: 0, Exec: func(ctx *framework.Context) error { return nil }, }
View Source
var EdgeDet = &framework.Command{ Name: "edge", PermissionRequired: 0, OwnerOnly: false, Help: "Performs edge detection on an image and outputs the result", Exec: func(ctx *framework.Context) error { im, err := ctx.GetImage(0) if err != nil { return err } im = effect.EdgeDetection(im, 1.0) ctx.ReplyJPGImg(im, "edge.jpg") return nil }, }
View Source
var Ethan = &framework.Command{ Name: "ethan", PermissionRequired: 0, OwnerOnly: false, Help: "Generates an Ethan style meme", Exec: func(ctx *framework.Context) error { img, err := ctx.GetImage(0) if err != nil { return err } text, err := ctx.GetArgIndex(0) if err != nil { return err } textCtx := gg.NewContext(img.Bounds().Max.X, img.Bounds().Max.Y/3) textCtx.SetColor(color.White) textCtx.DrawRectangle(0, 0, float64(textCtx.Width()), float64(textCtx.Height())) textCtx.Fill() textCtx.SetColor(color.Black) textCtx.SetFontFace(util.GetNotoFont(16)) textCtx.DrawStringWrapped(text, float64(textCtx.Width()/2), float64(textCtx.Height()/2), 0.5, 0.5, float64(textCtx.Width())*0.8, 1.0, gg.AlignCenter) ethanCtx := gg.NewContext(img.Bounds().Max.X, img.Bounds().Max.Y+textCtx.Height()) ethanCtx.DrawImage(textCtx.Image(), 0, 0) ethanCtx.DrawImage(img, 0, textCtx.Height()) ctx.ReplyPNGImg(ethanCtx.Image(), "ethan.png") return nil }, }
View Source
var Instakill = &framework.Command{ Name: "instakill", Help: "Generates instakill audio on top of image (experimental)", Exec: func(ctx *framework.Context) error { var useBaikenAudio = false var videoBuffer *bytes.Buffer if rand.Intn(22) == 21 { useBaikenAudio = true } img, err := ctx.GetImage(0) if err != nil { return err } baiken, _ := ctx.GetArgIndex(0) if baiken != "" || useBaikenAudio { videoBuffer = av.AddAudioToImage(img, "instakill_baiken.ogg") } else { videoBuffer = av.AddAudioToImage(img, "instakill.ogg") } ctx.ReplyFile("instakill.webm", videoBuffer) return nil }, }
View Source
var Jpg = &framework.Command{ Name: "jpg", PermissionRequired: 0, Exec: func(ctx *framework.Context) error { img, err := ctx.GetImage(0) if err != nil { return err } outBuf := new(bytes.Buffer) err = jpeg.Encode(outBuf, img, &jpeg.Options{Quality: 1}) if err != nil { return err } ctx.ReplyFile("bruh.jpg", outBuf) return nil }, }
View Source
var Latex = &framework.Command{ Name: "latex", PermissionRequired: 0, OwnerOnly: false, Exec: func(ctx *framework.Context) error { input := ctx.TakeRest() image, err := latex.GenerateLatexImage(input) neg := imaging.Invert(image) if err != nil { return err } ctx.ReplyPNGImg(neg, "latex") return nil }, }
View Source
var Persona = &framework.Command{ Name: "persona", Help: "Generates a persona style template (might be expanded in the future)", Exec: func(ctx *framework.Context) error { im, err := ctx.GetImage(0) if err != nil { return err } thr := ctx.GetArgIndexDefault(0, "90") thrInt, err := strconv.Atoi(thr) if err != nil { return fmt.Errorf("%s is not a number", thr) } im = effect.Grayscale(im) im = segment.Threshold(im, uint8(thrInt)) im = effect.Median(im, 1.2) im = effect.Erode(im, .5) for y := 0; y < im.Bounds().Max.Y; y++ { for x := 0; x < im.Bounds().Max.X; x++ { r, g, b, _ := im.At(x, y).RGBA() if r<<8 >= 255 && g<<8 >= 255 && b<<8 >= 255 { im.(*image.RGBA).Set(x, y, color.RGBA{R: 255, G: 0, B: 0}) } } } ctx.ReplyJPGImg(im, "persona.jpg") return nil }, }
View Source
var Rumble = &framework.Command{ Name: "rumble", PermissionRequired: 0, Exec: func(ctx *framework.Context) error { input, err := ctx.GetImage(0) if err != nil { return err } mutRCtx := imaging.Resize(rumbleImg, input.Bounds().Max.X, input.Bounds().Max.Y/2, imaging.Lanczos) inputCtx := gg.NewContextForImage(input) inputCtx.DrawImage(mutRCtx, 0, 0) ctx.ReplyJPGImg(inputCtx.Image(), "rumble") return nil }, Setup: func() error { var err error rumbleImg, _, err = image.Decode(bytes.NewReader(rumbleBytes)) if err != nil { return errors.New("failed to decode rumble.png") } return nil }, }
View Source
var Stretch = &framework.Command{ Name: "stretch", PermissionRequired: 0, OwnerOnly: false, Exec: func(ctx *framework.Context) error { img, err := ctx.GetImage(0) if err != nil { return err } resizedImg := imaging.Resize(img, img.Bounds().Max.X*2, img.Bounds().Max.Y, imaging.Lanczos) ctx.ReplyPNGImg(resizedImg, "resize") return nil }, }
View Source
var Stronk = &framework.Command{ Name: "stronk", PermissionRequired: 0, OwnerOnly: false, Help: "Generates a stronk image, I made this out of spite: <text> [hex color]", Exec: func(ctx *framework.Context) error { text, err := ctx.GetArgIndex(0) if err != nil { return err } color := ctx.GetArgIndexDefault(1, "#ff006e") fin := gg.NewContextForImage(getStronkImage()) w, h := fin.MeasureString(text) textCtx := gg.NewContext(int(w), int(h)) textCtx.SetHexColor(color) textCtx.DrawRectangle(0, 0, w, h) textCtx.Fill() textCtx.SetColor(colornames.Black) textCtx.DrawStringAnchored(text, w/2, h/2, 0.5, 0.5) textImg := imaging.Resize(textCtx.Image(), 142, 39, imaging.Lanczos) fin.DrawImage(textImg, 403, 284) ctx.ReplyJPGImg(fin.Image(), "stronk") return nil }, }
View Source
var Sunny = &framework.Command{ Name: "sunny", Help: "Generates always sunny in philadelphia title cards", Exec: func(ctx *framework.Context) error { arg := ctx.TakeRest() arg = arg[1:] board := gg.NewContext(1920, 1080) board.SetColor(color.Black) board.Fill() board.SetColor(color.White) board.SetFontFace(util.GetFontByName("Textile", 128)) board.DrawStringWrapped(fmt.Sprintf(`"%v"`, arg), float64(board.Width()/2), float64(board.Height()/2), 0.5, 0.5, float64(board.Width())/1.75, 1, gg.AlignCenter) ctx.ReplyJPGImg(board.Image(), "phily") return nil }, }
View Source
var SunnyAudio = &framework.Command{ Name: "asunny", Help: "Generates always sunny in philadelphia title cards with audio (experimental)", Exec: func(ctx *framework.Context) error { arg := ctx.TakeRest() arg = arg[1:] board := gg.NewContext(1920, 1080) board.SetColor(color.Black) board.Fill() board.SetColor(color.White) board.SetFontFace(util.GetFontByName("Textile", 128)) board.DrawStringWrapped(fmt.Sprintf(`"%v"`, arg), float64(board.Width()/2), float64(board.Height()/2), 0.5, 0.5, float64(board.Width())/1.75, 1, gg.AlignCenter) videoBuffer := av.AddAudioToImage(board.Image(), "sunny.ogg") ctx.ReplyFile("sunny.webm", videoBuffer) return nil }, }
View Source
var SunnyVideo = &framework.Command{ Name: "vsunny", Help: "Generates always sunny in philadelphia title sequences (experimental)", Exec: func(ctx *framework.Context) error { arg := ctx.TakeRest() arg = arg[1:] board := gg.NewContext(1920, 1080) board.SetColor(color.Black) board.Fill() board.SetColor(color.White) board.SetFontFace(util.GetFontByName("Textile", 128)) board.DrawStringWrapped(fmt.Sprintf(`"%v"`, arg), float64(board.Width()/2), float64(board.Height()/2), 0.5, 0.5, float64(board.Width())/1.75, 1, gg.AlignCenter) videoBuffer := av.OverlayImage(board.Image(), "sunny.webm", 0, 90) ctx.ReplyFile("sunny.mp4", videoBuffer) return nil }, }
View Source
var Wrong = &framework.Command{ Name: "wrong", Help: "You used the wrong your haha", Exec: func(ctx *framework.Context) error { srcGif := getSpiesGif() text := ctx.TakeRest() ed := computeEditData(srcGif.Image[0], text) iArr := make([]*image.Paletted, len(srcGif.Image)) var w sync.WaitGroup for idx, im := range srcGif.Image { w.Add(1) go func(idx int, im *image.Paletted) { iArr[idx] = insertText(im, ed) w.Done() }(idx, im) } w.Wait() srcGif.Config.Height = ed.Height srcGif.Image = iArr ctx.ReplyGIFImg(srcGif, "wrong") return nil }, }
View Source
var Zoom = &framework.Command{ Name: "zoom", PermissionRequired: 0, OwnerOnly: false, Help: "", Exec: func(ctx *framework.Context) error { msg, err := ctx.GetPreviousMessage() if err != nil { return err } if len(msg.Embeds) <= 0 { return fmt.Errorf("this command can only be used with embeded images") } imgUrl := msg.Embeds[0].URL resp, err := http.Get(imgUrl) if err != nil { return err } defer resp.Body.Close() g, err := gif.DecodeAll(resp.Body) if err != nil { return err } for i, d := range g.Delay { g.Delay[i] = d / 2 } _, err = ctx.ReplyGIFImg(g, "zoom") if err != nil { return err } return nil }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.