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: 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

View file

@ -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.0 Go wrapper for [TDLib (Telegram Database Library)](https://github.com/tdlib/td) with full support of TDLib v1.8.14
## 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.0 only! ### Note: Compatible with TDLib v1.8.14 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.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 docker run --rm -it -e "API_ID=00000" -e "API_HASH=abcdef0123456789" tdlib-test ash
./app ./app
``` ```

File diff suppressed because it is too large Load diff

View file

@ -2,6 +2,7 @@ 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"
@ -83,7 +84,8 @@ func (instance *tdlib) receive(timeout time.Duration) (*Response, error) {
return nil, errors.New("update receiving timeout") 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 var resp Response
@ -107,7 +109,8 @@ func Execute(req Request) (*Response, error) {
return nil, errors.New("request can't be parsed") 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 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 { func parseClass(firstLine string, scanner *bufio.Scanner) *Class {
name, description, _, _, _ := parseEntity(firstLine, scanner) class := &Class{
return &Class{ Name: "",
Name: name, Description: "",
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) {
@ -119,9 +125,6 @@ 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] {
@ -139,17 +142,13 @@ Loop:
rawProperties := strings.Split(propertiesLine, "@") rawProperties := strings.Split(propertiesLine, "@")
for _, rawProperty := range rawProperties[1:] { for _, rawProperty := range rawProperties[1:] {
propertyName, value := parseProperty(rawProperty) name, value := parseProperty(rawProperty)
switch { switch {
case propertyName == "class": case name == "description":
if name == "" {
name = value
}
case propertyName == "description":
description = value description = value
default: default:
propertyName = strings.TrimPrefix(propertyName, "param_") name = strings.TrimPrefix(name, "param_")
property := getProperty(properties, propertyName) property := getProperty(properties, name)
property.Description = value property.Description = value
} }