mirror of
https://github.com/c0re100/gotdlib.git
synced 2026-02-22 04:30:17 +01:00
Compare commits
23 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c9c7701a0d | ||
|
|
0f088c4101 | ||
|
|
c1bd67f199 | ||
|
|
4597e26403 | ||
|
|
926224f707 | ||
|
|
9b94728dda | ||
|
|
14418433a4 | ||
|
|
5c5078ec42 | ||
|
|
51f3ce0659 | ||
|
|
bc2b5f5823 | ||
|
|
969ddb4746 | ||
|
|
e5eeec83b3 | ||
|
|
3a8d30fd35 | ||
|
|
eb767ed26e | ||
|
|
b943b2fe5e | ||
|
|
dc9ae3ed54 | ||
|
|
c695d13f46 | ||
|
|
05b67218a9 | ||
|
|
8de0893227 | ||
|
|
baee9b059d | ||
|
|
bda4018ed3 | ||
|
|
2a5a6d2b76 | ||
|
|
626ffe1a7b |
12 changed files with 26556 additions and 2765 deletions
|
|
@ -86,15 +86,15 @@ func NewClient(authorizationStateHandler AuthorizationStateHandler, options ...O
|
||||||
client.extraGenerator = UuidV4Generator()
|
client.extraGenerator = UuidV4Generator()
|
||||||
client.catchTimeout = 60 * time.Second
|
client.catchTimeout = 60 * time.Second
|
||||||
|
|
||||||
for _, option := range options {
|
|
||||||
option(client)
|
|
||||||
}
|
|
||||||
|
|
||||||
tdlibInstance.addClient(client)
|
tdlibInstance.addClient(client)
|
||||||
|
|
||||||
go client.processPendingResponse()
|
go client.processPendingResponse()
|
||||||
go client.receiver()
|
go client.receiver()
|
||||||
|
|
||||||
|
for _, option := range options {
|
||||||
|
go option(client)
|
||||||
|
}
|
||||||
|
|
||||||
err := Authorize(client, authorizationStateHandler)
|
err := Authorize(client, authorizationStateHandler)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -155,6 +155,10 @@ func (client *Client) processResponse(response *Response) {
|
||||||
if needGc {
|
if needGc {
|
||||||
client.listenerStore.gc()
|
client.listenerStore.gc()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if typ.GetType() == TypeUpdateAuthorizationState && typ.(*UpdateAuthorizationState).AuthorizationState.AuthorizationStateType() == TypeAuthorizationStateClosed {
|
||||||
|
close(client.responses)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *Client) receiver() {
|
func (client *Client) receiver() {
|
||||||
|
|
@ -257,7 +261,3 @@ func (client *Client) AddEventReceiver(msgType Type, channelCapacity int) *Liste
|
||||||
|
|
||||||
return listener
|
return listener
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *Client) Stop() {
|
|
||||||
client.Destroy()
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -15,29 +15,29 @@ func UuidV4Generator() ExtraGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsCommand(text string) bool {
|
func IsCommand(text string) bool {
|
||||||
if text != "" {
|
if i := strings.Index(text, "/"); i == 0 {
|
||||||
if text[0] == '/' {
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func CheckCommand(text string, entities []*TextEntity) string {
|
func CheckCommand(text string, entities []*TextEntity) string {
|
||||||
if IsCommand(text) {
|
if IsCommand(text) {
|
||||||
// e.g.: ["/hello@world_bot", "/hello@", "/hello@123"]
|
cmd := text
|
||||||
// Result: "/hello"
|
|
||||||
if i := strings.Index(text, "@"); i != -1 {
|
|
||||||
return text[:i]
|
|
||||||
}
|
|
||||||
|
|
||||||
// e.g. ["/hello 123", "/hell o 123"]
|
// e.g. ["/hello 123", "/hell o 123"]
|
||||||
// Result: "/hello", "/hell"
|
// Result: "/hello", "/hell"
|
||||||
if i := strings.Index(text, " "); i != -1 {
|
if i := strings.Index(cmd, " "); i != -1 {
|
||||||
return text[:i]
|
cmd = cmd[:i]
|
||||||
}
|
}
|
||||||
|
|
||||||
return text
|
// e.g.: ["/hello@world_bot", "/hello@", "/hello@123"]
|
||||||
|
// Result: "/hello"
|
||||||
|
if i := strings.Index(cmd, "@"); i != -1 {
|
||||||
|
cmd = cmd[:i]
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmd
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
|
||||||
5942
client/function.go
5942
client/function.go
File diff suppressed because it is too large
Load diff
|
|
@ -4,9 +4,9 @@ package client
|
||||||
//#cgo freebsd CFLAGS: -I/usr/local/include
|
//#cgo freebsd CFLAGS: -I/usr/local/include
|
||||||
//#cgo darwin CFLAGS: -I/usr/local/include
|
//#cgo darwin CFLAGS: -I/usr/local/include
|
||||||
//#cgo windows CFLAGS: -IE:/src/tdlib -IE:/src/tdlib/build
|
//#cgo windows CFLAGS: -IE:/src/tdlib -IE:/src/tdlib/build
|
||||||
//#cgo linux LDFLAGS: -L/usr/local/lib -ltdjson_static -ltdjson_private -ltdclient -ltdcore -ltdapi -ltdactor -ltddb -ltdsqlite -ltdmtproto -ltdnet -ltdutils -lstdc++ -lssl -lcrypto -ldl -lz -lm
|
//#cgo linux LDFLAGS: -L/usr/local/lib -ltdjson_static -ltdjson_private -ltdclient -ltdcore -ltdapi -ltdactor -ltddb -ltde2e -ltdsqlite -ltdmtproto -ltdnet -ltdutils -lstdc++ -lssl -lcrypto -ldl -lz -lm
|
||||||
//#cgo freebsd LDFLAGS: -L/usr/local/lib -ltdjson_static -ltdjson_private -ltdclient -ltdcore -ltdapi -ltdactor -ltddb -ltdsqlite -ltdmtproto -ltdnet -ltdutils -lstdc++ -lssl -lcrypto -ldl -lz -lm
|
//#cgo freebsd LDFLAGS: -L/usr/local/lib -ltdjson_static -ltdjson_private -ltdclient -ltdcore -ltdapi -ltdactor -ltddb -ltde2e -ltdsqlite -ltdmtproto -ltdnet -ltdutils -lstdc++ -lssl -lcrypto -ldl -lz -lm
|
||||||
//#cgo darwin LDFLAGS: -L/usr/local/lib -L/usr/local/opt/openssl/lib -ltdjson_static -ltdjson_private -ltdclient -ltdcore -ltdapi -ltdactor -ltddb -ltdsqlite -ltdmtproto -ltdnet -ltdutils -lstdc++ -lssl -lcrypto -ldl -lz -lm
|
//#cgo darwin LDFLAGS: -L/usr/local/lib -L/usr/local/opt/openssl/lib -ltdjson_static -ltdjson_private -ltdclient -ltdcore -ltdapi -ltdactor -ltddb -ltde2e -ltdsqlite -ltdmtproto -ltdnet -ltdutils -lstdc++ -lssl -lcrypto -ldl -lz -lm
|
||||||
//#cgo windows LDFLAGS: -LE:/src/tdlib/build/Release -ltdjson
|
//#cgo windows LDFLAGS: -LE:/src/tdlib/build/Release -ltdjson
|
||||||
//#include <stdlib.h>
|
//#include <stdlib.h>
|
||||||
//#include <td/telegram/td_json_client.h>
|
//#include <td/telegram/td_json_client.h>
|
||||||
|
|
|
||||||
13326
client/type.go
13326
client/type.go
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
4252
data/td_api.tl
4252
data/td_api.tl
File diff suppressed because it is too large
Load diff
BIN
example/media/Meru_01.png
Normal file
BIN
example/media/Meru_01.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 794 KiB |
BIN
example/media/Meru_02.png
Normal file
BIN
example/media/Meru_02.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 900 KiB |
|
|
@ -101,7 +101,7 @@ func main() {
|
||||||
},
|
},
|
||||||
InputMessageContent: &tdlib.InputMessagePhoto{
|
InputMessageContent: &tdlib.InputMessagePhoto{
|
||||||
Photo: &tdlib.InputFileLocal{
|
Photo: &tdlib.InputFileLocal{
|
||||||
Path: "./myht9-1486821485193084928.jpg",
|
Path: "./Meru_01.png",
|
||||||
},
|
},
|
||||||
Caption: text,
|
Caption: text,
|
||||||
},
|
},
|
||||||
|
|
@ -123,13 +123,13 @@ func main() {
|
||||||
InputMessageContents: []tdlib.InputMessageContent{
|
InputMessageContents: []tdlib.InputMessageContent{
|
||||||
&tdlib.InputMessagePhoto{
|
&tdlib.InputMessagePhoto{
|
||||||
Photo: &tdlib.InputFileLocal{
|
Photo: &tdlib.InputFileLocal{
|
||||||
Path: "./myht9-1486821485193084928.jpg",
|
Path: "./Meru_01.png",
|
||||||
},
|
},
|
||||||
Caption: text,
|
Caption: text,
|
||||||
},
|
},
|
||||||
&tdlib.InputMessagePhoto{
|
&tdlib.InputMessagePhoto{
|
||||||
Photo: &tdlib.InputFileLocal{
|
Photo: &tdlib.InputFileLocal{
|
||||||
Path: "./hisagi_02-1486983199280738309.jpg",
|
Path: "./Meru_02.png",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 153 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 116 KiB |
Loading…
Add table
Add a link
Reference in a new issue