Compare commits
2 commits
fresh-tdli
...
fresh-tdli
Author | SHA1 | Date | |
---|---|---|---|
Bohdan Horbeshko | b4c12addb0 | ||
Bohdan Horbeshko | bc2f985e62 |
2
Makefile
2
Makefile
|
@ -1,4 +1,4 @@
|
||||||
TAG := v1.8.14
|
TAG := 5bbfc1cf5dab94f82e02f3430ded7241d4653551
|
||||||
|
|
||||||
schema-update:
|
schema-update:
|
||||||
curl https://raw.githubusercontent.com/tdlib/td/${TAG}/td/generate/scheme/td_api.tl 2>/dev/null > ./data/td_api.tl
|
curl https://raw.githubusercontent.com/tdlib/td/${TAG}/td/generate/scheme/td_api.tl 2>/dev/null > ./data/td_api.tl
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
# go-tdlib
|
# go-tdlib
|
||||||
|
|
||||||
Go wrapper for [TDLib (Telegram Database Library)](https://github.com/tdlib/td) with full support of TDLib v1.8.14
|
Go wrapper for [TDLib (Telegram Database Library)](https://github.com/tdlib/td) with full support of TDLib v1.8.0
|
||||||
|
|
||||||
## TDLib installation
|
## TDLib installation
|
||||||
|
|
||||||
Use [TDLib build instructions](https://tdlib.github.io/td/build.html) with checkmarked `Install built TDLib to /usr/local instead of placing the files to td/tdlib`.
|
Use [TDLib build instructions](https://tdlib.github.io/td/build.html) with checkmarked `Install built TDLib to /usr/local instead of placing the files to td/tdlib`.
|
||||||
|
|
||||||
### Note: Compatible with TDLib v1.8.14 only!
|
### Note: Compatible with TDLib v1.8.0 only!
|
||||||
|
|
||||||
### Windows
|
### Windows
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ tdlibClient, err := client.NewClient(authorizer, proxy)
|
||||||
|
|
||||||
```
|
```
|
||||||
cd example
|
cd example
|
||||||
docker build --network host --build-arg TD_TAG=v1.8.14 --tag tdlib-test .
|
docker build --network host --build-arg TD_TAG=v1.8.0 --tag tdlib-test .
|
||||||
docker run --rm -it -e "API_ID=00000" -e "API_HASH=abcdef0123456789" tdlib-test ash
|
docker run --rm -it -e "API_ID=00000" -e "API_HASH=abcdef0123456789" tdlib-test ash
|
||||||
./app
|
./app
|
||||||
```
|
```
|
||||||
|
|
2490
client/function.go
2490
client/function.go
File diff suppressed because it is too large
Load diff
|
@ -2,7 +2,6 @@ package client
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
|
||||||
#include <td/telegram/td_json_client.h>
|
#include <td/telegram/td_json_client.h>
|
||||||
*/
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
|
@ -84,8 +83,7 @@ func (instance *tdlib) receive(timeout time.Duration) (*Response, error) {
|
||||||
return nil, errors.New("update receiving timeout")
|
return nil, errors.New("update receiving timeout")
|
||||||
}
|
}
|
||||||
|
|
||||||
resultLen := C.strlen(result)
|
data := []byte(C.GoString(result))
|
||||||
data := C.GoBytes(unsafe.Pointer(result), C.int(resultLen))
|
|
||||||
|
|
||||||
var resp Response
|
var resp Response
|
||||||
|
|
||||||
|
@ -109,8 +107,7 @@ func Execute(req Request) (*Response, error) {
|
||||||
return nil, errors.New("request can't be parsed")
|
return nil, errors.New("request can't be parsed")
|
||||||
}
|
}
|
||||||
|
|
||||||
resultLen := C.strlen(result)
|
data = []byte(C.GoString(result))
|
||||||
data = C.GoBytes(unsafe.Pointer(result), C.int(resultLen))
|
|
||||||
|
|
||||||
var resp Response
|
var resp Response
|
||||||
|
|
||||||
|
|
7528
client/type.go
7528
client/type.go
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
5817
data/td_api.json
5817
data/td_api.json
File diff suppressed because it is too large
Load diff
2087
data/td_api.tl
2087
data/td_api.tl
File diff suppressed because it is too large
Load diff
|
@ -91,17 +91,11 @@ func parseFunction(firstLine string, scanner *bufio.Scanner) *Function {
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseClass(firstLine string, scanner *bufio.Scanner) *Class {
|
func parseClass(firstLine string, scanner *bufio.Scanner) *Class {
|
||||||
class := &Class{
|
name, description, _, _, _ := parseEntity(firstLine, scanner)
|
||||||
Name: "",
|
return &Class{
|
||||||
Description: "",
|
Name: name,
|
||||||
|
Description: description,
|
||||||
}
|
}
|
||||||
|
|
||||||
classLineParts := strings.Split(firstLine, "@")
|
|
||||||
|
|
||||||
_, class.Name = parseProperty(classLineParts[1])
|
|
||||||
_, class.Description = parseProperty(classLineParts[2])
|
|
||||||
|
|
||||||
return class
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseEntity(firstLine string, scanner *bufio.Scanner) (string, string, string, []*Property, bool) {
|
func parseEntity(firstLine string, scanner *bufio.Scanner) (string, string, string, []*Property, bool) {
|
||||||
|
@ -125,6 +119,9 @@ Loop:
|
||||||
|
|
||||||
default:
|
default:
|
||||||
bodyFields := strings.Fields(line)
|
bodyFields := strings.Fields(line)
|
||||||
|
if len(bodyFields) == 0 {
|
||||||
|
break Loop
|
||||||
|
}
|
||||||
name = bodyFields[0]
|
name = bodyFields[0]
|
||||||
|
|
||||||
for _, rawProperty := range bodyFields[1 : len(bodyFields)-2] {
|
for _, rawProperty := range bodyFields[1 : len(bodyFields)-2] {
|
||||||
|
@ -142,13 +139,17 @@ Loop:
|
||||||
|
|
||||||
rawProperties := strings.Split(propertiesLine, "@")
|
rawProperties := strings.Split(propertiesLine, "@")
|
||||||
for _, rawProperty := range rawProperties[1:] {
|
for _, rawProperty := range rawProperties[1:] {
|
||||||
name, value := parseProperty(rawProperty)
|
propertyName, value := parseProperty(rawProperty)
|
||||||
switch {
|
switch {
|
||||||
case name == "description":
|
case propertyName == "class":
|
||||||
|
if name == "" {
|
||||||
|
name = value
|
||||||
|
}
|
||||||
|
case propertyName == "description":
|
||||||
description = value
|
description = value
|
||||||
default:
|
default:
|
||||||
name = strings.TrimPrefix(name, "param_")
|
propertyName = strings.TrimPrefix(propertyName, "param_")
|
||||||
property := getProperty(properties, name)
|
property := getProperty(properties, propertyName)
|
||||||
property.Description = value
|
property.Description = value
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue