Compare commits

..

2 commits

9 changed files with 19234 additions and 1940 deletions

View file

@ -1,4 +1,4 @@
TAG := v1.8.14
TAG := 5bbfc1cf5dab94f82e02f3430ded7241d4653551
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.14
Go wrapper for [TDLib (Telegram Database Library)](https://github.com/tdlib/td) with full support of TDLib v1.8.0
## 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.14 only!
### Note: Compatible with TDLib v1.8.0 only!
### Windows
@ -143,7 +143,7 @@ tdlibClient, err := client.NewClient(authorizer, proxy)
```
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
./app
```

File diff suppressed because it is too large Load diff

View file

@ -2,7 +2,6 @@ package client
/*
#include <stdlib.h>
#include <string.h>
#include <td/telegram/td_json_client.h>
*/
import "C"
@ -84,8 +83,7 @@ func (instance *tdlib) receive(timeout time.Duration) (*Response, error) {
return nil, errors.New("update receiving timeout")
}
resultLen := C.strlen(result)
data := C.GoBytes(unsafe.Pointer(result), C.int(resultLen))
data := []byte(C.GoString(result))
var resp Response
@ -109,8 +107,7 @@ func Execute(req Request) (*Response, error) {
return nil, errors.New("request can't be parsed")
}
resultLen := C.strlen(result)
data = C.GoBytes(unsafe.Pointer(result), C.int(resultLen))
data = []byte(C.GoString(result))
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,17 +91,11 @@ func parseFunction(firstLine string, scanner *bufio.Scanner) *Function {
}
func parseClass(firstLine string, scanner *bufio.Scanner) *Class {
class := &Class{
Name: "",
Description: "",
name, description, _, _, _ := parseEntity(firstLine, scanner)
return &Class{
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) {
@ -125,6 +119,9 @@ Loop:
default:
bodyFields := strings.Fields(line)
if len(bodyFields) == 0 {
break Loop
}
name = bodyFields[0]
for _, rawProperty := range bodyFields[1 : len(bodyFields)-2] {
@ -142,13 +139,17 @@ Loop:
rawProperties := strings.Split(propertiesLine, "@")
for _, rawProperty := range rawProperties[1:] {
name, value := parseProperty(rawProperty)
propertyName, value := parseProperty(rawProperty)
switch {
case name == "description":
case propertyName == "class":
if name == "" {
name = value
}
case propertyName == "description":
description = value
default:
name = strings.TrimPrefix(name, "param_")
property := getProperty(properties, name)
propertyName = strings.TrimPrefix(propertyName, "param_")
property := getProperty(properties, propertyName)
property.Description = value
}