Documentation ΒΆ
Index ΒΆ
- Constants
- Variables
- func GetLocalFilePath(c *Context, fileID string) (string, error)
- func GetRemoteFilePath(c *Context, fileID string) (string, error)
- func GetShortVersion() string
- func GetVersion() string
- func Logger() *log.Logger
- func ObjectIdHex(s string) bson.ObjectId
- func Register(servicer Servicer, botToken string)
- func ReverseProxy(target *url.URL) gin.HandlerFunc
- func Run()
- func SeviceWorkerAutorespawnGoroutine(s *Service)
- func SliceContainsString(s []string, e string) bool
- func URLMustParse(s string) *url.URL
- type Bot
- type BotConfig
- type Button
- type Buttons
- type Chat
- func (chat *Chat) Cache(key string, res interface{}) (exists bool)
- func (c *Chat) IsGroup() bool
- func (c *Chat) IsPrivate() bool
- func (chat *Chat) SaveSetting(key string, value interface{}) error
- func (chat *Chat) SaveSettings(allSettings interface{}) error
- func (chat *Chat) ServiceHookToken() string
- func (chat *Chat) ServiceHookURL() string
- func (chat *Chat) SetCache(key string, val interface{}, ttl time.Duration) error
- func (chat *Chat) Setting(key string) (result interface{}, exists bool)
- func (chat *Chat) Settings(out interface{}) error
- func (chat *Chat) UpdateCache(key string, update interface{}, res interface{}) error
- type ChatConfig
- type ChatConfigWithUser
- type Context
- func (c *Context) AnswerCallbackQuery(text string, showAlert bool) error
- func (c *Context) AnswerCallbackQueryWithURL(url string) error
- func (c *Context) AnswerInlineQueryWithPM(text string, parameter string) error
- func (c *Context) AnswerInlineQueryWithResults(res []interface{}, cacheTime int, isPersonal bool, nextOffset string) error
- func (c *Context) AnswerInlineQueryWithResultsAndPM(res []interface{}, cacheTime int, isPersonal bool, nextOffset string, ...) error
- func (c *Context) Bot() *Bot
- func (c *Context) Db() *mgo.Database
- func (c *Context) DeleteMessage(om *OutgoingMessage) error
- func (c *Context) DeleteMessagesWithEventID(eventID string) (deleted int, err error)
- func (c *Context) DownloadURL(url string) (filePath string, err error)
- func (c *Context) EditInlineButton(om *OutgoingMessage, kbState string, buttonData string, newButtonText string) error
- func (c *Context) EditInlineKeyboard(om *OutgoingMessage, fromState string, kb InlineKeyboard) error
- func (c *Context) EditInlineStateButton(om *OutgoingMessage, kbState string, oldButtonState int, buttonData string, ...) error
- func (c *Context) EditMessageText(om *OutgoingMessage, text string) error
- func (c *Context) EditMessageTextAndInlineKeyboard(om *OutgoingMessage, fromState string, text string, kb InlineKeyboard) error
- func (c *Context) EditMessageTextWithMessageID(msgID bson.ObjectId, text string) (edited int, err error)
- func (c *Context) EditMessagesTextWithEventID(eventID string, text string) (edited int, err error)
- func (c *Context) EditMessagesWithEventID(eventID string, fromState string, text string, kb InlineKeyboard) (edited int, err error)
- func (c *Context) EditPressedInlineButton(newState int, newText string) error
- func (c *Context) EditPressedInlineKeyboard(kb InlineKeyboard) error
- func (c *Context) EditPressedMessageText(text string) error
- func (c *Context) EditPressedMessageTextAndInlineKeyboard(text string, kb InlineKeyboard) error
- func (c *Context) FindChat(query interface{}) (chatData, error)
- func (c *Context) FindChats(query interface{}) ([]chatData, error)
- func (c *Context) FindMessageByEventID(id string) (*Message, error)
- func (c *Context) FindUser(query interface{}) (userData, error)
- func (c *Context) FindUsers(query interface{}) ([]userData, error)
- func (c *Context) KeyboardAnswer() (data string, buttonText string)
- func (c *Context) Log() *log.Entry
- func (c *Context) NewMessage() *OutgoingMessage
- func (c *Context) OAuthProvider() *OAuthProvider
- func (c *Context) SaveOAuthProvider(baseURL url.URL, id string, secret string) (*OAuthProvider, error)
- func (c *Context) SendAction(s string) error
- func (c *Context) Service() *Service
- func (c *Context) ServiceCache(key string, res interface{}) (exists bool)
- func (c *Context) SetDb(database *mgo.Database)
- func (c *Context) SetServiceBaseURL(domainOrURL string)
- func (c *Context) SetServiceCache(key string, val interface{}, ttl time.Duration) error
- func (c *Context) StatInc(key StatKey) error
- func (c *Context) StatIncBy(key StatKey, uniqueID int64, inc int) error
- func (c *Context) StatIncChat(key StatKey) error
- func (c *Context) StatIncUser(key StatKey) error
- func (c *Context) UpdateServiceCache(key string, update interface{}, res interface{}) error
- func (c *Context) WebPreview(title string, headline string, text string, serviceURL string, imageURL string) (WebPreviewURL string)
- type DefaultOAuth1
- type DefaultOAuth2
- type FileInfo
- type FileType
- type HTMLRichText
- func (hrt HTMLRichText) Bold(text string) string
- func (hrt HTMLRichText) EncodeEntities(s string) string
- func (hrt HTMLRichText) Fixed(s string) string
- func (hrt HTMLRichText) Italic(text string) string
- func (hrt HTMLRichText) Pre(s string) string
- func (hrt HTMLRichText) URL(text string, url string) string
- type IncomingMessage
- func (m *IncomingMessage) GetCommand() (string, string)
- func (m *IncomingMessage) GetFile(c *Context, allowedTypes []FileType, maxSize int) (localPath string, fileInfo FileInfo, err error)
- func (m *IncomingMessage) GetFileInfo(c *Context, allowedTypes []FileType) (info FileInfo, err error)
- func (m *IncomingMessage) IsEventBotAddedToGroup() bool
- func (m *IncomingMessage) SetCallbackAction(handlerFunc interface{}, args ...interface{}) *IncomingMessage
- func (m *IncomingMessage) SetEditAction(handlerFunc interface{}, args ...interface{}) *IncomingMessage
- func (m *IncomingMessage) SetReplyAction(handlerFunc interface{}, args ...interface{}) *IncomingMessage
- type InlineButton
- type InlineButtons
- func (buttons *InlineButtons) AddURL(url string, text string)
- func (buttons *InlineButtons) Append(data string, text string)
- func (buttons *InlineButtons) AppendWithState(state int, data string, text string)
- func (buttons InlineButtons) Keyboard() InlineKeyboard
- func (buttons *InlineButtons) Markup(columns int, state string) InlineKeyboard
- func (buttons *InlineButtons) Prepend(data string, text string)
- func (buttons *InlineButtons) PrependWithState(state int, data string, text string)
- type InlineKeyboard
- func (keyboard *InlineKeyboard) AddPMSwitchButton(b *Bot, text string, param string)
- func (keyboard *InlineKeyboard) AppendRows(buttons ...InlineButtons)
- func (keyboard *InlineKeyboard) EditText(buttonData string, newText string)
- func (keyboard *InlineKeyboard) Find(buttonData string) (i, j int, but *InlineButton)
- func (keyboard InlineKeyboard) Keyboard() InlineKeyboard
- func (keyboard *InlineKeyboard) PrependRows(buttons ...InlineButtons)
- type InlineKeyboardMarkup
- type Job
- type Keyboard
- type KeyboardMarkup
- type Location
- type MarkdownRichText
- func (mrt MarkdownRichText) Bold(text string) string
- func (mrt MarkdownRichText) Esc(s string) string
- func (mrt MarkdownRichText) Fixed(text string) string
- func (mrt MarkdownRichText) Italic(text string) string
- func (mrt MarkdownRichText) Pre(text string) string
- func (mrt MarkdownRichText) URL(text string, url string) string
- type Message
- func (m *Message) GetTextHash() string
- func (m *Message) SetCallbackAction(handlerFunc interface{}, args ...interface{}) *Message
- func (m *Message) SetEditAction(handlerFunc interface{}, args ...interface{}) *Message
- func (m *Message) SetReplyAction(handlerFunc interface{}, args ...interface{}) *Message
- func (m *Message) Update(db *mgo.Database) error
- func (m *Message) UpdateEventsID(db *mgo.Database, eventID ...string) error
- type MgoChange
- type Mode
- type Module
- type OAuthProvider
- type OutgoingMessage
- func (m *OutgoingMessage) AddEventID(id ...string) *OutgoingMessage
- func (m *OutgoingMessage) DisableWebPreview() *OutgoingMessage
- func (m *OutgoingMessage) EnableAntiFlood() *OutgoingMessage
- func (m *OutgoingMessage) EnableFileRemoveAfter() *OutgoingMessage
- func (m *OutgoingMessage) EnableForceReply() *OutgoingMessage
- func (m *OutgoingMessage) EnableHTML() *OutgoingMessage
- func (m *OutgoingMessage) EnableMarkdown() *OutgoingMessage
- func (m *OutgoingMessage) HideKeyboard() *OutgoingMessage
- func (m *OutgoingMessage) Send() error
- func (m *OutgoingMessage) SetBackupChat(id int64) *OutgoingMessage
- func (m *OutgoingMessage) SetCallbackAction(handlerFunc interface{}, args ...interface{}) *OutgoingMessage
- func (m *OutgoingMessage) SetChat(id int64) *OutgoingMessage
- func (m *OutgoingMessage) SetDocument(localPath string, fileName string) *OutgoingMessage
- func (m *OutgoingMessage) SetImage(localPath string, fileName string) *OutgoingMessage
- func (m *OutgoingMessage) SetInlineKeyboard(k InlineKeyboardMarkup) *OutgoingMessage
- func (m *OutgoingMessage) SetKeyboard(k KeyboardMarkup, selective bool) *OutgoingMessage
- func (m *OutgoingMessage) SetLocation(latitude, longitude float64) *OutgoingMessage
- func (m *OutgoingMessage) SetOneTimeKeyboard(b bool) *OutgoingMessage
- func (m *OutgoingMessage) SetParseMode(s string) *OutgoingMessage
- func (m *OutgoingMessage) SetReplyAction(handlerFunc interface{}, args ...interface{}) *OutgoingMessage
- func (m *OutgoingMessage) SetReplyToMsgID(id int) *OutgoingMessage
- func (m *OutgoingMessage) SetResizeKeyboard(b bool) *OutgoingMessage
- func (m *OutgoingMessage) SetSelective(b bool) *OutgoingMessage
- func (m *OutgoingMessage) SetSendAfter(after time.Time) *OutgoingMessage
- func (m *OutgoingMessage) SetSilent(b bool) *OutgoingMessage
- func (m *OutgoingMessage) SetText(text string) *OutgoingMessage
- func (m *OutgoingMessage) SetTextFmt(text string, a ...interface{}) *OutgoingMessage
- type Service
- func (s *Service) Bot() *Bot
- func (s *Service) DefaultOAuthProvider() *OAuthProvider
- func (s *Service) DoJob(handlerFunc interface{}, data ...interface{}) (*jobs.Job, error)
- func (s *Service) EmptyContext() *Context
- func (s *Service) Log() *log.Entry
- func (s *Service) SheduleJob(handlerFunc interface{}, priority int, time time.Time, data ...interface{}) (*jobs.Job, error)
- func (s *Service) TriggerEventHandler(queryChat bool, bsonQuery map[string]interface{}, data interface{}) error
- type Servicer
- type StatKey
- type User
- func (user *User) AddChatToHook(chatID int64) error
- func (user *User) AuthTempToken() string
- func (user *User) Cache(key string, res interface{}) (exists bool)
- func (user *User) Chat() Chat
- func (user *User) IsPrivateStarted() bool
- func (u *User) Mention() string
- func (user *User) OAuthHTTPClient() *http.Client
- func (user *User) OAuthToken() string
- func (user *User) OAuthValid() bool
- func (user *User) OauthInitURL() string
- func (user *User) OauthRedirectURL() string
- func (user *User) ResetOAuthToken() error
- func (user *User) SaveSetting(key string, value interface{}) error
- func (user *User) SaveSettings(allSettings interface{}) error
- func (user *User) ServiceHookToken() string
- func (user *User) ServiceHookURL() string
- func (user *User) SetAfterAuthAction(handlerFunc interface{}, args ...interface{}) error
- func (user *User) SetCache(key string, val interface{}, ttl time.Duration) error
- func (user *User) Setting(key string) (result interface{}, exists bool)
- func (user *User) Settings(out interface{}) error
- func (u *User) String() string
- func (u *User) TzLocation() *time.Location
- func (user *User) UpdateCache(key string, update interface{}, res interface{}) error
- type WebhookContext
- func (wc *WebhookContext) File(path string)
- func (wc *WebhookContext) FirstParse() bool
- func (wc *WebhookContext) Form() uurl.Values
- func (wc *WebhookContext) FormValue(key string) string
- func (wc *WebhookContext) Get(key string) (interface{}, bool)
- func (wc *WebhookContext) Header(key string) string
- func (wc *WebhookContext) Headers() map[string][]string
- func (wc *WebhookContext) HookID() string
- func (wc *WebhookContext) JSON(out interface{}) error
- func (wc *WebhookContext) Param(s string) string
- func (wc *WebhookContext) QueryValue(key string) string
- func (wc *WebhookContext) RAW() (*[]byte, error)
- func (wc *WebhookContext) Redirect(code int, s string)
- func (wc *WebhookContext) Request() *http.Request
- func (wc *WebhookContext) RequestID() string
- func (wc *WebhookContext) Response(code int, s string)
- func (wc *WebhookContext) Store(key string, b interface{})
- func (wc *WebhookContext) Writer() http.ResponseWriter
Constants ΒΆ
const ( // JobRetryLinear specify jobs retry politic as retry after fail JobRetryLinear = iota // JobRetryFibonacci specify jobs retry politic as delay after fail using fibonacci sequence JobRetryFibonacci )
Variables ΒΆ
var Config config
var ErrorFlood = fmt.Errorf("Too many messages. You could not send the same message more than once per %d sec. The number of messages sent to chat must not exceed %d in %d sec", antiFloodTimeout, antiFloodChatLimit, antiFloodChatDuration)
var GetFileMaxSizeExceedError = errors.New("Maximum allowed file size exceed")
var MaxMsgsToUpdateWithEventID = 10
MaxMsgsToUpdateWithEventID set the maximum number of last messages to update with EditMessagesTextWithEventID
Functions ΒΆ
func GetShortVersion ΒΆ
func GetShortVersion() string
GetVersion returns the current HEAD git commit(first 7 symbols) if .git exists
func GetVersion ΒΆ
func GetVersion() string
GetVersion returns the current HEAD git commit if .git exists
func ObjectIdHex ΒΆ
func ReverseProxy ΒΆ
func ReverseProxy(target *url.URL) gin.HandlerFunc
func Run ΒΆ
func Run()
Run initiates Integram to listen webhooks, TG updates and start the workers pool
func SeviceWorkerAutorespawnGoroutine ΒΆ
func SeviceWorkerAutorespawnGoroutine(s *Service)
func SliceContainsString ΒΆ
SliceContainsString returns true if []string contains string
func URLMustParse ΒΆ
URLMustParse returns url.URL from static string. Don't use it with a dynamic param
Types ΒΆ
type Bot ΒΆ
type Bot struct { // Bot Telegram user id ID int64 // Bot Telegram username Username string API *tg.BotAPI // contains filtered or unexported fields }
Bot represents parsed auth data & API reference
type Button ΒΆ
type Button struct { Data string // data is stored in the DB. May be collisions if button text is not unique per keyboard Text string // should be unique per keyboard }
Button contains the data to create Keyboard
type Buttons ΒΆ
type Buttons []Button
Buttons is a Shorthand for []Button
func (*Buttons) InlineButtons ΒΆ
func (buttons *Buttons) InlineButtons() InlineButtons
InlineButtons converts Buttons to InlineButtons useful with universal methods that create keyboard (f.e. settigns) for both usual and inline keyboard
type Chat ΒΆ
type Chat struct { ID int64 `bson:"_id"` Type string `bson:",omitempty"` FirstName string LastName string `bson:",omitempty"` UserName string `bson:",omitempty"` Title string `bson:",omitempty"` Tz string `bson:",omitempty"` // contains filtered or unexported fields }
Chat information initiated from TG
func (*Chat) Cache ΒΆ
Cache returns if Chat's cache for specific key exists and try to bind it to res
func (*Chat) SaveSetting ΒΆ
SaveSetting sets Chat's setting for service with specific key
func (*Chat) SaveSettings ΒΆ
SaveSettings save Chat's setting for service
func (*Chat) ServiceHookToken ΒΆ
ServiceHookToken returns Chats's hook token to use in webhook handling
func (*Chat) ServiceHookURL ΒΆ
ServiceHookURL returns Chats's webhook URL for service to use in webhook handling Used in case when user need to put webhook URL to receive notifications to chat
func (*Chat) Setting ΒΆ
Setting returns Chat's setting for service with specific key. NOTE! Only builtin types are supported (f.e. structs will become map)
func (*Chat) UpdateCache ΒΆ
UpdateCache updates the per Chat cache using MongoDB Update query (see trello service as example)
type ChatConfig ΒΆ
type ChatConfig struct {
tg.ChatConfig
}
type ChatConfigWithUser ΒΆ
type ChatConfigWithUser struct {
tg.ChatConfigWithUser
}
type Context ΒΆ
type Context struct { ServiceName string // Actual service's name. Use context's Service() method to receive full service config ServiceBaseURL url.URL // Useful for self-hosted services. Default set to service's DefaultHost User User // User associated with current webhook or Telegram update. Chat Chat // Chat associated with current webhook or Telegram update Message *IncomingMessage // Telegram incoming message if it triggired current request MessageEdited bool // True if Message is edited message instead of the new one InlineQuery *tg.InlineQuery // Telegram inline query if it triggired current request ChosenInlineResult *chosenInlineResult // Telegram chosen inline result if it triggired current request Callback *callback // Telegram inline buttons callback if it it triggired current request // contains filtered or unexported fields }
Context of the current request
func (*Context) AnswerCallbackQuery ΒΆ
AnswerCallbackQuery answer the inline keyboard callback query that triggered this request with toast or alert
func (*Context) AnswerCallbackQueryWithURL ΒΆ
func (*Context) AnswerInlineQueryWithPM ΒΆ
AnswerInlineQueryWithPM answer the inline query that triggered this request with Private Message redirect tip
func (*Context) AnswerInlineQueryWithResults ΒΆ
func (c *Context) AnswerInlineQueryWithResults(res []interface{}, cacheTime int, isPersonal bool, nextOffset string) error
AnswerInlineQueryWithResults answer the inline query that triggered this request
func (*Context) AnswerInlineQueryWithResultsAndPM ΒΆ
func (c *Context) AnswerInlineQueryWithResultsAndPM(res []interface{}, cacheTime int, isPersonal bool, nextOffset string, PMText string, PMParameter string) error
AnswerInlineQueryWithResults answer the inline query that triggered this request
func (*Context) Db ΒΆ
func (c *Context) Db() *mgo.Database
Db returns the MongoDB *mgo.Database instance
func (*Context) DeleteMessage ΒΆ
func (c *Context) DeleteMessage(om *OutgoingMessage) error
DeleteMessage deletes the outgoing message's text and inline keyboard
func (*Context) DeleteMessagesWithEventID ΒΆ
DeleteMessagesWithEventID deletes the last MaxMsgsToUpdateWithEventID messages' text and inline keyboard with the corresponding eventID in ALL chats
func (*Context) DownloadURL ΒΆ
DownloadURL downloads the remote URL and returns the local file path
func (*Context) EditInlineButton ΒΆ
func (c *Context) EditInlineButton(om *OutgoingMessage, kbState string, buttonData string, newButtonText string) error
EditInlineButton edit the outgoing message's inline button
func (*Context) EditInlineKeyboard ΒΆ
func (c *Context) EditInlineKeyboard(om *OutgoingMessage, fromState string, kb InlineKeyboard) error
EditInlineKeyboard edit the outgoing message's inline keyboard
func (*Context) EditInlineStateButton ΒΆ
func (c *Context) EditInlineStateButton(om *OutgoingMessage, kbState string, oldButtonState int, buttonData string, newButtonState int, newButtonText string) error
EditInlineStateButton edit the outgoing message's inline button with a state
func (*Context) EditMessageText ΒΆ
func (c *Context) EditMessageText(om *OutgoingMessage, text string) error
EditMessageText edit the text of message previously sent by the bot
func (*Context) EditMessageTextAndInlineKeyboard ΒΆ
func (c *Context) EditMessageTextAndInlineKeyboard(om *OutgoingMessage, fromState string, text string, kb InlineKeyboard) error
EditMessageTextAndInlineKeyboard edit the outgoing message's text and inline keyboard
func (*Context) EditMessageTextWithMessageID ΒΆ
func (c *Context) EditMessageTextWithMessageID(msgID bson.ObjectId, text string) (edited int, err error)
EditMessagesTextWithMessageID edit the one message text with by message BSON ID
func (*Context) EditMessagesTextWithEventID ΒΆ
EditMessagesTextWithEventID edit the last MaxMsgsToUpdateWithEventID messages' text with the corresponding eventID in ALL chats
func (*Context) EditMessagesWithEventID ΒΆ
func (c *Context) EditMessagesWithEventID(eventID string, fromState string, text string, kb InlineKeyboard) (edited int, err error)
EditMessagesWithEventID edit the last MaxMsgsToUpdateWithEventID messages' text and inline keyboard with the corresponding eventID in ALL chats
func (*Context) EditPressedInlineButton ΒΆ
EditPressedInlineButton edit the text and state of pressed inline button in case this request is triggered by inlineButton callback
func (*Context) EditPressedInlineKeyboard ΒΆ
func (c *Context) EditPressedInlineKeyboard(kb InlineKeyboard) error
EditPressedInlineKeyboard edit the inline keyboard in the msg where user taped it in case this request is triggered by inlineButton callback
func (*Context) EditPressedMessageText ΒΆ
EditPressedMessageText edit the text in the msg where user taped it in case this request is triggered by inlineButton callback
func (*Context) EditPressedMessageTextAndInlineKeyboard ΒΆ
func (c *Context) EditPressedMessageTextAndInlineKeyboard(text string, kb InlineKeyboard) error
EditPressedMessageTextAndInlineKeyboard edit the text and inline keyboard in the msg where user taped it in case this request is triggered by inlineButton callback
func (*Context) FindMessageByEventID ΒΆ
FindMessageByEventID find message by event id
func (*Context) KeyboardAnswer ΒΆ
KeyboardAnswer retrieve the data related to pressed button buttonText will be returned only in case this button relates to the one in db for this chat
func (*Context) NewMessage ΒΆ
func (c *Context) NewMessage() *OutgoingMessage
NewMessage creates the message targeted to the current chat
func (*Context) OAuthProvider ΒΆ
func (c *Context) OAuthProvider() *OAuthProvider
OAuthProvider details. Useful for services that can be installed on your own side
func (*Context) SaveOAuthProvider ΒΆ
func (c *Context) SaveOAuthProvider(baseURL url.URL, id string, secret string) (*OAuthProvider, error)
SaveOAuthProvider add the OAuth client to DB. Useful when the new OAuth provider registred for self-hosted services
func (*Context) SendAction ΒΆ
SendAction send the one of "typing", "upload_photo", "record_video", "upload_video", "record_audio", "upload_audio", "upload_document", "find_location"
func (*Context) ServiceCache ΒΆ
ServiceCache returns if Services's cache for specific key exists and try to bind it to res
func (*Context) SetServiceBaseURL ΒΆ
SetServiceBaseURL set the baseURL for the current request. Useful when service can be self-hosted. The actual service URL can be found in the incoming webhook
func (*Context) SetServiceCache ΒΆ
SetServiceCache set the Services's cache with specific key and TTL
func (*Context) StatIncChat ΒΆ
func (*Context) StatIncUser ΒΆ
func (*Context) UpdateServiceCache ΒΆ
UpdateServiceCache updates the Services's cache using MongoDB Update query (see trello service as example)
type DefaultOAuth1 ΒΆ
type DefaultOAuth1 struct { Key string Secret string RequestTokenURL string AuthorizeTokenURL string AccessTokenURL string AdditionalAuthorizationURLParams map[string]string HTTPMethod string AccessTokenReceiver func(serviceContext *Context, r *http.Request, requestToken *oauth.RequestToken) (token string, err error) }
DefaultOAuth1 is the default OAuth1 config for the service
type DefaultOAuth2 ΒΆ
type DefaultOAuth2 struct { oauth2.Config AccessTokenReceiver func(serviceContext *Context, r *http.Request) (token string, expiresAt *time.Time, refreshToken string, err error) }
DefaultOAuth2 is the default OAuth2 config for the service
type HTMLRichText ΒΆ
type HTMLRichText struct{}
HTMLRichText produce HTML that can be sent to Telegram
func (HTMLRichText) Bold ΒΆ
func (hrt HTMLRichText) Bold(text string) string
Bold generates <b>text</b>
func (HTMLRichText) EncodeEntities ΒΆ
func (hrt HTMLRichText) EncodeEntities(s string) string
EncodeEntities encodes '<', '>'
func (HTMLRichText) Fixed ΒΆ
func (hrt HTMLRichText) Fixed(s string) string
Fixed generates <code>text</code>
func (HTMLRichText) Italic ΒΆ
func (hrt HTMLRichText) Italic(text string) string
Italic generates <i>text</I>
func (HTMLRichText) Pre ΒΆ
func (hrt HTMLRichText) Pre(s string) string
Pre generates <pre>text</pre>
type IncomingMessage ΒΆ
type IncomingMessage struct { Message `bson:",inline"` From User Chat Chat ForwardFrom *User ForwardDate time.Time ForwardFromMessageID int64 ReplyToMessage *Message `bson:"-"` ForwardFromChat *Chat `json:"forward_from_chat"` // optional EditDate int `json:"edit_date"` // optional Entities *[]tg.MessageEntity `json:"entities"` // optional Audio *tg.Audio `json:"audio"` // optional Document *tg.Document `json:"document"` // optional Photo *[]tg.PhotoSize `json:"photo"` // optional Sticker *tg.Sticker `json:"sticker"` // optional Video *tg.Video `json:"video"` // optional Voice *tg.Voice `json:"voice"` // optional Caption string `json:"caption"` // optional Contact *tg.Contact `json:"contact"` // optional Location *tg.Location `json:"location"` // optional Venue *tg.Venue `json:"venue"` // optional NewChatMembers []*User `json:"new_chat_members"` // optional LeftChatMember *User `json:"left_chat_member"` // optional NewChatTitle string `json:"new_chat_title"` // optional NewChatPhoto *[]tg.PhotoSize `json:"new_chat_photo"` // optional DeleteChatPhoto bool `json:"delete_chat_photo"` // optional GroupChatCreated bool `json:"group_chat_created"` // optional SuperGroupChatCreated bool `json:"supergroup_chat_created"` // optional ChannelChatCreated bool `json:"channel_chat_created"` // optional MigrateToChatID int64 `json:"migrate_to_chat_id"` // optional MigrateFromChatID int64 `json:"migrate_from_chat_id"` // optional PinnedMessage *Message `json:"pinned_message"` // optional // contains filtered or unexported fields }
IncomingMessage specifies data that available for incoming message
func (*IncomingMessage) GetCommand ΒΆ
func (m *IncomingMessage) GetCommand() (string, string)
GetCommand parses received message text for bot command. Returns the command and after command text if presented
func (*IncomingMessage) GetFileInfo ΒΆ
func (m *IncomingMessage) GetFileInfo(c *Context, allowedTypes []FileType) (info FileInfo, err error)
func (*IncomingMessage) IsEventBotAddedToGroup ΒΆ
func (m *IncomingMessage) IsEventBotAddedToGroup() bool
IsEventBotAddedToGroup returns true if user created a new group with bot as member or add the bot to existing group
func (*IncomingMessage) SetCallbackAction ΒΆ
func (m *IncomingMessage) SetCallbackAction(handlerFunc interface{}, args ...interface{}) *IncomingMessage
SetCallbackAction sets the callback func that will be called when user press inline button with Data field !!! Please note that you must omit first arg *integram.Context, because it will be automatically prepended as message reply received and will contain actual context
func (*IncomingMessage) SetEditAction ΒΆ
func (m *IncomingMessage) SetEditAction(handlerFunc interface{}, args ...interface{}) *IncomingMessage
SetEditAction sets the edited func that will be called when user edit the message !!! Please note that you must omit first arg *integram.Context, because it will be automatically prepended as message reply received and will contain actual context
func (*IncomingMessage) SetReplyAction ΒΆ
func (m *IncomingMessage) SetReplyAction(handlerFunc interface{}, args ...interface{}) *IncomingMessage
SetReplyAction sets the reply func that will be called when user reply the message !!! Please note that you must omit first arg *integram.Context, because it will be automatically prepended as message reply received and will contain actual context
type InlineButton ΒΆ
type InlineButton struct { Text string State int URL string `bson:",omitempty"` Data string `bson:",omitempty"` // maximum 64 bytes SwitchInlineQuery string `bson:",omitempty"` // SwitchInlineQueryCurrentChat string `bson:",omitempty"` OutOfPagination bool `bson:",omitempty" json:"-"` // Only for the single button in first or last row. Use together with InlineKeyboard.MaxRows β for buttons outside of pagination list }
InlineButton contains the data to create InlineKeyboard One of URL, Data, SwitchInlineQuery must be specified If more than one specified the first in order of (URL, Data, SwitchInlineQuery) will be used
func (InlineButton) Keyboard ΒΆ
func (button InlineButton) Keyboard() InlineKeyboard
Keyboard generates inline keyboard with 1 button
type InlineButtons ΒΆ
type InlineButtons []InlineButton
InlineButtons is a Shorthand for []InlineButton
func (*InlineButtons) AddURL ΒΆ
func (buttons *InlineButtons) AddURL(url string, text string)
AddURL adds InlineButton with URL to the end of InlineButtons(row)
func (*InlineButtons) Append ΒΆ
func (buttons *InlineButtons) Append(data string, text string)
Append adds 1 or more InlineButton (column) to the end of InlineButtons(row)
func (*InlineButtons) AppendWithState ΒΆ
func (buttons *InlineButtons) AppendWithState(state int, data string, text string)
AppendWithState add the InlineButton with state to the end of InlineButtons(row) Useful for checkbox or to revert the action
func (InlineButtons) Keyboard ΒΆ
func (buttons InlineButtons) Keyboard() InlineKeyboard
Keyboard generates inline keyboard with 1 column
func (*InlineButtons) Markup ΒΆ
func (buttons *InlineButtons) Markup(columns int, state string) InlineKeyboard
Markup generate InlineKeyboard from InlineButtons ([]Button), chunking buttons by columns number, and specifying current keyboard state Keyboard state useful for nested levels to determine current position
func (*InlineButtons) Prepend ΒΆ
func (buttons *InlineButtons) Prepend(data string, text string)
Prepend adds 1 or more InlineButton (column) to the begin of InlineButtons(row)
func (*InlineButtons) PrependWithState ΒΆ
func (buttons *InlineButtons) PrependWithState(state int, data string, text string)
PrependWithState add the InlineButton with state to the begin of InlineButtons(row) Useful for checkbox or to revert the action
type InlineKeyboard ΒΆ
type InlineKeyboard struct { Buttons []InlineButtons // You must specify at least 1 InlineButton in slice FixedWidth bool `bson:",omitempty"` // will add right padding to match all buttons text width State string // determine the current keyboard's state. Useful to change the behavior for branch cases and make it little thread safe while it is using by several users MaxRows int `bson:",omitempty"` // Will automatically add next/prev buttons. Zero means no limit RowOffset int `bson:",omitempty"` // Current offset when using MaxRows }
InlineKeyboard contains the data to create the Inline keyboard for Telegram and store it in DB
func (*InlineKeyboard) AddPMSwitchButton ΒΆ
func (keyboard *InlineKeyboard) AddPMSwitchButton(b *Bot, text string, param string)
AddPMSwitchButton add the button to switch to PM as a first row in the InlineKeyboard
func (*InlineKeyboard) AppendRows ΒΆ
func (keyboard *InlineKeyboard) AppendRows(buttons ...InlineButtons)
AppendRows adds 1 or more InlineButtons (rows) to the end of InlineKeyboard
func (*InlineKeyboard) EditText ΒΆ
func (keyboard *InlineKeyboard) EditText(buttonData string, newText string)
EditText find the InlineButton in Keyboard by the Data and change the text of that button
func (*InlineKeyboard) Find ΒΆ
func (keyboard *InlineKeyboard) Find(buttonData string) (i, j int, but *InlineButton)
Find the InlineButton in Keyboard by the Data
func (InlineKeyboard) Keyboard ΒΆ
func (keyboard InlineKeyboard) Keyboard() InlineKeyboard
Keyboard generates inline keyboard from inline keyboard :-D
func (*InlineKeyboard) PrependRows ΒΆ
func (keyboard *InlineKeyboard) PrependRows(buttons ...InlineButtons)
PrependRows adds 1 or more InlineButtons (rows) to the begin of InlineKeyboard
type InlineKeyboardMarkup ΒΆ
type InlineKeyboardMarkup interface { Keyboard() InlineKeyboard // contains filtered or unexported methods }
InlineKeyboardMarkup allow to generate TG and DB data from different states - (InlineButtons, []InlineButtons and InlineKeyboard)
type Job ΒΆ
type Job struct { HandlerFunc interface{} // Must be a func. Retries uint // Number of retries before fail RetryType int // JobRetryLinear or JobRetryFibonacci }
Job 's handler that may be used when scheduling
type Keyboard ΒΆ
type Keyboard []Buttons
Keyboard is a Shorthand for [][]Button
type KeyboardMarkup ΒΆ
type KeyboardMarkup interface { Keyboard() Keyboard // contains filtered or unexported methods }
KeyboardMarkup allow to generate TG and DB data from different states - (Buttons and Keyboard)
type MarkdownRichText ΒΆ
type MarkdownRichText struct{}
MarkdownRichText produce Markdown that can be sent to Telegram. Not recommended to use because of tricky escaping Use HTMLRichText instead
func (MarkdownRichText) Bold ΒΆ
func (mrt MarkdownRichText) Bold(text string) string
Bold generates *text*
func (MarkdownRichText) Esc ΒΆ
func (mrt MarkdownRichText) Esc(s string) string
Esc escapes '[', ']', '(', ')', "`", "_", "*" with \
func (MarkdownRichText) Fixed ΒΆ
func (mrt MarkdownRichText) Fixed(text string) string
Fixed generates`text`
func (MarkdownRichText) Italic ΒΆ
func (mrt MarkdownRichText) Italic(text string) string
Italic generates _text_
func (MarkdownRichText) Pre ΒΆ
func (mrt MarkdownRichText) Pre(text string) string
Pre generates```text```
type Message ΒΆ
type Message struct { ID bson.ObjectId `bson:"_id,omitempty"` // Internal unique BSON ID EventID []string `bson:",omitempty"` MsgID int `bson:",omitempty"` // Telegram Message ID. BotID+MsgID is unique InlineMsgID string `bson:",omitempty"` // Telegram InlineMessage ID. ChatID+InlineMsgID is unique BotID int64 `bson:",minsize"` // TG bot's ID on which behalf message is sending or receiving FromID int64 `bson:",minsize"` // TG User's ID of sender. Equal to BotID in case of outgoinf message from bot ChatID int64 `bson:",omitempty,minsize"` // Telegram chat's ID, equal to FromID in case of private message BackupChatID int64 `bson:",omitempty,minsize"` // This chat will be used if chatid failed (bot not started or stopped or group deactivated) ReplyToMsgID int `bson:",omitempty"` // If this message is reply, contains Telegram's Message ID of original message Date time.Time Text string `bson:",omitempty"` Location *Location `bson:",omitempty"` AntiFlood bool `bson:",omitempty"` Deleted bool `bson:",omitempty"` // f.e. admin can delete the message in supergroup and we can't longer edit or reply on it OnCallbackAction string `bson:",omitempty"` // Func to call on inline button press OnCallbackData []byte `bson:",omitempty"` // Args to send to this func OnReplyAction string `bson:",omitempty"` // Func to call on message reply OnReplyData []byte `bson:",omitempty"` // Args to send to this func OnEditAction string `bson:",omitempty"` // Func to call on message edit OnEditData []byte `bson:",omitempty"` // Args to send to this func // contains filtered or unexported fields }
Message represent both outgoing and incoming message data
func (*Message) GetTextHash ΒΆ
GetTextHash generate MD5 hash of message's text
func (*Message) SetCallbackAction ΒΆ
SetCallbackAction sets the reply func that will be called when user reply the message !!! Please note that you must omit first arg *integram.Context, because it will be automatically prepended as message reply received and will contain actual context
func (*Message) SetEditAction ΒΆ
SetEditAction sets the edited func that will be called when user edit the message !!! Please note that you must omit first arg *integram.Context, because it will be automatically prepended as message reply received and will contain actual context
func (*Message) SetReplyAction ΒΆ
SetReplyAction sets the reply func that will be called when user reply the message !!! Please note that you must omit first arg *integram.Context, because it will be automatically prepended as message reply received and will contain actual context
type Mode ΒΆ
type Mode string
const ( InstanceModeMultiProcessMain Mode = "multi-main" // run only the main worker. It will process the outgoing messages queue, route the incoming webhooks to specific services and resolve webpreviews InstanceModeMultiProcessService Mode = "multi-service" // run only one the registred services and their workers. Main instance must be running in order to the outgoing TG messages could be sent InstanceModeSingleProcess Mode = "single" // run all-in-one process β main worker and all registred services )
type OAuthProvider ΒΆ
type OAuthProvider struct { Service string // Service name BaseURL url.URL `envconfig:"OAUTH_BASEURL"` // Scheme + Host. Default https://{service.DefaultHost} ID string `envconfig:"OAUTH_ID" required:"true"` // OAuth ID Secret string `envconfig:"OAUTH_SECRET" required:"true"` // OAuth Secret }
OAuthProvider contains OAuth application info
func (*OAuthProvider) IsSetup ΒΆ
func (o *OAuthProvider) IsSetup() bool
IsSetup returns true if OAuth provider(app,client) has ID and Secret. Should be always true for service's default provider
func (*OAuthProvider) OAuth1Client ΒΆ
func (o *OAuthProvider) OAuth1Client(c *Context) *oauth.Consumer
OAuth1Client returns oauth.Consumer using OAuthProvider details
func (*OAuthProvider) OAuth2Client ΒΆ
func (o *OAuthProvider) OAuth2Client(c *Context) *oauth2.Config
OAuth2Client returns oauth2.Config using OAuthProvider details
func (*OAuthProvider) RedirectURL ΒΆ
func (o *OAuthProvider) RedirectURL() string
RedirectURL returns impersonal Redirect URL, useful when setting up the OAuth Client
type OutgoingMessage ΒΆ
type OutgoingMessage struct { Message `bson:",inline"` TextHash string `bson:",omitempty"` KeyboardHide bool `bson:",omitempty"` ResizeKeyboard bool `bson:",omitempty"` KeyboardMarkup Keyboard `bson:"-"` InlineKeyboardMarkup InlineKeyboard `bson:",omitempty"` Keyboard bool `bson:",omitempty"` ParseMode string `bson:",omitempty"` OneTimeKeyboard bool `bson:",omitempty"` Selective bool `bson:",omitempty"` ForceReply bool `bson:",omitempty"` // in the private dialog assume user's message as the reply for the last message sent by the bot if bot's message has Reply handler and ForceReply set WebPreview bool `bson:",omitempty"` Silent bool `bson:",omitempty"` FilePath string `bson:",omitempty"` FileName string `bson:",omitempty"` FileType string `bson:",omitempty"` FileRemoveAfter bool `bson:",omitempty"` SendAfter *time.Time `bson:",omitempty"` // contains filtered or unexported fields }
OutgoingMessage specispecifiesfy data of performing or performed outgoing message
func (*OutgoingMessage) AddEventID ΒΆ
func (m *OutgoingMessage) AddEventID(id ...string) *OutgoingMessage
AddEventID attach one or more event ID. You can use eventid to edit the message in case of additional webhook received or to ignore in case of duplicate
func (*OutgoingMessage) DisableWebPreview ΒΆ
func (m *OutgoingMessage) DisableWebPreview() *OutgoingMessage
DisableWebPreview indicates TG clients to not trying to resolve the URL's in the message
func (*OutgoingMessage) EnableAntiFlood ΒΆ
func (m *OutgoingMessage) EnableAntiFlood() *OutgoingMessage
EnableAntiFlood will check if the message wasn't already sent within last antiFloodTimeout seconds
func (*OutgoingMessage) EnableFileRemoveAfter ΒΆ
func (m *OutgoingMessage) EnableFileRemoveAfter() *OutgoingMessage
EnableFileRemoveAfter adds the flag to remove the file after message will be sent
func (*OutgoingMessage) EnableForceReply ΒΆ
func (m *OutgoingMessage) EnableForceReply() *OutgoingMessage
EnableForceReply will automatically set the reply to this message and focus on the input field
func (*OutgoingMessage) EnableHTML ΒΆ
func (m *OutgoingMessage) EnableHTML() *OutgoingMessage
EnableHTML sets parseMode to HTML
func (*OutgoingMessage) EnableMarkdown ΒΆ
func (m *OutgoingMessage) EnableMarkdown() *OutgoingMessage
EnableMarkdown sets parseMode to Markdown
func (*OutgoingMessage) HideKeyboard ΒΆ
func (m *OutgoingMessage) HideKeyboard() *OutgoingMessage
HideKeyboard will hide existing keyboard in the chat where message will be sent
func (*OutgoingMessage) Send ΒΆ
func (m *OutgoingMessage) Send() error
Send put the message to the jobs queue
func (*OutgoingMessage) SetBackupChat ΒΆ
func (m *OutgoingMessage) SetBackupChat(id int64) *OutgoingMessage
SetBackupChat set backup chat id that will be used in case message failed to sent to private chat (f.e. bot stopped or not initialized)
func (*OutgoingMessage) SetCallbackAction ΒΆ
func (m *OutgoingMessage) SetCallbackAction(handlerFunc interface{}, args ...interface{}) *OutgoingMessage
SetCallbackAction sets the callback func that will be called when user press inline button with Data field
func (*OutgoingMessage) SetChat ΒΆ
func (m *OutgoingMessage) SetChat(id int64) *OutgoingMessage
SetChat sets the target chat to send the message
func (*OutgoingMessage) SetDocument ΒΆ
func (m *OutgoingMessage) SetDocument(localPath string, fileName string) *OutgoingMessage
SetDocument adds the file located at localPath with name fileName to the message
func (*OutgoingMessage) SetImage ΒΆ
func (m *OutgoingMessage) SetImage(localPath string, fileName string) *OutgoingMessage
SetImage adds the image file located at localPath with name fileName to the message
func (*OutgoingMessage) SetInlineKeyboard ΒΆ
func (m *OutgoingMessage) SetInlineKeyboard(k InlineKeyboardMarkup) *OutgoingMessage
SetInlineKeyboard sets the inline keyboard markup
func (*OutgoingMessage) SetKeyboard ΒΆ
func (m *OutgoingMessage) SetKeyboard(k KeyboardMarkup, selective bool) *OutgoingMessage
SetKeyboard sets the keyboard markup and Selective bool. If Selective is true keyboard will sent only for target users that you must @mention people in text or specify with SetReplyToMsgID
func (*OutgoingMessage) SetLocation ΒΆ
func (m *OutgoingMessage) SetLocation(latitude, longitude float64) *OutgoingMessage
SetLocation set the location
func (*OutgoingMessage) SetOneTimeKeyboard ΒΆ
func (m *OutgoingMessage) SetOneTimeKeyboard(b bool) *OutgoingMessage
SetOneTimeKeyboard sets the Onetime mode for keyboard. Keyboard will be hided after 1st use
func (*OutgoingMessage) SetParseMode ΒΆ
func (m *OutgoingMessage) SetParseMode(s string) *OutgoingMessage
SetParseMode sets parseMode: 'HTML' and 'markdown' supporting for now
func (*OutgoingMessage) SetReplyAction ΒΆ
func (m *OutgoingMessage) SetReplyAction(handlerFunc interface{}, args ...interface{}) *OutgoingMessage
SetReplyAction sets the reply func that will be called when user reply the message !!! Please note that you must omit first arg *integram.Context, because it will be automatically prepended as message reply received and will contain actual context
func (*OutgoingMessage) SetReplyToMsgID ΒΆ
func (m *OutgoingMessage) SetReplyToMsgID(id int) *OutgoingMessage
SetReplyToMsgID sets parseMode: 'HTML' and 'markdown' supporting for now
func (*OutgoingMessage) SetResizeKeyboard ΒΆ
func (m *OutgoingMessage) SetResizeKeyboard(b bool) *OutgoingMessage
SetResizeKeyboard sets the ResizeKeyboard to collapse keyboard wrapper to match the actual underneath keyboard
func (*OutgoingMessage) SetSelective ΒΆ
func (m *OutgoingMessage) SetSelective(b bool) *OutgoingMessage
SetSelective sets the Selective mode for the keyboard. If Selective is true keyboard make sure to @mention people in text or specify message to reply with SetReplyToMsgID
func (*OutgoingMessage) SetSendAfter ΒΆ
func (m *OutgoingMessage) SetSendAfter(after time.Time) *OutgoingMessage
SetSendAfter set the time to send the message
func (*OutgoingMessage) SetSilent ΒΆ
func (m *OutgoingMessage) SetSilent(b bool) *OutgoingMessage
SetSilent turns off notifications on iOS and make it silent on Android
func (*OutgoingMessage) SetText ΒΆ
func (m *OutgoingMessage) SetText(text string) *OutgoingMessage
SetText set the text of message to sent In case of documents and photo messages this text will be used in the caption
func (*OutgoingMessage) SetTextFmt ΒΆ
func (m *OutgoingMessage) SetTextFmt(text string, a ...interface{}) *OutgoingMessage
SetTextFmt is a shorthand for SetText(fmt.Sprintf("%s %s %s", a, b, c))
type Service ΒΆ
type Service struct { Name string // Service lowercase name NameToPrint string // Service print name ImageURL string // Service thumb image to use in WebPreview if there is no image specified in message. Useful for non-interactive integrations that uses main Telegram's bot. DefaultBaseURL url.URL // Cloud(not self-hosted) URL DefaultOAuth1 *DefaultOAuth1 // Cloud(not self-hosted) app data DefaultOAuth2 *DefaultOAuth2 // Cloud(not self-hosted) app data OAuthRequired bool // Is OAuth required in order to receive webhook updates JobsPool int // Worker pool to be created for service. Default to 1 worker. Workers will be inited only if jobs types are available Jobs []Job // Job types that can be scheduled Modules []Module // you can inject modules and use it across different services // Functions that can be triggered after message reply, inline button press or Auth success f.e. API query to comment the card on replying. // Please note that first argument must be an *integram.Context. Because all actions is triggered in some context. // F.e. when using action with onReply triggered with context of replied message (user, chat, bot). Actions []interface{} // Handler to produce the user/chat search query based on the http request. Set queryChat to true to perform chat search TokenHandler func(ctx *Context, request *WebhookContext) (queryChat bool, bsonQuery map[string]interface{}, err error) // Handler to receive webhooks from outside WebhookHandler func(ctx *Context, request *WebhookContext) error // Handler to receive already prepared data. Useful for manual interval grabbing jobs EventHandler func(ctx *Context, data interface{}) error // Worker wil be run in goroutine after service and framework started. In case of error or crash it will be restarted Worker func(ctx *Context) error // Handler to receive new messages from Telegram TGNewMessageHandler func(ctx *Context) error // Handler to receive new messages from Telegram TGEditMessageHandler func(ctx *Context) error // Handler to receive inline queries from Telegram TGInlineQueryHandler func(ctx *Context) error // Handler to receive chosen inline results from Telegram TGChosenInlineResultHandler func(ctx *Context) error OAuthSuccessful func(ctx *Context) error // Can be used for services with tiny load UseWebhookInsteadOfLongPolling bool // contains filtered or unexported fields }
Service configuration
func (*Service) DefaultOAuthProvider ΒΆ
func (s *Service) DefaultOAuthProvider() *OAuthProvider
DefaultOAuthProvider returns default(means cloud-based) OAuth client
func (*Service) DoJob ΒΆ
DoJob queues the job to run. The job must be registred in Service's config (Jobs field). Arguments must be identically types with hudlerFunc's input args
func (*Service) EmptyContext ΒΆ
EmptyContext returns context on behalf of service without user/chat relation
func (*Service) SheduleJob ΒΆ
func (s *Service) SheduleJob(handlerFunc interface{}, priority int, time time.Time, data ...interface{}) (*jobs.Job, error)
SheduleJob schedules the job for specific time with specific priority. The job must be registred in Service's config (Jobs field). Arguments must be identically types with hudlerFunc's input args
type Servicer ΒΆ
type Servicer interface {
Service() *Service
}
Servicer is interface to match service's config from which the service itself can be produced
type StatKey ΒΆ
type StatKey string
const ( StatInlineQueryAnswered StatKey = "iq_answered" StatInlineQueryNotAnswered StatKey = "iq_not_answered" StatInlineQueryTimeouted StatKey = "iq_timeouted" StatInlineQueryCanceled StatKey = "iq_canceled" StatInlineQueryChosen StatKey = "iq_chosen" StatInlineQueryProcessingError StatKey = "iq_error" StatWebhookHandled StatKey = "wh_handled" StatWebhookProducedMessageToChat StatKey = "wh_message" StatWebhookProcessingError StatKey = "wh_error" StatIncomingMessageAnswered StatKey = "im_replied" StatIncomingMessageNotAnswered StatKey = "im_not_replied" StatOAuthSuccess StatKey = "oauth_success" )
type User ΒΆ
type User struct { ID int64 `bson:"_id"` FirstName string LastName string `bson:",omitempty"` UserName string `bson:",omitempty"` Tz string // contains filtered or unexported fields }
User information initiated from TG
func (*User) AddChatToHook ΒΆ
AddChatToHook adds the target chat to user's existing hook
func (*User) AuthTempToken ΒΆ
AuthTempToken returns Auth token used in OAuth process to associate TG user with OAuth creditianals
func (*User) Cache ΒΆ
Cache returns if User's cache for specific key exists and try to bind it to res
func (*User) IsPrivateStarted ΒΆ
IsPrivateStarted indicates if user started the private dialog with a bot (e.g. pressed the start button)
func (*User) OAuthHTTPClient ΒΆ
OAuthHTTPClient returns HTTP client with Bearer authorization headers
func (*User) OAuthToken ΒΆ
OAuthToken returns OAuthToken for service
func (*User) OAuthValid ΒΆ
OAuthValid checks if OAuthToken for service is set
func (*User) OauthInitURL ΒΆ
OauthInitURL used in OAuth process as returning URL
func (*User) OauthRedirectURL ΒΆ
OauthRedirectURL used in OAuth process as returning URL
func (*User) ResetOAuthToken ΒΆ
ResetOAuthToken reset OAuthToken for service
func (*User) SaveSetting ΒΆ
SaveSetting sets User's setting for service with specific key
func (*User) SaveSettings ΒΆ
SaveSettings save User's setting for service
func (*User) ServiceHookToken ΒΆ
ServiceHookToken returns User's hook token to use in webhook handling
func (*User) ServiceHookURL ΒΆ
ServiceHookURL returns User's webhook URL for service to use in webhook handling Used in case when incoming webhooks despatching on the user behalf to chats
func (*User) SetAfterAuthAction ΒΆ
SetAfterAuthAction sets the handlerFunc and it's args that will be triggered on success user Auth. F.e. you can use it to resume action interrupted because user didn't authed !!! Please note that you must ommit first arg *integram.Context, because it will be automatically prepended on auth success and will contains actual action context
func (*User) TzLocation ΒΆ
TzLocation retrieve User's timezone if stored in DB
func (*User) UpdateCache ΒΆ
UpdateCache updates the per User cache using MongoDB Update query
type WebhookContext ΒΆ
type WebhookContext struct {
// contains filtered or unexported fields
}
WebhookContext is passed to WebhookHandler of service
func (*WebhookContext) FirstParse ΒΆ
func (wc *WebhookContext) FirstParse() bool
FirstParse indicates that the request body is not yet readed
func (*WebhookContext) Form ΒΆ
func (wc *WebhookContext) Form() uurl.Values
Form decodes the POST form in the request's body to the out interface
func (*WebhookContext) FormValue ΒΆ
func (wc *WebhookContext) FormValue(key string) string
FormValue return form data with specific key
func (*WebhookContext) Get ΒΆ
func (wc *WebhookContext) Get(key string) (interface{}, bool)
func (*WebhookContext) Header ΒΆ
func (wc *WebhookContext) Header(key string) string
Header returns the request header with the name
func (*WebhookContext) Headers ΒΆ
func (wc *WebhookContext) Headers() map[string][]string
Headers returns the headers of request
func (*WebhookContext) HookID ΒΆ
func (wc *WebhookContext) HookID() string
HookID returns the HookID from the URL
func (*WebhookContext) JSON ΒΆ
func (wc *WebhookContext) JSON(out interface{}) error
JSON decodes the JSON in the request's body to the out interface
func (*WebhookContext) Param ΒΆ
func (wc *WebhookContext) Param(s string) string
Param return param from url
func (*WebhookContext) QueryValue ΒΆ
func (wc *WebhookContext) QueryValue(key string) string
FormValue return form data with specific key
func (*WebhookContext) RAW ΒΆ
func (wc *WebhookContext) RAW() (*[]byte, error)
RAW returns request's body
func (*WebhookContext) Redirect ΒΆ
func (wc *WebhookContext) Redirect(code int, s string)
Redirect send the Location header
func (*WebhookContext) Request ΒΆ
func (wc *WebhookContext) Request() *http.Request
func (*WebhookContext) RequestID ΒΆ
func (wc *WebhookContext) RequestID() string
RequestID returns the unique generated request ID
func (*WebhookContext) Response ΒΆ
func (wc *WebhookContext) Response(code int, s string)
Header returns the request header with the name
func (*WebhookContext) Store ΒΆ
func (wc *WebhookContext) Store(key string, b interface{})
func (*WebhookContext) Writer ΒΆ
func (wc *WebhookContext) Writer() http.ResponseWriter