-
Notifications
You must be signed in to change notification settings - Fork 0
Dev/basic controller #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
f80e5c3
Add TDLib as git submodule
getcoffee420 bfbc78a
rebased main and dev/basic-controller
getcoffee420 2c39c96
added tg client interface
getcoffee420 5c65bc9
added auth controller
Kirtsuha eb6383b
added message sender controller
Kirtsuha b1b20ee
added chat getter controller
Kirtsuha 096b254
added message sender controller header
Kirtsuha fbe55fe
added chat history controllers
Kirtsuha e009579
added tests for auth controller
Kirtsuha 1a00508
added primitive ui facade
Kirtsuha 32565f0
added auth, added sending messages
getcoffee420 225cd0b
added auth in facade
Kirtsuha 9e35031
added chats controller to facade
Kirtsuha 95efba4
added history and sender controllers to facade
Kirtsuha fa0431f
fixed bugs on facade
Kirtsuha 4e04d06
updated main
Kirtsuha 6fdb203
updated cmake
Kirtsuha File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,25 +1,20 @@ | ||
| #include "../src/tgClient/ITgClient.hpp" | ||
| #include "../src/tgClient/TgClientTdlib.hpp" | ||
| // main/main.cpp | ||
| #include <iostream> | ||
|
|
||
| int main() { | ||
| TgClientTdlib a = TgClientTdlib(); | ||
| auto temp = a.check_status(); | ||
| #include "../src/tgClient/TgClientTdlib.hpp" | ||
| #include "../src/facade/TgClientFacade.h" | ||
|
|
||
| int main(int argc, char** argv) { | ||
| try { | ||
| TgClientTdlib client; | ||
| TgClientFacade facade(client); | ||
|
|
||
| std::cout << "waitingPhone " << (temp == TgClientTdlib::AuthState::WaitingPhone) << std::endl; | ||
| std::cout << "WaitingCode " << (temp == TgClientTdlib::AuthState::WaitingCode) << std::endl; | ||
| std::cout << "WaitingPassword " << (temp == TgClientTdlib::AuthState::WaitingPassword) << std::endl; | ||
| std::cout << "WaitingParameters " << (temp == TgClientTdlib::AuthState::WaitingTdlibParameters) << std::endl; | ||
| std::cout << "Ready " << (temp == TgClientTdlib::AuthState::Ready) << std::endl; | ||
| std::cout << "LogginOut " << (temp == TgClientTdlib::AuthState::LoggingOut) << std::endl; | ||
| std::cout << "error " << (temp == TgClientTdlib::AuthState::Error) << std::endl; | ||
| enum class AuthState { | ||
| WaitingPhone, | ||
| WaitingCode, | ||
| WaitingPassword, | ||
| WaitingTdlibParameters, | ||
| Ready, | ||
| LoggingOut, | ||
| Error, | ||
| }; | ||
| return facade.run(argc, argv); | ||
| } catch (const std::exception& e) { | ||
| std::cerr << "[tgcli] fatal error: " << e.what() << "\n"; | ||
| return 1; | ||
| } catch (...) { | ||
| std::cerr << "[tgcli] fatal error: unknown exception\n"; | ||
| return 1; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
|
|
||
|
|
||
| #include "ChatHistoryController.h" | ||
|
|
||
| ChatHistoryController::ChatHistoryController(ITgClient& client) | ||
| : tgClient(client), target_chat_id("") {} | ||
|
|
||
| void ChatHistoryController::set_target_chat_id(const std::string& chatId) { | ||
| target_chat_id = chatId; | ||
| } | ||
|
|
||
| std::string ChatHistoryController::get_target_chat_id() const { | ||
| return target_chat_id; | ||
| } | ||
|
|
||
| void ChatHistoryController::clear_target_chat_id() { | ||
| target_chat_id.clear(); | ||
| } | ||
|
|
||
| std::vector<ITgClient::Message> ChatHistoryController::get_target_chat_history(int limit) { | ||
| if (target_chat_id.empty()) { | ||
| return {}; | ||
| } | ||
| return tgClient.get_chat_history(target_chat_id, limit); | ||
| } | ||
|
|
||
| std::vector<ITgClient::Message> ChatHistoryController::get_chat_history(const std::string& chatId, int limit) { | ||
| return tgClient.get_chat_history(chatId, limit); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| #pragma once | ||
| #include <string> | ||
| #include <vector> | ||
| #include "../tgClient/ITgClient.hpp" | ||
|
|
||
| class ChatHistoryController { | ||
| private: | ||
| ITgClient& tgClient; | ||
| std::string target_chat_id; | ||
|
|
||
| public: | ||
| explicit ChatHistoryController(ITgClient& client); | ||
|
|
||
| ChatHistoryController(const ChatHistoryController&) = delete; | ||
| ChatHistoryController& operator=(const ChatHistoryController) = delete; | ||
|
|
||
| ~ChatHistoryController() = default; | ||
|
|
||
| void set_target_chat_id(const std::string& chatId); | ||
|
|
||
| std::string get_target_chat_id() const; | ||
|
|
||
| void clear_target_chat_id(); | ||
|
|
||
| std::vector<ITgClient::Message> get_target_chat_history(int limit = 20); | ||
|
|
||
| std::vector<ITgClient::Message> get_chat_history(const std::string& chatId, int limit = 20); | ||
|
|
||
| }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.