aboutsummaryrefslogtreecommitdiff
path: root/telegram/client.go
diff options
context:
space:
mode:
authorbodqhrohro <bodqhrohro@gmail.com>2019-11-29 03:51:41 +0300
committerbodqhrohro <bodqhrohro@gmail.com>2019-11-29 03:51:41 +0300
commitdbe87fafa8fb3c38d6cb22ac335cc76b70b607a6 (patch)
tree784f16c7e27444c03b865e1f4c03aadac1f18bf8 /telegram/client.go
parentbcf222b53db2199cb6c784ac8c5b7105d794b6c9 (diff)
Handle updates of user status
Diffstat (limited to 'telegram/client.go')
-rw-r--r--telegram/client.go35
1 files changed, 17 insertions, 18 deletions
diff --git a/telegram/client.go b/telegram/client.go
index 6a738af..e8643ce 100644
--- a/telegram/client.go
+++ b/telegram/client.go
@@ -1,10 +1,10 @@
package telegram
import (
- "fmt"
"github.com/pkg/errors"
"path/filepath"
"strconv"
+ "sync"
"dev.narayana.im/narayana/telegabber/config"
"dev.narayana.im/narayana/telegabber/persistence"
@@ -23,6 +23,16 @@ var logConstants = map[string]int32{
":all": 1023,
}
+type cacheStruct struct {
+ chats map[int64]*client.Chat
+ users map[int32]*client.User
+}
+
+var cache = cacheStruct{
+ chats: map[int64]*client.Chat{},
+ users: map[int32]*client.User{},
+}
+
func stringToLogConstant(c string) int32 {
level, ok := logConstants[c]
if !ok {
@@ -44,10 +54,14 @@ type Client struct {
jid string
Session *persistence.Session
- ready chan bool
+ locks clientLocks
online bool
}
+type clientLocks struct {
+ authorizationReady sync.WaitGroup
+}
+
// NewClient instantiates a Telegram App
func NewClient(conf config.TelegramConfig, jid string, component *xmpp.Component, session *persistence.Session) (*Client, error) {
logVerbosity := client.WithLogVerbosity(&client.SetLogVerbosityLevelRequest{
@@ -88,21 +102,6 @@ func NewClient(conf config.TelegramConfig, jid string, component *xmpp.Component
jid: jid,
Session: session,
logVerbosity: logVerbosity,
- ready: make(chan bool),
+ locks: clientLocks{},
}, nil
}
-
-func updateHandler(tdlibClient *client.Client) {
- listener := tdlibClient.GetListener()
- defer listener.Close()
-
- for update := range listener.Updates {
- if update.GetClass() == client.ClassUpdate {
- fmt.Printf("%#v\n", update)
- }
- }
-}
-
-func (c *Client) ProcessOutgoingMessage(chatID int, text string, messageID int) {
- // TODO
-}