forked from tucnak/telebot
-
Notifications
You must be signed in to change notification settings - Fork 1
/
telebot.go
136 lines (123 loc) · 4.09 KB
/
telebot.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// Package telebot is a framework for Telegram bots.
//
// Example:
//
// package main
//
// import (
// "time"
// tele "gopkg.in/telebot.v3"
// )
//
// func main() {
// b, err := tele.NewBot(tele.Settings{
// Token: "...",
// Poller: &tele.LongPoller{Timeout: 10 * time.Second},
// })
// if err != nil {
// return
// }
//
// b.Handle("/start", func(c tele.Context) error {
// return c.Send("Hello world!")
// })
//
// b.Start()
// }
//
package telebot
import "errors"
var (
ErrBadRecipient = errors.New("telebot: recipient is nil")
ErrUnsupportedWhat = errors.New("telebot: unsupported what argument")
ErrCouldNotUpdate = errors.New("telebot: could not fetch new updates")
ErrTrueResult = errors.New("telebot: result is True")
ErrBadContext = errors.New("telebot: context does not contain message")
)
const DefaultApiURL = "https://api.telegram.org"
// These are one of the possible events Handle() can deal with.
//
// For convenience, all Telebot-provided endpoints start with
// an "alert" character \a.
//
const (
// Basic message handlers.
OnText = "\atext"
OnEdited = "\aedited"
OnPhoto = "\aphoto"
OnAudio = "\aaudio"
OnAnimation = "\aanimation"
OnDocument = "\adocument"
OnSticker = "\asticker"
OnVideo = "\avideo"
OnVoice = "\avoice"
OnVideoNote = "\avideo_note"
OnContact = "\acontact"
OnLocation = "\alocation"
OnVenue = "\avenue"
OnDice = "\adice"
OnInvoice = "\ainvoice"
OnPayment = "\apayment"
OnGame = "\agame"
OnPoll = "\apoll"
OnPollAnswer = "\apoll_answer"
OnPinned = "\apinned"
OnChannelPost = "\achannel_post"
OnEditedChannelPost = "\aedited_channel_post"
OnAddedToGroup = "\aadded_to_group"
OnUserJoined = "\auser_joined"
OnUserLeft = "\auser_left"
OnNewGroupTitle = "\anew_chat_title"
OnNewGroupPhoto = "\anew_chat_photo"
OnGroupPhotoDeleted = "\achat_photo_deleted"
OnGroupCreated = "\agroup_created"
OnSuperGroupCreated = "\asupergroup_created"
OnChannelCreated = "\achannel_created"
// OnMigration happens when group switches to
// a supergroup. You might want to update
// your internal references to this chat
// upon switching as its ID will change.
OnMigration = "\amigration"
OnMedia = "\amedia"
OnCallback = "\acallback"
OnQuery = "\aquery"
OnInlineResult = "\ainline_result"
OnShipping = "\ashipping_query"
OnCheckout = "\apre_checkout_query"
OnMyChatMember = "\amy_chat_member"
OnChatMember = "\achat_member"
OnChatJoinRequest = "\achat_join_request"
OnProximityAlert = "\aproximity_alert_triggered"
OnAutoDeleteTimer = "\amessage_auto_delete_timer_changed"
OnWebApp = "\aweb_app"
OnVideoChatStarted = "\avideo_chat_started"
OnVideoChatEnded = "\avideo_chat_ended"
OnVideoChatParticipants = "\avideo_chat_participants_invited"
OnVideoChatScheduled = "\avideo_chat_scheduled"
)
// ChatAction is a client-side status indicating bot activity.
type ChatAction string
const (
Typing ChatAction = "typing"
UploadingPhoto ChatAction = "upload_photo"
UploadingVideo ChatAction = "upload_video"
UploadingAudio ChatAction = "upload_audio"
UploadingDocument ChatAction = "upload_document"
UploadingVNote ChatAction = "upload_video_note"
RecordingVideo ChatAction = "record_video"
RecordingAudio ChatAction = "record_audio"
RecordingVNote ChatAction = "record_video_note"
FindingLocation ChatAction = "find_location"
ChoosingSticker ChatAction = "choose_sticker"
)
// ParseMode determines the way client applications treat the text of the message
type ParseMode = string
const (
ModeDefault ParseMode = ""
ModeMarkdown ParseMode = "Markdown"
ModeMarkdownV2 ParseMode = "MarkdownV2"
ModeHTML ParseMode = "HTML"
)
// M is a shortcut for map[string]interface{}. Use it for passing
// arguments to the layout functions.
type M = map[string]interface{}