func getChatName cid int string not_cached if cid 2000000000 cid cid 2

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
func getChatName(cid int) string {
not_cached := 0
if cid > 2000000000 {
cid = cid - 2000000000
}
str_uid := strconv.Itoa(cid)
if val, ok := chatsCache[str_uid]; ok {
return val
} else {
not_cached = 1
}
str_id := strconv.Itoa(cid)
query := req("messages.getChat", "chat_id="+str_id)
v, _ := jason.NewObjectFromBytes([]byte(query))
response, _ := v.GetObject("response")
chatName, _ := response.Map()["title"].String()
if not_cached == 1 {
chatsCache[str_uid] = chatName
}
return chatName
}