hhooking

package module
v0.0.0-...-e49fec5 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2021 License: MIT Imports: 11 Imported by: 0

README

hhooking

(略: hh -> 呼称: ふっくふっく)

Discord Slash Commands on Webhook API Wrapper written Golang.


Webhookで動作するDiscord Slash CommandsのGolang-wrapperです.
主にGoogle Cloud Functionsで動作することを想定して作られています(Standalone Serverも使えます)


(c) 2021, Nanai10a.

Documentation

Index

Constants

View Source
const (
	AcptRole = 1
	AcptUser = 2
)

Acpt: ApplicationCommandPermissonType

View Source
const (
	BaseAPIUrl = "https://discord.com/api/v8/"
)

Variables

This section is empty.

Functions

func CreateFollowupMessage

func CreateFollowupMessage(appId SnowFlake, authToken string, iaToken string, data WebhookMessagePostData)

func CreateInteractionResponse

func CreateInteractionResponse(appId SnowFlake, authToken string, iaId SnowFlake, iaToken string, res InteractionReponse)

func DeleteApplicationCommand

func DeleteApplicationCommand(appId SnowFlake, authToken string, cmdId SnowFlake, guildId *SnowFlake)

func DeleteOriginalInteractionResponse

func DeleteOriginalInteractionResponse(appId SnowFlake, authToken string, iaToken string, msgId *SnowFlake)

FIXME: msgIdを使用すると"Delete Followup Message"なので命名に問題あり

func SignatureVerify

func SignatureVerify(r *http.Request, key ed25519.PublicKey) bool

Types

type AllowedMention

type AllowedMention interface{} // FIXME: これInterfaceなんだけどどうしよう

type ApplicationCommand

type ApplicationCommand struct {
	Id               SnowFlake                   `json:"id"`
	ApplicationId    SnowFlake                   `json:"application_id"`
	Name             string                      `json:"name"`
	Description      string                      `json:"description"`
	Options          *[]ApplicationCommandOption `json:"options,omitempty"`
	DefaultPermisson *bool                       `json:"default_permission,omitempty"` // default: true
}

func BulkOverwriteApplicationCommands

func BulkOverwriteApplicationCommands(appId SnowFlake, authToken string, guildId *SnowFlake, data []ApplicationCommandPostData) []ApplicationCommand

func CreateApplicationCommands

func CreateApplicationCommands(appId SnowFlake, authToken string, guildId *SnowFlake, data ApplicationCommandPostData) ApplicationCommand

func EditApplicationCommand

func EditApplicationCommand(appId SnowFlake, authToken string, cmdId SnowFlake, guildId *SnowFlake, data ApplicationCommandPatchData) ApplicationCommand

func GetApplicationCommand

func GetApplicationCommand(appId SnowFlake, authToken string, cmdId SnowFlake, guildId *SnowFlake) ApplicationCommand

func GetApplicationCommands

func GetApplicationCommands(appId SnowFlake, authToken string, guildId *SnowFlake) []ApplicationCommand

type ApplicationCommandInteractionData

type ApplicationCommandInteractionData struct {
	Id            SnowFlake                                  `json:"id"`
	Name          string                                     `json:"name"`
	Resolved      *ApplicationCommandInteractionDataResolved `json:"resolved,omitempty"`
	Options       *[]ApplicationCommandInteractionDataOption `json:"options,omitempty"`
	CustomId      string                                     `json:"custom_id"`
	ComponentType int                                        `json:"component_type"`
}

type ApplicationCommandInteractionDataOption

type ApplicationCommandInteractionDataOption struct {
	Name    string                                     `json:"name"`
	Type    ApplicationCommandOptionType               `json:"type"`
	Value   *OptionType                                `json:"value,omitempty"`
	Options *[]ApplicationCommandInteractionDataOption `json:"options,omitempty"`
}

type ApplicationCommandInteractionDataResolved

type ApplicationCommandInteractionDataResolved struct {
}

type ApplicationCommandOption

type ApplicationCommandOption struct {
	Type        ApplicationCommandOptionType      `json:"type"`
	Name        string                            `json:"name"`
	Description string                            `json:"description"`
	Required    *bool                             `json:"required,omitempty"`
	Choices     *[]ApplicationCommandOptionChoice `json:"choices,omitempty"`
	Options     *[]ApplicationCommandOption       `json:"options,omitempty"`
}

type ApplicationCommandOptionChoice

type ApplicationCommandOptionChoice struct {
	Name  string `json:"name"`
	Value string `json:"value"` // string (others) or int (ACOT_INTEGER) // TODO: 合ってる?
}

type ApplicationCommandOptionType

type ApplicationCommandOptionType int
const (
	AcotSubCommand      ApplicationCommandOptionType = 1
	AcotSubCommandGroup ApplicationCommandOptionType = 2
	AcotString          ApplicationCommandOptionType = 3
	AcotInteger         ApplicationCommandOptionType = 4
	AcotBoolean         ApplicationCommandOptionType = 5
	AcotUser            ApplicationCommandOptionType = 6
	AcotChannel         ApplicationCommandOptionType = 7
	AcotRole            ApplicationCommandOptionType = 8
	AcotMentionable     ApplicationCommandOptionType = 9
)

Acot: ApplicationCommandOptionType

type ApplicationCommandPatchData

type ApplicationCommandPatchData struct {
	Name             string                     `json:"name,omitempty"`
	Description      string                     `json:"description,omitempty"`
	Options          []ApplicationCommandOption `json:"options,omitempty"`
	DefaultPermisson bool                       `json:"default_permisson,omitempty"`
}

FIXME: 内容は同じだけどtagだけ違うので微妙なところではある "...PostData"との統合を検討.

type ApplicationCommandPermissions

type ApplicationCommandPermissions struct {
	Id        SnowFlake                       `json:"id"`
	Type      ApplicationCommandPermissonType `json:"type"`
	Permisson bool                            `json:"permisson"`
}

type ApplicationCommandPermissonType

type ApplicationCommandPermissonType int

type ApplicationCommandPostData

type ApplicationCommandPostData struct {
	Name             string                     `json:"name"`
	Description      string                     `json:"description"`
	Options          []ApplicationCommandOption `json:"options,omitempty"`
	DefaultPermisson bool                       `json:"default_permisson,omitempty"`
}

type GCFInteractionFunction

type GCFInteractionFunction func(http.ResponseWriter, *http.Request)

func CreateInteractionHandler

func CreateInteractionHandler(hexEncodedKey string, h GCFInteractionHandler) GCFInteractionFunction

type GCFInteractionHandler

type GCFInteractionHandler func(Interaction) InteractionReponse

type GuildApplicationCommandPermissions

type GuildApplicationCommandPermissions struct {
	Id            SnowFlake                       `json:"id"`
	ApplicationId SnowFlake                       `json:"application_id"`
	GuiidId       SnowFlake                       `json:"guild_id"`
	Permissons    []ApplicationCommandPermissions `json:"permissons"`
}

type Interaction

type Interaction struct {
	Id            SnowFlake                          `json:"id"`
	ApplicationId SnowFlake                          `json:"application_id"`
	Type          InteractionType                    `json:"type"`
	Data          *ApplicationCommandInteractionData `json:"data,omitempty"`
	GuildId       *SnowFlake                         `json:"guild_id"`
	ChannelId     *SnowFlake                         `json:"channel_id"`
	// Member *Member `json:"member,omitempty"`
	// User *User `json:"user,omitempty"`
	Token   string `json:"token"`
	Version int    `json:"version"`
}

type InteractionApplicationCommandCallbackData

type InteractionApplicationCommandCallbackData struct {
	Tts     bool    `json:"tts"`
	Content *string `json:"content,omitempty"`
	// Embeds *[]Embed `json:"embeds,omitempty"`
	AllowedMentions *AllowedMention `json:"allowed_mentions,omitempty"`
	Flags           int             `json:"flags"` // set 64
}

type InteractionCallbackType

type InteractionCallbackType int
const (
	IctPong                             InteractionCallbackType = 1
	IctChannelMessageWithSource         InteractionCallbackType = 4
	IctDeferredChannelMessageWithSource InteractionCallbackType = 5
	IctDeferredUpdateMessage            InteractionCallbackType = 6
	IctUpdateMessage                    InteractionCallbackType = 7
)

type InteractionReponse

type InteractionReponse struct {
	Type InteractionCallbackType                    `json:"type"`
	Data *InteractionApplicationCommandCallbackData `json:"data,omitempty"`
}

type InteractionServer

type InteractionServer struct {
	// contains filtered or unexported fields
}

func NewInteractionServer

func NewInteractionServer() *InteractionServer

func (*InteractionServer) RegisterHandlers

func (s *InteractionServer) RegisterHandlers(hs ...StandaloneInteractionHandler)

type InteractionType

type InteractionType int
const (
	ItPing               InteractionType = 1
	ItApplicationCommand InteractionType = 2
	ItMessageComponent   InteractionType = 3
)

It: InteractionType

type Message

type Message struct{}

func EditOriginalInteractionResponse

func EditOriginalInteractionResponse(appId SnowFlake, authToken string, iaToken string, msgId *SnowFlake, data WebhookMessagePatchData) Message

FIXME: msgIdを使用すると"Edit Followup Message"なので命名に問題あり

func GetOriginalInteractionResponse

func GetOriginalInteractionResponse(appId SnowFlake, authToken string, iaToken string) Message

type MessageInteraction

type MessageInteraction struct {
	Id   SnowFlake       `json:"id"`
	Type InteractionType `json:"type"`
	Name string          `json:"name"`
}

type OptionType

type OptionType string // FIXME: この型わかんない

type SnowFlake

type SnowFlake string

type StandaloneInteractionHandler

type StandaloneInteractionHandler func(*fiber.Ctx)

type WebhookMessagePatchData

type WebhookMessagePatchData struct{}

type WebhookMessagePostData

type WebhookMessagePostData struct{}

Jump to

Keyboard shortcuts

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