Merge branch 'master' into all-contributors/add-wcsiu

This commit is contained in:
Arman 2021-02-19 16:11:34 +03:30 committed by GitHub
commit 56d18d435c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 3937 additions and 1038 deletions

View File

@ -82,6 +82,15 @@
"bug",
"doc"
]
},
{
"login": "motylkov",
"name": "motylkov",
"avatar_url": "https://avatars1.githubusercontent.com/u/1659182?v=4",
"profile": "https://github.com/motylkov",
"contributions": [
"code"
]
}
],
"contributorsPerLine": 7,

View File

@ -1,6 +1,6 @@
# go-tdlib
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-8-orange.svg?style=flat-square)](#contributors-)
[![All Contributors](https://img.shields.io/badge/all_contributors-9-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->
Golang Telegram TdLib JSON bindings
@ -42,11 +42,31 @@ If hit any build errors, refer to [Tdlib build instructions](https://github.com/
I'm using static linking against tdlib so it won't require to build the whole tdlib source files.
## Docker
You can use prebuilt tdlib with following Docker image:
You can use the prebuilt tdlib image and Go image of your liking:
***Windows:***
``` shell
docker pull mihaildemidoff/tdlib-go
```
FROM golang:1.15-alpine AS golang
COPY --from=wcsiu/tdlib:1.7-alpine /usr/local/include/td /usr/local/include/td
COPY --from=wcsiu/tdlib:1.7-alpine /usr/local/lib/libtd* /usr/local/lib/
COPY --from=wcsiu/tdlib:1.7-alpine /usr/lib/libssl.a /usr/local/lib/libssl.a
COPY --from=wcsiu/tdlib:1.7-alpine /usr/lib/libcrypto.a /usr/local/lib/libcrypto.a
COPY --from=wcsiu/tdlib:1.7-alpine /lib/libz.a /usr/local/lib/libz.a
RUN apk add build-base
WORKDIR /myApp
COPY . .
RUN go build --ldflags "-extldflags '-static -L/usr/local/lib -ltdjson_static -ltdjson_private -ltdclient -ltdcore -ltdactor -ltddb -ltdsqlite -ltdnet -ltdutils -ldl -lm -lssl -lcrypto -lstdc++ -lz'" -o /tmp/getChats getChats.go
FROM gcr.io/distroless/base:latest
COPY --from=golang /tmp/getChats /getChats
ENTRYPOINT [ "/getChats" ]
```
```
$ docker build -fDockerfile -ttelegram-client .
```
## Example
@ -145,6 +165,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
</tr>
<tr>
<td align="center"><a href="https://github.com/wcsiu"><img src="https://avatars0.githubusercontent.com/u/5212960?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Wachiu Siu</b></sub></a><br /><a href="#example-wcsiu" title="Examples">💡</a> <a href="https://github.com/Arman92/go-tdlib/issues?q=author%3Awcsiu" title="Bug reports">🐛</a> <a href="https://github.com/Arman92/go-tdlib/commits?author=wcsiu" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/motylkov"><img src="https://avatars1.githubusercontent.com/u/1659182?v=4?s=100" width="100px;" alt=""/><br /><sub><b>motylkov</b></sub></a><br /><a href="https://github.com/Arman92/go-tdlib/commits?author=motylkov" title="Code">💻</a></td>
</tr>
</table>

View File

@ -70,16 +70,22 @@ func getChatList(client *tdlib.Client, limit int) error {
if !haveFullChatList && limit > len(allChats) {
offsetOrder := int64(math.MaxInt64)
offsetChatID := int64(0)
var chatList = tdlib.NewChatListMain()
var lastChat *tdlib.Chat
if len(allChats) > 0 {
lastChat = allChats[len(allChats)-1]
offsetOrder = int64(lastChat.Order)
for i := 0; i < len(lastChat.Positions); i++ {
//Find the main chat list
if lastChat.Positions[i].List.GetChatListEnum() == tdlib.ChatListMainType {
offsetOrder = int64(lastChat.Positions[i].Order)
}
}
offsetChatID = lastChat.ID
}
// get chats (ids) from tdlib
chats, err := client.GetChats(tdlib.JSONInt64(offsetOrder),
chats, err := client.GetChats(chatList, tdlib.JSONInt64(offsetOrder),
offsetChatID, int32(limit-len(allChats)))
if err != nil {
return err

View File

@ -53,7 +53,7 @@ func main() {
chatID := int64(198529620) // Foursquare bot chat id
inputMsgTxt := tdlib.NewInputMessageText(tdlib.NewFormattedText("/start", nil), true, true)
client.SendMessage(chatID, 0, false, true, nil, inputMsgTxt)
client.SendMessage(chatID, int64(0), int64(0), nil, nil, inputMsgTxt)
time.Sleep(5 * time.Second)
}()

1068
methods.go

File diff suppressed because it is too large Load Diff

3855
types.go

File diff suppressed because it is too large Load Diff