Documentation ¶
Index ¶
Constants ¶
const VERSION = "v1.0.0-beta13"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct { // Dispatcher handlers the incoming updates and execute mapped handlers. It is recommended to use dispatcher.MakeDispatcher function for this field. Dispatcher dispatcher.Dispatcher // PublicKeys of telegram. // // If not provided, embedded public keys will be used. PublicKeys []telegram.PublicKey // DC ID to connect. // // If not provided, 2 will be used by default. DC int // DCList is initial list of addresses to connect. DCList dcs.List // Resolver to use. Resolver dcs.Resolver // Whether to show the copyright line in console or no. DisableCopyright bool // Logger is instance of zap.Logger. No logs by default. Logger *zap.Logger // Self contains details of logged in user in the form of *tg.User. Self *tg.User // Code for the language used on the device's OS, ISO 639-1 standard. SystemLangCode string // Code for the language used on the client, ISO 639-1 standard. ClientLangCode string *telegram.Client // contains filtered or unexported fields }
func NewClient ¶
func NewClient(appId int, apiHash string, cType ClientType, opts *ClientOpts) (*Client, error)
NewClient creates a new gotgproto client and logs in to telegram.
func (*Client) CreateContext ¶
CreateContext creates a new pseudo updates context. A context retrieved from this method should be reused.
func (*Client) ExportStringSession ¶
ExportStringSession EncodeSessionToString encodes the client session to a string in base64.
Note: You must not share this string with anyone, it contains auth details for your logged in account.
func (*Client) RefreshContext ¶
RefreshContext casts the new context.Context and telegram session to ext.Context (It may be used after doing Stop and Start calls respectively.)
func (*Client) Start ¶
func (c *Client) Start(opts *ClientOpts) error
Start connects the client to telegram servers and logins. It will return error if the client is already running.
type ClientOpts ¶
type ClientOpts struct { // Logger is instance of zap.Logger. No logs by default. Logger *zap.Logger // PublicKeys of telegram. // // If not provided, embedded public keys will be used. PublicKeys []telegram.PublicKey // DC ID to connect. // // If not provided, 2 will be used by default. DC int // DCList is initial list of addresses to connect. DCList dcs.List // Resolver to use. Resolver dcs.Resolver // Whether to show the copyright line in console or no. DisableCopyright bool // Session info of the authenticated user, use sessionMaker.NewSession function to fill this field. Session *sessionMaker.SessionName // Setting this field to true will lead to automatically fetch the reply_to_message for a new message update. // // Set to `false` by default. AutoFetchReply bool // Code for the language used on the device's OS, ISO 639-1 standard. SystemLangCode string // Code for the language used on the client, ISO 639-1 standard. ClientLangCode string // Custom client device Device *telegram.DeviceConfig // Panic handles all the panics that occur during handler execution. PanicHandler dispatcher.PanicHandler // Error handles all the unknown errors which are returned by the handler callback functions. ErrorHandler dispatcher.ErrorHandler // Custom middlewares Middlewares []telegram.Middleware // Custom context(if you need to stop the client from running externally) Ctx func() (ctx context.Context, cancel context.CancelFunc) }
type ClientType ¶
type ClientType struct { // BotToken is the unique API Token for the bot you're trying to authorize, get it from @BotFather. BotToken string // Mobile number of the authenticating user. Phone string }
Type of client to login to, can be of 2 types: 1.) Bot (Fill BotToken in this case) 2.) User (Fill Phone in this case)