Refactor to put all types in types.go

pull/46/head
Donnie Adams 10 years ago
parent b68832daa6
commit b7a4acc343
  1. 114
      methods.go
  2. 114
      types.go

@ -14,120 +14,6 @@ import (
"strconv" "strconv"
) )
// Constant values for ChatActions
const (
ChatTyping = "typing"
ChatUploadPhoto = "upload_photo"
ChatRecordVideo = "record_video"
ChatUploadVideo = "upload_video"
ChatRecordAudio = "record_audio"
ChatUploadAudio = "upload_audio"
ChatUploadDocument = "upload_document"
ChatFindLocation = "find_location"
)
// MessageConfig contains information about a SendMessage request.
type MessageConfig struct {
ChatID int
Text string
DisableWebPagePreview bool
ReplyToMessageID int
ReplyMarkup interface{}
}
// ForwardConfig contains infomation about a ForwardMessage request.
type ForwardConfig struct {
ChatID int
FromChatID int
MessageID int
}
// PhotoConfig contains information about a SendPhoto request.
type PhotoConfig struct {
ChatID int
Caption string
ReplyToMessageID int
ReplyMarkup interface{}
UseExistingPhoto bool
FilePath string
FileID string
}
// AudioConfig contains information about a SendAudio request.
type AudioConfig struct {
ChatID int
ReplyToMessageID int
ReplyMarkup interface{}
UseExistingAudio bool
FilePath string
FileID string
}
// DocumentConfig contains information about a SendDocument request.
type DocumentConfig struct {
ChatID int
ReplyToMessageID int
ReplyMarkup interface{}
UseExistingDocument bool
FilePath string
FileID string
}
// StickerConfig contains information about a SendSticker request.
type StickerConfig struct {
ChatID int
ReplyToMessageID int
ReplyMarkup interface{}
UseExistingSticker bool
FilePath string
FileID string
}
// VideoConfig contains information about a SendVideo request.
type VideoConfig struct {
ChatID int
ReplyToMessageID int
ReplyMarkup interface{}
UseExistingVideo bool
FilePath string
FileID string
}
// LocationConfig contains information about a SendLocation request.
type LocationConfig struct {
ChatID int
Latitude float64
Longitude float64
ReplyToMessageID int
ReplyMarkup interface{}
}
// ChatActionConfig contains information about a SendChatAction request.
type ChatActionConfig struct {
ChatID int
Action string
}
// UserProfilePhotosConfig contains information about a GetUserProfilePhotos request.
type UserProfilePhotosConfig struct {
UserID int
Offset int
Limit int
}
// UpdateConfig contains information about a GetUpdates request.
type UpdateConfig struct {
Offset int
Limit int
Timeout int
}
// WebhookConfig contains information about a SetWebhook request.
type WebhookConfig struct {
Clear bool
URL *url.URL
}
// MakeRequest makes a request to a specific endpoint with our token. // MakeRequest makes a request to a specific endpoint with our token.
// All requests are POSTs because Telegram doesn't care, and it's easier. // All requests are POSTs because Telegram doesn't care, and it's easier.
func (bot *BotAPI) MakeRequest(endpoint string, params url.Values) (APIResponse, error) { func (bot *BotAPI) MakeRequest(endpoint string, params url.Values) (APIResponse, error) {

@ -4,6 +4,18 @@ import (
"encoding/json" "encoding/json"
) )
// Constant values for ChatActions
const (
ChatTyping = "typing"
ChatUploadPhoto = "upload_photo"
ChatRecordVideo = "record_video"
ChatUploadVideo = "upload_video"
ChatRecordAudio = "record_audio"
ChatUploadAudio = "upload_audio"
ChatUploadDocument = "upload_document"
ChatFindLocation = "find_location"
)
// APIResponse is a response from the Telegram API with the result stored raw. // APIResponse is a response from the Telegram API with the result stored raw.
type APIResponse struct { type APIResponse struct {
Ok bool `json:"ok"` Ok bool `json:"ok"`
@ -151,3 +163,105 @@ type ForceReply struct {
ForceReply bool `json:"force_reply"` ForceReply bool `json:"force_reply"`
Selective bool `json:"force_reply"` Selective bool `json:"force_reply"`
} }
// MessageConfig contains information about a SendMessage request.
type MessageConfig struct {
ChatID int
Text string
DisableWebPagePreview bool
ReplyToMessageID int
ReplyMarkup interface{}
}
// ForwardConfig contains infomation about a ForwardMessage request.
type ForwardConfig struct {
ChatID int
FromChatID int
MessageID int
}
// PhotoConfig contains information about a SendPhoto request.
type PhotoConfig struct {
ChatID int
Caption string
ReplyToMessageID int
ReplyMarkup interface{}
UseExistingPhoto bool
FilePath string
FileID string
}
// AudioConfig contains information about a SendAudio request.
type AudioConfig struct {
ChatID int
ReplyToMessageID int
ReplyMarkup interface{}
UseExistingAudio bool
FilePath string
FileID string
}
// DocumentConfig contains information about a SendDocument request.
type DocumentConfig struct {
ChatID int
ReplyToMessageID int
ReplyMarkup interface{}
UseExistingDocument bool
FilePath string
FileID string
}
// StickerConfig contains information about a SendSticker request.
type StickerConfig struct {
ChatID int
ReplyToMessageID int
ReplyMarkup interface{}
UseExistingSticker bool
FilePath string
FileID string
}
// VideoConfig contains information about a SendVideo request.
type VideoConfig struct {
ChatID int
ReplyToMessageID int
ReplyMarkup interface{}
UseExistingVideo bool
FilePath string
FileID string
}
// LocationConfig contains information about a SendLocation request.
type LocationConfig struct {
ChatID int
Latitude float64
Longitude float64
ReplyToMessageID int
ReplyMarkup interface{}
}
// ChatActionConfig contains information about a SendChatAction request.
type ChatActionConfig struct {
ChatID int
Action string
}
// UserProfilePhotosConfig contains information about a GetUserProfilePhotos request.
type UserProfilePhotosConfig struct {
UserID int
Offset int
Limit int
}
// UpdateConfig contains information about a GetUpdates request.
type UpdateConfig struct {
Offset int
Limit int
Timeout int
}
// WebhookConfig contains information about a SetWebhook request.
type WebhookConfig struct {
Clear bool
URL *url.URL
}