2015-06-25 19:43:19 +00:00
|
|
|
// Package telebot provides a handy wrapper for interactions
|
|
|
|
// with Telegram bots.
|
2015-06-27 15:44:12 +00:00
|
|
|
//
|
|
|
|
// Here is an example of helloworld bot implementation:
|
|
|
|
//
|
|
|
|
// import (
|
|
|
|
// "time"
|
|
|
|
// "github.com/tucnak/telebot"
|
|
|
|
// )
|
|
|
|
//
|
|
|
|
// func main() {
|
2015-07-03 18:54:40 +00:00
|
|
|
// bot, err := telebot.NewBot("SECRET_TOKEN")
|
2015-06-27 15:44:12 +00:00
|
|
|
// if err != nil {
|
|
|
|
// return
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// messages := make(chan telebot.Message)
|
|
|
|
// bot.Listen(messages, 1*time.Second)
|
|
|
|
//
|
|
|
|
// for message := range messages {
|
|
|
|
// if message.Text == "/hi" {
|
|
|
|
// bot.SendMessage(message.Chat,
|
2015-07-06 13:46:19 +00:00
|
|
|
// "Hello, "+message.Sender.FirstName+"!", nil)
|
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-21 02:22:45 +00:00
|
|
|
OnMessage = "\amessage"
|
|
|
|
OnEditedMessage = "\aedited_msg"
|
|
|
|
OnQuery = "\aquery"
|
|
|
|
OnCallback = "\acallback"
|
|
|
|
OnChannelPost = "\achan_post"
|
|
|
|
OnEditedChannelPost = "\achan_post"
|
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"
|
2017-11-18 10:19:58 +00:00
|
|
|
RecordingVNote ChatAction = "record_video_note"
|
2016-11-10 20:04:50 +00:00
|
|
|
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 (
|
2016-11-10 20:04:50 +00:00
|
|
|
ChatPrivate ChatType = "private"
|
|
|
|
ChatGroup ChatType = "group"
|
|
|
|
ChatSuperGroup ChatType = "supergroup"
|
|
|
|
ChatChannel ChatType = "channel"
|
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"
|
|
|
|
)
|