Totally new, universal API
This commit is contained in:
parent
d3f7ac7197
commit
da026b435e
2 changed files with 70 additions and 136 deletions
44
configs.go
44
configs.go
|
@ -40,6 +40,7 @@ const (
|
|||
|
||||
type Chattable interface {
|
||||
Values() (url.Values, error)
|
||||
Method() string
|
||||
}
|
||||
|
||||
type Fileable interface {
|
||||
|
@ -133,6 +134,10 @@ func (config MessageConfig) Values() (url.Values, error) {
|
|||
return v, nil
|
||||
}
|
||||
|
||||
func (config MessageConfig) Method() string {
|
||||
return "SendMessage"
|
||||
}
|
||||
|
||||
// ForwardConfig contains information about a ForwardMessage request.
|
||||
type ForwardConfig struct {
|
||||
BaseChat
|
||||
|
@ -143,17 +148,14 @@ type ForwardConfig struct {
|
|||
|
||||
func (config ForwardConfig) Values() (url.Values, error) {
|
||||
v, _ := config.BaseChat.Values()
|
||||
|
||||
if config.FromChannelUsername != "" {
|
||||
v.Add("chat_id", config.FromChannelUsername)
|
||||
} else {
|
||||
v.Add("chat_id", strconv.Itoa(config.FromChatID))
|
||||
}
|
||||
v.Add("message_id", strconv.Itoa(config.MessageID))
|
||||
|
||||
return v, nil
|
||||
}
|
||||
|
||||
func (config ForwardConfig) Method() string {
|
||||
return "forwardMessage"
|
||||
}
|
||||
|
||||
// PhotoConfig contains information about a SendPhoto request.
|
||||
type PhotoConfig struct {
|
||||
BaseFile
|
||||
|
@ -209,6 +211,10 @@ func (config PhotoConfig) Name() string {
|
|||
return "photo"
|
||||
}
|
||||
|
||||
func (config PhotoConfig) Method() string {
|
||||
return "SendPhoto"
|
||||
}
|
||||
|
||||
// AudioConfig contains information about a SendAudio request.
|
||||
type AudioConfig struct {
|
||||
BaseFile
|
||||
|
@ -278,6 +284,10 @@ func (config AudioConfig) Name() string {
|
|||
return "audio"
|
||||
}
|
||||
|
||||
func (config AudioConfig) Method() string {
|
||||
return "SendAudio"
|
||||
}
|
||||
|
||||
// DocumentConfig contains information about a SendDocument request.
|
||||
type DocumentConfig struct {
|
||||
BaseFile
|
||||
|
@ -326,6 +336,10 @@ func (config DocumentConfig) Name() string {
|
|||
return "document"
|
||||
}
|
||||
|
||||
func (config DocumentConfig) Method() string {
|
||||
return "sendDocument"
|
||||
}
|
||||
|
||||
// StickerConfig contains information about a SendSticker request.
|
||||
type StickerConfig struct {
|
||||
BaseFile
|
||||
|
@ -374,6 +388,10 @@ func (config StickerConfig) Name() string {
|
|||
return "sticker"
|
||||
}
|
||||
|
||||
func (config StickerConfig) Method() string {
|
||||
return "sendSticker"
|
||||
}
|
||||
|
||||
// VideoConfig contains information about a SendVideo request.
|
||||
type VideoConfig struct {
|
||||
BaseFile
|
||||
|
@ -430,6 +448,10 @@ func (config VideoConfig) Name() string {
|
|||
return "viceo"
|
||||
}
|
||||
|
||||
func (config VideoConfig) Method() string {
|
||||
return "sendVideo"
|
||||
}
|
||||
|
||||
// VoiceConfig contains information about a SendVoice request.
|
||||
type VoiceConfig struct {
|
||||
BaseFile
|
||||
|
@ -485,6 +507,10 @@ func (config VoiceConfig) Name() string {
|
|||
return "voice"
|
||||
}
|
||||
|
||||
func (config VoiceConfig) Method() string {
|
||||
return "sendVoice"
|
||||
}
|
||||
|
||||
// LocationConfig contains information about a SendLocation request.
|
||||
type LocationConfig struct {
|
||||
BaseChat
|
||||
|
@ -515,6 +541,10 @@ func (config LocationConfig) Values() (url.Values, error) {
|
|||
return v, nil
|
||||
}
|
||||
|
||||
func (config LocationConfig) Method() string {
|
||||
return "sendLocation"
|
||||
}
|
||||
|
||||
// ChatActionConfig contains information about a SendChatAction request.
|
||||
type ChatActionConfig struct {
|
||||
BaseChat
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue