mirror of
https://github.com/c0re100/gotdlib.git
synced 2026-02-22 04:30:17 +01:00
Compare commits
No commits in common. "master" and "v1.4.8" have entirely different histories.
12 changed files with 2757 additions and 26548 deletions
|
|
@ -86,15 +86,15 @@ func NewClient(authorizationStateHandler AuthorizationStateHandler, options ...O
|
|||
client.extraGenerator = UuidV4Generator()
|
||||
client.catchTimeout = 60 * time.Second
|
||||
|
||||
for _, option := range options {
|
||||
option(client)
|
||||
}
|
||||
|
||||
tdlibInstance.addClient(client)
|
||||
|
||||
go client.processPendingResponse()
|
||||
go client.receiver()
|
||||
|
||||
for _, option := range options {
|
||||
go option(client)
|
||||
}
|
||||
|
||||
err := Authorize(client, authorizationStateHandler)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
@ -155,10 +155,6 @@ func (client *Client) processResponse(response *Response) {
|
|||
if needGc {
|
||||
client.listenerStore.gc()
|
||||
}
|
||||
|
||||
if typ.GetType() == TypeUpdateAuthorizationState && typ.(*UpdateAuthorizationState).AuthorizationState.AuthorizationStateType() == TypeAuthorizationStateClosed {
|
||||
close(client.responses)
|
||||
}
|
||||
}
|
||||
|
||||
func (client *Client) receiver() {
|
||||
|
|
@ -261,3 +257,7 @@ func (client *Client) AddEventReceiver(msgType Type, channelCapacity int) *Liste
|
|||
|
||||
return listener
|
||||
}
|
||||
|
||||
func (client *Client) Stop() {
|
||||
client.Destroy()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,29 +15,29 @@ func UuidV4Generator() ExtraGenerator {
|
|||
}
|
||||
|
||||
func IsCommand(text string) bool {
|
||||
if i := strings.Index(text, "/"); i == 0 {
|
||||
return true
|
||||
if text != "" {
|
||||
if text[0] == '/' {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func CheckCommand(text string, entities []*TextEntity) string {
|
||||
if IsCommand(text) {
|
||||
cmd := text
|
||||
// e.g.: ["/hello@world_bot", "/hello@", "/hello@123"]
|
||||
// Result: "/hello"
|
||||
if i := strings.Index(text, "@"); i != -1 {
|
||||
return text[:i]
|
||||
}
|
||||
|
||||
// e.g. ["/hello 123", "/hell o 123"]
|
||||
// Result: "/hello", "/hell"
|
||||
if i := strings.Index(cmd, " "); i != -1 {
|
||||
cmd = cmd[:i]
|
||||
if i := strings.Index(text, " "); i != -1 {
|
||||
return text[:i]
|
||||
}
|
||||
|
||||
// e.g.: ["/hello@world_bot", "/hello@", "/hello@123"]
|
||||
// Result: "/hello"
|
||||
if i := strings.Index(cmd, "@"); i != -1 {
|
||||
cmd = cmd[:i]
|
||||
}
|
||||
|
||||
return cmd
|
||||
return text
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
|
|
|||
5936
client/function.go
5936
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 darwin CFLAGS: -I/usr/local/include
|
||||
//#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 -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 -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 -ltde2e -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 -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 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 windows LDFLAGS: -LE:/src/tdlib/build/Release -ltdjson
|
||||
//#include <stdlib.h>
|
||||
//#include <td/telegram/td_json_client.h>
|
||||
|
|
|
|||
13322
client/type.go
13322
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
Binary file not shown.
|
Before Width: | Height: | Size: 794 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 900 KiB |
|
|
@ -101,7 +101,7 @@ func main() {
|
|||
},
|
||||
InputMessageContent: &tdlib.InputMessagePhoto{
|
||||
Photo: &tdlib.InputFileLocal{
|
||||
Path: "./Meru_01.png",
|
||||
Path: "./myht9-1486821485193084928.jpg",
|
||||
},
|
||||
Caption: text,
|
||||
},
|
||||
|
|
@ -123,13 +123,13 @@ func main() {
|
|||
InputMessageContents: []tdlib.InputMessageContent{
|
||||
&tdlib.InputMessagePhoto{
|
||||
Photo: &tdlib.InputFileLocal{
|
||||
Path: "./Meru_01.png",
|
||||
Path: "./myht9-1486821485193084928.jpg",
|
||||
},
|
||||
Caption: text,
|
||||
},
|
||||
&tdlib.InputMessagePhoto{
|
||||
Photo: &tdlib.InputFileLocal{
|
||||
Path: "./Meru_02.png",
|
||||
Path: "./hisagi_02-1486983199280738309.jpg",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
BIN
example/media/hisagi_02-1486983199280738309.jpg
Normal file
BIN
example/media/hisagi_02-1486983199280738309.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 153 KiB |
BIN
example/media/myht9-1486821485193084928.jpg
Normal file
BIN
example/media/myht9-1486821485193084928.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 116 KiB |
Loading…
Add table
Add a link
Reference in a new issue