Compare commits
1 commit
fresh-tdli
...
fresh-tdli
Author | SHA1 | Date | |
---|---|---|---|
47da331806 |
2
Makefile
2
Makefile
|
@ -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
|
||||
|
|
|
@ -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
|
||||
```
|
||||
|
|
2490
client/function.go
2490
client/function.go
File diff suppressed because it is too large
Load diff
|
@ -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
|
||||
|
||||
|
|
7522
client/type.go
7522
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,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
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue