Documentation
¶
Overview ¶
Package ubot provides types and
Index ¶
- func Always(bot *Bot, update axon.O) (result bool)
- func GetUpdatesSource(bot *Bot, ctx context.Context, updatesChan chan axon.O)
- func MessageHasCommand(entity string) func(bot *Bot, message axon.O) (result bool)
- func MessageHasEntities(bot *Bot, message axon.O) (result bool)
- func MessageHasPhoto(bot *Bot, message axon.O) (result bool)
- func MessageInGroup(bot *Bot, message axon.O) (result bool)
- func MessageIsPrivate(bot *Bot, message axon.O) (result bool)
- func ServerSource(bot *Bot, ctx context.Context, updatesChan chan axon.O)
- type Bot
- func (b *Bot) AddCallbackQueryHandler(matcher Matcher, handler Handler)
- func (b *Bot) AddChannelPostHandler(matcher Matcher, handler Handler)
- func (b *Bot) AddChatMemberHandler(matcher Matcher, handler Handler)
- func (b *Bot) AddChosenInlineResultHandler(matcher Matcher, handler Handler)
- func (b *Bot) AddEditedChannelPostHandler(matcher Matcher, handler Handler)
- func (b *Bot) AddEditedMessageHandler(matcher Matcher, handler Handler)
- func (b *Bot) AddInlineQueryHandler(matcher Matcher, handler Handler)
- func (b *Bot) AddMessageHandler(matcher Matcher, handler Handler)
- func (b *Bot) AddMyChatMemberHandler(matcher Matcher, handler Handler)
- func (b *Bot) AddPollAnswerHandler(matcher Matcher, handler Handler)
- func (b *Bot) AddPollHandler(matcher Matcher, handler Handler)
- func (b *Bot) AddPreCheckoutQueryHandler(matcher Matcher, handler Handler)
- func (b *Bot) AddShippingQueryHandler(matcher Matcher, handler Handler)
- func (b *Bot) AnswerCallbackQuery(request axon.O) (result bool, err error)
- func (b *Bot) Close() (err error)
- func (b *Bot) CopyMessage(request axon.O) (result axon.O, err error)
- func (b *Bot) DeleteChatStickerSet(request axon.O) (result bool, err error)
- func (b *Bot) DeleteWebhook(request axon.O) (result bool, err error)
- func (b *Bot) EditMessageLiveLocation(request axon.O) (result axon.O, err error)
- func (b *Bot) Forever(ctx context.Context, wg *sync.WaitGroup, source UpdatesSource) error
- func (b *Bot) ForwardMessage(request axon.O) (result axon.O, err error)
- func (b *Bot) GetChat(request axon.O) (result axon.O, err error)
- func (b *Bot) GetChatAdministrators(request axon.O) (result axon.A, err error)
- func (b *Bot) GetChatMember(request axon.O) (result axon.O, err error)
- func (b *Bot) GetChatMembersCount(request axon.O) (result int64, err error)
- func (b *Bot) GetFile(fileId string) (result axon.O, err error)
- func (b *Bot) GetMe() (result *User, err error)
- func (b *Bot) GetMyCommands() (result axon.A, err error)
- func (b *Bot) GetUserProfilePhotos(request axon.O) (result axon.O, err error)
- func (b *Bot) GetWebhookInfo() (result axon.O, err error)
- func (b *Bot) KickChatMember(request axon.O) (result bool, err error)
- func (b *Bot) LeaveChat(request axon.O) (result bool, err error)
- func (b *Bot) LogOut() (err error)
- func (b *Bot) PinChatMessage(request axon.O) (result bool, err error)
- func (b *Bot) PromoteChatMember(request axon.O) (result bool, err error)
- func (b *Bot) RestrictChatMember(request axon.O) (result bool, err error)
- func (b *Bot) SendAnimation(request axon.O) (result axon.O, err error)
- func (b *Bot) SendAudio(request axon.O) (result axon.O, err error)
- func (b *Bot) SendChatAction(request axon.O) (result bool, err error)
- func (b *Bot) SendContact(request axon.O) (result axon.O, err error)
- func (b *Bot) SendDice(request axon.O) (result axon.O, err error)
- func (b *Bot) SendDocument(request axon.O) (result axon.O, err error)
- func (b *Bot) SendLocation(request axon.O) (result axon.O, err error)
- func (b *Bot) SendMediaGroup(request axon.O) (result axon.O, err error)
- func (b *Bot) SendMessage(request axon.O) (result axon.O, err error)
- func (b *Bot) SendPhoto(request axon.O) (result axon.O, err error)
- func (b *Bot) SendPoll(request axon.O) (result axon.O, err error)
- func (b *Bot) SendVenue(request axon.O) (result axon.O, err error)
- func (b *Bot) SendVideo(request axon.O) (result axon.O, err error)
- func (b *Bot) SendVideoNote(request axon.O) (result axon.O, err error)
- func (b *Bot) SendVoice(request axon.O) (result axon.O, err error)
- func (b *Bot) SetChatStickerSet(request axon.O) (result bool, err error)
- func (b *Bot) SetMyCommands(request axon.O) (result bool, err error)
- func (b *Bot) SetWebhook(request axon.O) (result bool, err error)
- func (b *Bot) StopMessageLiveLocation(request axon.O) (result axon.O, err error)
- func (b *Bot) UnbanChatMember(request axon.O) (result bool, err error)
- func (b *Bot) UnpinAllChatMessages(request axon.O) (result bool, err error)
- func (b *Bot) UnpinChatMessage(request axon.O) (result bool, err error)
- type Configuration
- type Handler
- type Matcher
- type UpdatesSource
- type UploadFile
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetUpdatesSource ¶
GetUpdatesSource is a ServerSource tha get updates vi long polling See https://core.telegram.org/bots/api#getupdates
func MessageHasCommand ¶
MessageHasCommand matches if update has axon.A certain message entity
func MessageHasEntities ¶
MatchMessageEntities matches if update has message entities
func MessageHasPhoto ¶
MessageHasPhoto matches if updates has axon.A photo
func MessageInGroup ¶
MessageInGroup matches if a message is from a group
func MessageIsPrivate ¶
MessageIsPrivate matchs is message chat type is private
func ServerSource ¶
ServerSource is ServerSource that receives updates by exposing an http endpoint. The endpoint is exposed at http://hostname:<port>/bot<apiToken>.
Types ¶
type Bot ¶
type Bot struct { Configuration Configuration BotUser User // contains filtered or unexported fields }
Bot is the main type of ubot. It implements a bot API frontend.
func NewBot ¶
func NewBot(configuration *Configuration) (result *Bot)
NewBot creates a new Bot for the given configuration
func (*Bot) AddCallbackQueryHandler ¶
AddCallbackQueryHandler adds an handler for callback_query updates.
func (*Bot) AddChannelPostHandler ¶
AddChannelPostHandler adds an handler for channel_post updates.
func (*Bot) AddChatMemberHandler ¶
AddChatMemberHandler adds an handler for chat_member updates.
func (*Bot) AddChosenInlineResultHandler ¶
AddChosenInlineResultHandler adds an handler for inline_query updates.
func (*Bot) AddEditedChannelPostHandler ¶
AddEditedChannelPostHandler adds an handler for edited_channel_post updates.
func (*Bot) AddEditedMessageHandler ¶
AddEditedMessageHandler adds an handler for edited_message updates.
func (*Bot) AddInlineQueryHandler ¶
AddInlineQueryHandler adds an handler for inline_query updates.
func (*Bot) AddMessageHandler ¶
AddMessageHandler adds an handler for message updates.
func (*Bot) AddMyChatMemberHandler ¶
AddMyChatMemberHandler adds an handler for my_chat_member updates.
func (*Bot) AddPollAnswerHandler ¶
AddPollAnswerHandler adds an handler for callback_query updates.
func (*Bot) AddPollHandler ¶
AddPollHandler adds an handler for callback_query updates.
func (*Bot) AddPreCheckoutQueryHandler ¶
AddPreCheckoutQueryHandler adds an handler for callback_query updates.
func (*Bot) AddShippingQueryHandler ¶
AddShippingQueryHandler adds an handler for callback_query updates.
func (*Bot) AnswerCallbackQuery ¶
AnswerCallbackQuery send an answer to the given callback query https://core.telegram.org/bots/api#answercallbackquery
func (*Bot) Close ¶
Close closea the bot instance see https://core.telegram.org/bots/api#close
func (*Bot) CopyMessage ¶
CopyMessage copy messages of any kind. The method is analogous to the method forwardMessage, but the copied message doesn't have a link to the original message. see https://core.telegram.org/bots/api#copymessage
func (*Bot) DeleteChatStickerSet ¶
DeleteChatStickerSet set a new group sticker set for a supergroup. see https://core.telegram.org/bots/api#deletechatstickerset
func (*Bot) DeleteWebhook ¶
DeleteWebhook implements deleteWebhook from Telegram Bot API see https://core.telegram.org/bots/api#deletewebhook
func (*Bot) EditMessageLiveLocation ¶
EditMessageLiveLocation sends a location see https://core.telegram.org/bots/api#editmessagelivelocation
func (*Bot) ForwardMessage ¶
ForwardMessage forwards messages of any kind see https://core.telegram.org/bots/api#forwardmessage
func (*Bot) GetChat ¶
GetChat get up to date information about the chat. see https://core.telegram.org/bots/api#getchat
func (*Bot) GetChatAdministrators ¶
GetChatAdministrators get the number of members in a chat. see https://core.telegram.org/bots/api#getchatmemberscount
func (*Bot) GetChatMember ¶
GetChatMember gets information about a member of a chat. see https://core.telegram.org/bots/api#getchatmember
func (*Bot) GetChatMembersCount ¶
GetChatMembersCount get the number of members in a chat. see https://core.telegram.org/bots/api#getchatmemberscount
func (*Bot) GetFile ¶
GetFile gets basic info about a file and prepare it for downloading. see https://core.telegram.org/bots/api#getfile
func (*Bot) GetMe ¶
GetMe returns basic information about the bot in form of a User object. see https://core.telegram.org/bots/api#getme
func (*Bot) GetMyCommands ¶
GetMyCommands send an answer to the given callback query https://core.telegram.org/bots/api#getmycommands
func (*Bot) GetUserProfilePhotos ¶
GetUserProfilePhotos gets user profile photos. see https://core.telegram.org/bots/api#getuserprofilephotos
func (*Bot) GetWebhookInfo ¶
GetWebhookInfo get current webhook status https://core.telegram.org/bots/api#getwebhookinfo
func (*Bot) KickChatMember ¶
KickChatMember kicks a user from a group, a supergroup or a channel. see https://core.telegram.org/bots/api#kickchatmember
func (*Bot) LeaveChat ¶
LeaveChat leave a group, supergroup or channel. see https://core.telegram.org/bots/api#leavechat
func (*Bot) LogOut ¶
LogOut logs the bot out of the cloud Bot API server see https://core.telegram.org/bots/api#logout
func (*Bot) PinChatMessage ¶
PinChatMessage pins a message for the given chat https://core.telegram.org/bots/api#pinchatmessage
func (*Bot) PromoteChatMember ¶
PromoteChatMember unban a previously kicked user in a supergroup or channel. see https://core.telegram.org/bots/api#promotechatmember
func (*Bot) RestrictChatMember ¶
RestrictChatMember unban a previously kicked user in a supergroup or channel. see https://core.telegram.org/bots/api#restrictchatmember
func (*Bot) SendAnimation ¶
SendAnimation sends an animation see https://core.telegram.org/bots/api#sendanimation
func (*Bot) SendAudio ¶
SendAudio sends an audio see https://core.telegram.org/bots/api#sendaudio
func (*Bot) SendChatAction ¶
SendChatAction sends a chat action see https://core.telegram.org/bots/api#sendchataction
func (*Bot) SendContact ¶
SendContact sends a venue see https://core.telegram.org/bots/api#sendcontact
func (*Bot) SendDice ¶
SendDice sends a dice see https://core.telegram.org/bots/api#senddice
func (*Bot) SendDocument ¶
SendVideo sends a video see https://core.telegram.org/bots/api#senddocument
func (*Bot) SendLocation ¶
SendLocation sends a location see https://core.telegram.org/bots/api#sendlocation
func (*Bot) SendMediaGroup ¶
SendVoice sends a media group see https://core.telegram.org/bots/api#sendmediagroup
func (*Bot) SendMessage ¶
SendMessage sends a text message see https://core.telegram.org/bots/api#sendmessage
func (*Bot) SendPhoto ¶
SendPhoto sends a photo see https://core.telegram.org/bots/api#sendphoto
func (*Bot) SendPoll ¶
SendPoll sends a poll see https://core.telegram.org/bots/api#sendpoll
func (*Bot) SendVenue ¶
SendVenue sends a venue see https://core.telegram.org/bots/api#sendvenue
func (*Bot) SendVideo ¶
SendVideo sends a video see https://core.telegram.org/bots/api#sendvideo
func (*Bot) SendVideoNote ¶
SendVoice sends a video note see https://core.telegram.org/bots/api#sendvideonote
func (*Bot) SendVoice ¶
SendVoice sends a voice see https://core.telegram.org/bots/api#sendvoice
func (*Bot) SetChatStickerSet ¶
SetChatStickerSet set a new group sticker set for a supergroup. see https://core.telegram.org/bots/api#setchatstickerset
func (*Bot) SetMyCommands ¶
SetMyCommands AnswerCallbackQuery send an answer to the given callback query https://core.telegram.org/bots/api#setmycommands
func (*Bot) SetWebhook ¶
SetWebhook implements setWebhook from Telegram Bot API. see https://core.telegram.org/bots/api#setwebhook
func (*Bot) StopMessageLiveLocation ¶
StopMessageLiveLocation sends a location see https://core.telegram.org/bots/api#stopmessagelivelocation
func (*Bot) UnbanChatMember ¶
UnbanChatMember unban a previously kicked user in a supergroup or channel. see https://core.telegram.org/bots/api#unbanchatmember
func (*Bot) UnpinAllChatMessages ¶
UnpinAllChatMessages clears the list of pinned messages in a chat. see https://core.telegram.org/bots/api#unpinallchatmessages
func (*Bot) UnpinChatMessage ¶
UnpinChatMessage removes a message from the list of pinned messages in a chat. see https://core.telegram.org/bots/api#unpinchatmessage
type Configuration ¶
type Configuration struct { APIToken string `json:"api_token"` ServerPort string `json:"server_port"` WebhookUrl string `json:"webhook_url"` WorkerNo int `json:"worker_no"` }
Configuration struct holds configuration data for the bot
type Matcher ¶
Matcher is a function that will decide wheter an update will be handled by a Matcher
type UpdatesSource ¶
UpdatesSource are function that will get updates from the API server or any other source and publish them onto a channel. A proper UpdateSource will handle the context argument as needed.
type UploadFile ¶
type User ¶
type User struct { ID int64 `json:"id"` IsBot bool `json:"is_bot"` FirstName string `json:"first_name"` LastName string `json:"last_name,omitempty"` Username string `json:"username,omitempty"` LanguageCode string `json:"language_code,omitempty"` CanJoinGroups bool `json:"can_join_groups,omitempty"` CanReadAllGroupMessages bool `json:"can_read_all_group_messages,omitempty"` SupportsInlineQueries bool `json:"supports_inline_queries,omitempty"` }
User struct stores user infos for the bot user