Compare commits

..

1 commit

Author SHA1 Message Date
Aleksey Obukhov 47da331806 Адаптация к tdlib версии 1.8.14 2023-07-29 22:11:36 -04:00
9 changed files with 1937 additions and 19231 deletions

View file

@ -1,4 +1,4 @@
TAG := 5bbfc1cf5dab94f82e02f3430ded7241d4653551
TAG := v1.8.14
schema-update:
curl https://raw.githubusercontent.com/tdlib/td/${TAG}/td/generate/scheme/td_api.tl 2>/dev/null > ./data/td_api.tl

View file

@ -1,12 +1,12 @@
# go-tdlib
Go wrapper for [TDLib (Telegram Database Library)](https://github.com/tdlib/td) with full support of TDLib v1.8.0
Go wrapper for [TDLib (Telegram Database Library)](https://github.com/tdlib/td) with full support of TDLib v1.8.14
## 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`.
### Note: Compatible with TDLib v1.8.0 only!
### Note: Compatible with TDLib v1.8.14 only!
### Windows
@ -143,7 +143,7 @@ tdlibClient, err := client.NewClient(authorizer, proxy)
```
cd example
docker build --network host --build-arg TD_TAG=v1.8.0 --tag tdlib-test .
docker build --network host --build-arg TD_TAG=v1.8.14 --tag tdlib-test .
docker run --rm -it -e "API_ID=00000" -e "API_HASH=abcdef0123456789" tdlib-test ash
./app
```

File diff suppressed because it is too large Load diff

View file

@ -2,6 +2,7 @@ package client
/*
#include <stdlib.h>
#include <string.h>
#include <td/telegram/td_json_client.h>
*/
import "C"
@ -83,7 +84,8 @@ func (instance *tdlib) receive(timeout time.Duration) (*Response, error) {
return nil, errors.New("update receiving timeout")
}
data := []byte(C.GoString(result))
resultLen := C.strlen(result)
data := C.GoBytes(unsafe.Pointer(result), C.int(resultLen))
var resp Response
@ -107,7 +109,8 @@ func Execute(req Request) (*Response, error) {
return nil, errors.New("request can't be parsed")
}
data = []byte(C.GoString(result))
resultLen := C.strlen(result)
data = C.GoBytes(unsafe.Pointer(result), C.int(resultLen))
var resp Response

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -91,11 +91,17 @@ func parseFunction(firstLine string, scanner *bufio.Scanner) *Function {
}
func parseClass(firstLine string, scanner *bufio.Scanner) *Class {
name, description, _, _, _ := parseEntity(firstLine, scanner)
return &Class{
Name: name,
Description: description,
class := &Class{
Name: "",
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) {
@ -119,9 +125,6 @@ Loop:
default:
bodyFields := strings.Fields(line)
if len(bodyFields) == 0 {
break Loop
}
name = bodyFields[0]
for _, rawProperty := range bodyFields[1 : len(bodyFields)-2] {
@ -139,17 +142,13 @@ Loop:
rawProperties := strings.Split(propertiesLine, "@")
for _, rawProperty := range rawProperties[1:] {
propertyName, value := parseProperty(rawProperty)
name, value := parseProperty(rawProperty)
switch {
case propertyName == "class":
if name == "" {
name = value
}
case propertyName == "description":
case name == "description":
description = value
default:
propertyName = strings.TrimPrefix(propertyName, "param_")
property := getProperty(properties, propertyName)
name = strings.TrimPrefix(name, "param_")
property := getProperty(properties, name)
property.Description = value
}