diff --git a/.gitignore b/.gitignore index f1c181e..3953589 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,6 @@ # Output of the go coverage tool, specifically when used with LiteIDE *.out + +# IDEA +.idea \ No newline at end of file diff --git a/api.go b/api.go new file mode 100644 index 0000000..f7f592f --- /dev/null +++ b/api.go @@ -0,0 +1,3 @@ +package tamtam + +// TODO methods diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..e02b27c --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/neonxp/tamtam-go + +go 1.12 diff --git a/types.go b/types.go new file mode 100644 index 0000000..1cd88af --- /dev/null +++ b/types.go @@ -0,0 +1,107 @@ +package tamtam + +type BotInfo struct { + UserID int64 `json:"user_id"` + Name string `json:"name"` + Username string `json:"username,omitempty"` + AvatarURL string `json:"avatar_url"` + FullAvatarURL string `json:"full_avatar_url"` +} + +type ChatType string + +const ( + TypeDialog ChatType = "dialog" + TypeChat = "chat" + TypeChannel = "channel" +) + +type StatusType string + +const ( + StatusActive StatusType = "active" + StatusRemoved = "removed" + StatusLeft = "left" + StatusClosed = "closed" + StatusSuspended = "suspended" +) + +type Chat struct { + ChatID int64 `json:"chat_id"` + Type ChatType `json:"type"` + Status StatusType `json:"status"` + Title string `json:"title"` + Icon struct { + URL string `json:"url"` + } `json:"icon"` + LastEventTime int64 `json:"last_event_time"` + ParticipantsCount int32 `json:"participants_count"` + OwnerID int64 `json:"owner_id"` + Participants interface{} `json:"participants,omitempty"` + IsPublic bool `json:"is_public"` + Link string `json:"link,omitempty"` + Description string `json:"description,omitempty"` +} + +type Chats struct { + Chats []Chat `json:"chats"` + Marker int `json:"marker"` +} + +type Participant struct { + UserID int64 `json:"user_id"` + Name string `json:"name"` + Username string `json:"username,omitempty"` +} + +type Recipient struct { + ChatID int64 `json:"chat_id"` + ChatType ChatType `json:"chat_type"` + UserID int64 `json:"user_id,omitempty"` +} + +type LinkType string + +const ( + LinkForward = "forward" + LinkReply = "reply" +) + +type Message struct { + Sender Participant `json:"sender"` + Recipient Recipient `json:"recipient"` + Timestamp int64 `json:"timestamp"` + Link struct { + Type LinkType `json:"type"` + Sender Participant `json:"sender"` + ChatID int64 `json:"chat_id"` + Message MessageBody `json:"message"` + } `json:"link"` + Body MessageBody `json:"body"` +} + +type AttachmentType string + +const ( + AttachmentImage AttachmentType = "image" + AttachmentVideo = "video" + AttachmentAudio = "audio" + AttachmentFile = "file" + AttachmentContact = "contact" + AttachmentSticker = "sticker" + AttachmentShare = "share" + AttachmentLocation = "location" + AttachmentKeyboard = "inline_keyboard" +) + +type Attachment struct { + Type AttachmentType `json:"type"` + Payload interface{} `json:"payload"` +} + +type MessageBody struct { + MID string `json:"mid"` + Seq int64 `json:"seq"` + Text string `json:"text,omitempty"` + Attachments []Attachment `json:"attachments"` +}