2017-11-21 02:49:37 +00:00
|
|
|
// Package telebot is a framework for Telegram bots.
|
2015-06-27 15:44:12 +00:00
|
|
|
//
|
2017-11-21 02:49:37 +00:00
|
|
|
// Example:
|
2015-06-27 15:44:12 +00:00
|
|
|
//
|
2017-11-21 02:49:37 +00:00
|
|
|
// import (
|
|
|
|
// "time"
|
|
|
|
// tb "gopkg.in/tucnak/telebot.v2"
|
|
|
|
// )
|
2015-06-27 15:44:12 +00:00
|
|
|
//
|
2017-11-21 02:49:37 +00:00
|
|
|
// func main() {
|
|
|
|
// b, err := tb.NewBot(tb.Settings{
|
|
|
|
// Token: "TOKEN_HERE",
|
|
|
|
// Poller: &tb.LongPoller{10 * time.Second},
|
|
|
|
// })
|
2015-06-27 15:44:12 +00:00
|
|
|
//
|
2017-11-21 02:49:37 +00:00
|
|
|
// if err != nil {
|
|
|
|
// return
|
|
|
|
// }
|
2015-06-27 15:44:12 +00:00
|
|
|
//
|
2017-11-21 02:49:37 +00:00
|
|
|
// b.Handle(tb.OnMessage, func(m *tb.Message) {
|
2017-11-24 15:24:07 +00:00
|
|
|
// b.Send(m.Sender, "hello world")
|
2015-06-27 15:44:12 +00:00
|
|
|
// }
|
2017-11-21 02:49:37 +00:00
|
|
|
//
|
|
|
|
// b.Start()
|
2015-06-27 15:44:12 +00:00
|
|
|
// }
|
|
|
|
//
|
2015-06-25 19:32:41 +00:00
|
|
|
package telebot
|
2015-07-06 16:13:08 +00:00
|
|
|
|
2017-11-21 02:22:45 +00:00
|
|
|
// These are one of the possible events Handle() can deal with.
|
2017-11-21 01:50:44 +00:00
|
|
|
//
|
|
|
|
// For convenience, all Telebot-provided endpoints start with
|
|
|
|
// an "alert" character \a.
|
|
|
|
const (
|
2017-11-24 15:24:07 +00:00
|
|
|
// Basic message handlers.
|
2017-11-23 02:13:15 +00:00
|
|
|
//
|
|
|
|
// Handler: func(*Message)
|
2017-11-24 15:24:07 +00:00
|
|
|
OnText = "\atext"
|
|
|
|
OnPhoto = "\aphoto"
|
|
|
|
OnAudio = "\aaudio"
|
|
|
|
OnDocument = "\adocument"
|
|
|
|
OnSticker = "\asticker"
|
|
|
|
OnVideo = "\avideo"
|
|
|
|
OnVoice = "\avoice"
|
|
|
|
OnVideoNote = "\avideo_note"
|
|
|
|
OnContact = "\acontact"
|
|
|
|
OnLocation = "\alocation"
|
|
|
|
OnVenue = "\avenue"
|
2017-11-26 01:26:07 +00:00
|
|
|
OnEdited = "\aedited"
|
|
|
|
OnPinned = "\apinned"
|
2017-11-21 02:22:45 +00:00
|
|
|
OnChannelPost = "\achan_post"
|
2017-11-24 15:24:07 +00:00
|
|
|
OnEditedChannelPost = "\achan_edited_post"
|
2017-11-23 02:13:15 +00:00
|
|
|
|
2017-11-26 01:26:07 +00:00
|
|
|
// Will fire when bot is added to a group.
|
|
|
|
OnAddedToGroup = "\aadded_to_group"
|
|
|
|
// Group events:
|
|
|
|
OnUserJoined = "\auser_joined"
|
|
|
|
OnUserLeft = "\auser_left"
|
|
|
|
OnNewGroupTitle = "\anew_chat_title"
|
|
|
|
OnNewGroupPhoto = "\anew_chat_photo"
|
|
|
|
OnGroupPhotoDeleted = "\achat_photo_del"
|
|
|
|
|
|
|
|
// Migration happens when group switches to
|
|
|
|
// a super group. You might want to update
|
|
|
|
// your internal references to this chat
|
|
|
|
// upon switching as its ID will change.
|
|
|
|
//
|
|
|
|
// Handler: func(from, to int64)
|
|
|
|
OnMigration = "\amigration"
|
|
|
|
|
2017-11-23 02:13:15 +00:00
|
|
|
// Will fire on callback requests.
|
|
|
|
//
|
|
|
|
// Handler: func(*Callback)
|
|
|
|
OnCallback = "\acallback"
|
|
|
|
|
|
|
|
// Will fire on incoming inline queries.
|
|
|
|
//
|
|
|
|
// Handler: func(*Query)
|
|
|
|
OnQuery = "\aquery"
|
2017-12-26 01:07:36 +00:00
|
|
|
|
|
|
|
// Will fire on chosen inline results.
|
|
|
|
//
|
|
|
|
// Handler: func(*ChosenInlineResult)
|
|
|
|
OnChosenInlineResult = "\achosen_inline_result"
|
2017-11-21 01:50:44 +00:00
|
|
|
)
|
|
|
|
|
2016-11-10 20:04:50 +00:00
|
|
|
// 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"
|
2017-11-18 10:19:58 +00:00
|
|
|
UploadingVNote ChatAction = "upload_video_note"
|
2016-11-10 20:04:50 +00:00
|
|
|
RecordingVideo ChatAction = "record_video"
|
|
|
|
RecordingAudio ChatAction = "record_audio"
|
|
|
|
FindingLocation ChatAction = "find_location"
|
|
|
|
)
|
|
|
|
|
|
|
|
// ParseMode determines the way client applications treat the text of the message
|
|
|
|
type ParseMode string
|
|
|
|
|
|
|
|
const (
|
|
|
|
ModeDefault ParseMode = ""
|
|
|
|
ModeMarkdown ParseMode = "Markdown"
|
|
|
|
ModeHTML ParseMode = "HTML"
|
|
|
|
)
|
|
|
|
|
|
|
|
// EntityType is a MessageEntity type.
|
|
|
|
type EntityType string
|
|
|
|
|
|
|
|
const (
|
|
|
|
EntityMention EntityType = "mention"
|
|
|
|
EntityTMention EntityType = "text_mention"
|
|
|
|
EntityHashtag EntityType = "hashtag"
|
|
|
|
EntityCommand EntityType = "bot_command"
|
|
|
|
EntityURL EntityType = "url"
|
|
|
|
EntityEmail EntityType = "email"
|
|
|
|
EntityBold EntityType = "bold"
|
|
|
|
EntityItalic EntityType = "italic"
|
|
|
|
EntityCode EntityType = "code"
|
|
|
|
EntityCodeBlock EntityType = "pre"
|
|
|
|
EntityTextLink EntityType = "text_link"
|
|
|
|
)
|
|
|
|
|
|
|
|
// ChatType represents one of the possible chat types.
|
|
|
|
type ChatType string
|
|
|
|
|
2015-07-06 16:13:08 +00:00
|
|
|
const (
|
2017-12-30 12:08:44 +00:00
|
|
|
ChatPrivate ChatType = "private"
|
|
|
|
ChatGroup ChatType = "group"
|
|
|
|
ChatSuperGroup ChatType = "supergroup"
|
|
|
|
ChatChannel ChatType = "channel"
|
|
|
|
ChatChannelPrivate ChatType = "privatechannel"
|
2015-07-06 16:13:08 +00:00
|
|
|
)
|
2017-11-18 10:19:58 +00:00
|
|
|
|
|
|
|
// MemberStatus is one's chat status
|
|
|
|
type MemberStatus string
|
|
|
|
|
|
|
|
const (
|
|
|
|
Creator MemberStatus = "creator"
|
|
|
|
Administrator MemberStatus = "administrator"
|
|
|
|
Member MemberStatus = "member"
|
|
|
|
Restricted MemberStatus = "restricted"
|
|
|
|
Left MemberStatus = "left"
|
|
|
|
Kicked MemberStatus = "kicked"
|
|
|
|
)
|
2017-11-18 14:41:23 +00:00
|
|
|
|
|
|
|
// MaskFeature defines sticker mask position.
|
|
|
|
type MaskFeature string
|
|
|
|
|
|
|
|
const (
|
|
|
|
FeatureForehead MaskFeature = "forehead"
|
|
|
|
FeatureEyes MaskFeature = "eyes"
|
|
|
|
FeatureMouth MaskFeature = "mouth"
|
|
|
|
FeatureChin MaskFeature = "chin"
|
|
|
|
)
|