aboutsummaryrefslogtreecommitdiff
path: root/telegram/client.go
diff options
context:
space:
mode:
authorbodqhrohro <bodqhrohro@gmail.com>2019-11-24 20:10:29 +0300
committerbodqhrohro <bodqhrohro@gmail.com>2019-11-24 20:10:29 +0300
commit653b1bde94b89d91862007a18b8730ff58673f59 (patch)
tree5b0c8674f918eb49dd27e53918ff10529c0ff55c /telegram/client.go
parentc0c21a35a4cfd326423ad530926a0e96c1b07dcf (diff)
Telegram authorization
Diffstat (limited to 'telegram/client.go')
-rw-r--r--telegram/client.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/telegram/client.go b/telegram/client.go
index 833d883..c8187fc 100644
--- a/telegram/client.go
+++ b/telegram/client.go
@@ -10,6 +10,7 @@ import (
"dev.narayana.im/narayana/telegabber/persistence"
"github.com/zelenin/go-tdlib/client"
+ "gosrc.io/xmpp"
)
var logConstants = map[string]int32{
@@ -34,6 +35,8 @@ func stringToLogConstant(c string) int32 {
// Client stores the metadata for lazily invoked TDlib instance
type Client struct {
client *client.Client
+ authorizer *client.ClientAuthorizerType
+ xmpp *xmpp.Component
jid string
parameters *client.TdlibParameters
Session *persistence.Session
@@ -42,14 +45,14 @@ type Client struct {
}
// NewClient instantiates a Telegram App
-func NewClient(conf config.TelegramConfig, jid string, session *persistence.Session) (Client, error) {
+func NewClient(conf config.TelegramConfig, jid string, component *xmpp.Component, session *persistence.Session) (*Client, error) {
logVerbosity := client.WithLogVerbosity(&client.SetLogVerbosityLevelRequest{
NewVerbosityLevel: stringToLogConstant(conf.Loglevel),
})
apiID, err := strconv.Atoi(conf.Tdlib.Client.APIID)
if err != nil {
- return Client{}, errors.Wrap(err, "Wrong api_id")
+ return &Client{}, errors.Wrap(err, "Wrong api_id")
}
parameters := client.TdlibParameters{
@@ -75,8 +78,9 @@ func NewClient(conf config.TelegramConfig, jid string, session *persistence.Sess
IgnoreFileNames: false,
}
- return Client{
+ return &Client{
parameters: &parameters,
+ xmpp: component,
jid: jid,
Session: session,
logVerbosity: logVerbosity,
@@ -93,3 +97,7 @@ func updateHandler(tdlibClient *client.Client) {
}
}
}
+
+func (c *Client) ProcessOutgoingMessage(chatID int, text string, messageID int) {
+ // TODO
+}