utils

package
v0.0.0-...-7ecc845 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 6, 2024 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotEnoughArguments  = errors.New("not enough arguments")
	ErrNotEnoughPermission = errors.New("not enough permission")
)
View Source
var CommandMap map[string]Command = make(map[string]Command)
View Source
var OpenAIClient = openai.NewClient(env.OPENAI_API_KEY)
View Source
var PastMessages = make(map[types.JID][]openai.ChatCompletionMessage, 0)

TODO: Move this to database

Functions

func ClearChat

func ClearChat(chat types.JID)

func CreateAudioMessage

func CreateAudioMessage(client *whatsmeow.Client, audio []byte) (*waProto.Message, error)

func CreateCommand

func CreateCommand(name string, permission string, description string, execute func(client *whatsmeow.Client, chat types.JID, user string, ctx *waProto.ContextInfo, pipe *waProto.Message, args []string) (*waProto.Message, error))

func CreateImgCmd

func CreateImgCmd(process func(image.Image) *image.NRGBA) func(client *whatsmeow.Client, chat types.JID, user string, ctx *waProto.ContextInfo, pipe *waProto.Message, args []string) (*waProto.Message, error)

func CreateImgMessage

func CreateImgMessage(client *whatsmeow.Client, buffer []byte) (*waProto.Message, error)

func CreateStickerMessage

func CreateStickerMessage(client *whatsmeow.Client, buffer []byte) (*waProto.Message, error)

func CreateTextMessage

func CreateTextMessage(content string) *waProto.Message

func CreateVideoMessage

func CreateVideoMessage(client *whatsmeow.Client, buffer []byte) (*waProto.Message, error)

func CreateVoiceVoxClient

func CreateVoiceVoxClient() *voicevox.Client

func GetChatReponse

func GetChatReponse(chat types.JID, prompt string) (string, error)

func GetMedia

func GetMedia(client *whatsmeow.Client, fetchUrl string) (*waProto.Message, error)

func GetMemeImg

func GetMemeImg(meme *RedditMemeResponse) ([]byte, error)

func GetTextContext

func GetTextContext(msg *waProto.Message) (string, *waProto.ContextInfo)

func GetWaifu

func GetWaifu(category string) ([]byte, error)

func Mp3ToOgg

func Mp3ToOgg(audioData []byte) ([]byte, error)

func OggToMp3

func OggToMp3(audioData []byte) ([]byte, error)

func SetSystemChat

func SetSystemChat(chat types.JID, content string)

func ToOgg

func ToOgg(audioData []byte) ([]byte, error)

func TranscribeAudio

func TranscribeAudio(audioData []byte) (string, error)

func Txt2Img

func Txt2Img(prompt string) ([]byte, error)

func VideoToAudio

func VideoToAudio(videoData []byte) ([]byte, error)

func WebmToOgg

func WebmToOgg(audioData []byte) ([]byte, error)

Types

type Command

type Command struct {
	Name        string
	Permission  string
	Description string
	Execute     func(client *whatsmeow.Client, chat types.JID, user string, ctx *waProto.ContextInfo, pipe *waProto.Message, args []string) (*waProto.Message, error)
}

type CommandInput

type CommandInput struct {
	Name string
	Args []string
}

type RedditMemeResponse

type RedditMemeResponse struct {
	PostLink  string   `json:"postLink"`
	SubReddit string   `json:"subreddit"`
	Title     string   `json:"title"`
	URL       string   `json:"url"`
	NSFW      bool     `json:"nsfw"`
	Spoiler   bool     `json:"spoiler"`
	Author    string   `json:"author"`
	UPs       int      `json:"ups"`
	Preview   []string `json:"preview"`
}

func GetMeme

func GetMeme(subreddit string) (*RedditMemeResponse, error)

type Txt2ImgRequest

type Txt2ImgRequest struct {
	Prompt         string `json:"prompt"`
	NegativePrompt string `json:"negative_prompt"`
	Steps          int64  `json:"steps"`
	Width          int64  `json:"width"`
	Height         int64  `json:"height"`
	SamplerName    string `json:"sampler_name"`
}

type Txt2ImgResponse

type Txt2ImgResponse struct {
	Images []string `json:"images"`
	Info   string   `json:"info"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL