From 6ae3f83566b7ba158790cff35134f2fc2a2b009b Mon Sep 17 00:00:00 2001 From: c0re100 Date: Thu, 27 Jan 2022 08:22:40 +0800 Subject: [PATCH] No longer needed --- client/puller/chat.go | 52 ------------------------------- client/puller/chats.go | 62 ------------------------------------- client/puller/error.go | 7 ----- client/puller/supergroup.go | 53 ------------------------------- 4 files changed, 174 deletions(-) delete mode 100644 client/puller/chat.go delete mode 100644 client/puller/chats.go delete mode 100644 client/puller/error.go delete mode 100644 client/puller/supergroup.go diff --git a/client/puller/chat.go b/client/puller/chat.go deleted file mode 100644 index 82e15a0..0000000 --- a/client/puller/chat.go +++ /dev/null @@ -1,52 +0,0 @@ -package puller - -import ( - "github.com/c0re100/gotdlib/client" -) - -func ChatHistory(tdlibClient *client.Client, chatId int64) (chan *client.Message, chan error) { - messageChan := make(chan *client.Message, 10) - errChan := make(chan error, 1) - - var fromMessageId int64 = 0 - var offset int32 = 0 - var limit int32 = 100 - - go chatHistory(tdlibClient, messageChan, errChan, chatId, fromMessageId, offset, limit, false) - - return messageChan, errChan -} - -func chatHistory(tdlibClient *client.Client, messageChan chan *client.Message, errChan chan error, chatId int64, fromMessageId int64, offset int32, limit int32, onlyLocal bool) { - defer func() { - close(messageChan) - close(errChan) - }() - - for { - messages, err := tdlibClient.GetChatHistory(&client.GetChatHistoryRequest{ - ChatId: chatId, - FromMessageId: fromMessageId, - Offset: offset, - Limit: limit, - OnlyLocal: onlyLocal, - }) - if err != nil { - errChan <- err - - return - } - - if len(messages.Messages) == 0 { - errChan <- EOP - - break - } - - for _, message := range messages.Messages { - fromMessageId = message.Id - - messageChan <- message - } - } -} diff --git a/client/puller/chats.go b/client/puller/chats.go deleted file mode 100644 index afb4f45..0000000 --- a/client/puller/chats.go +++ /dev/null @@ -1,62 +0,0 @@ -package puller - -import ( - "math" - - "github.com/c0re100/gotdlib/client" -) - -func Chats(tdlibClient *client.Client) (chan *client.Chat, chan error) { - chatChan := make(chan *client.Chat, 10) - errChan := make(chan error, 1) - - var offsetOrder client.JsonInt64 = math.MaxInt64 - var offsetChatId int64 = 0 - var limit int32 = 100 - - go chats(tdlibClient, chatChan, errChan, offsetOrder, offsetChatId, limit) - - return chatChan, errChan -} - -func chats(tdlibClient *client.Client, chatChan chan *client.Chat, errChan chan error, offsetOrder client.JsonInt64, offsetChatId int64, limit int32) { - defer func() { - close(chatChan) - close(errChan) - }() - - for { - chats, err := tdlibClient.GetChats(&client.GetChatsRequest{ - OffsetOrder: offsetOrder, - OffsetChatId: offsetChatId, - Limit: limit, - }) - if err != nil { - errChan <- err - - return - } - - if len(chats.ChatIds) == 0 { - errChan <- EOP - - break - } - - for _, chatId := range chats.ChatIds { - chat, err := tdlibClient.GetChat(&client.GetChatRequest{ - ChatId: chatId, - }) - if err != nil { - errChan <- err - - return - } - - offsetOrder = chat.Order - offsetChatId = chat.Id - - chatChan <- chat - } - } -} diff --git a/client/puller/error.go b/client/puller/error.go deleted file mode 100644 index b82bd18..0000000 --- a/client/puller/error.go +++ /dev/null @@ -1,7 +0,0 @@ -package puller - -import ( - "errors" -) - -var EOP = errors.New("end of pull") diff --git a/client/puller/supergroup.go b/client/puller/supergroup.go deleted file mode 100644 index 5c42654..0000000 --- a/client/puller/supergroup.go +++ /dev/null @@ -1,53 +0,0 @@ -package puller - -import ( - "github.com/c0re100/gotdlib/client" -) - -func SupergroupMembers(tdlibClient *client.Client, supergroupId int64) (chan *client.ChatMember, chan error) { - chatMemberChan := make(chan *client.ChatMember, 10) - errChan := make(chan error, 1) - - var filter client.SupergroupMembersFilter = nil - var offset int32 = 0 - var limit int32 = 200 - - go supergroupMembers(tdlibClient, chatMemberChan, errChan, supergroupId, filter, offset, limit) - - return chatMemberChan, errChan -} - -func supergroupMembers(tdlibClient *client.Client, chatMemberChan chan *client.ChatMember, errChan chan error, supergroupId int64, filter client.SupergroupMembersFilter, offset int32, limit int32) { - defer func() { - close(chatMemberChan) - close(errChan) - }() - - var page int32 = 0 - - for { - chatMembers, err := tdlibClient.GetSupergroupMembers(&client.GetSupergroupMembersRequest{ - SupergroupId: supergroupId, - Filter: filter, - Offset: page*limit + offset, - Limit: limit, - }) - if err != nil { - errChan <- err - - return - } - - if len(chatMembers.Members) == 0 { - errChan <- EOP - - break - } - - for _, member := range chatMembers.Members { - chatMemberChan <- member - } - - page++ - } -}