{"action":"created","comment":{"url":"https://api.github.com/repos/drucoder/letsCodeBot/pulls/comments/195653000","pull_request_review_id":129064869,"id":195653000,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5NTY1MzAwMA==","diff_hunk":"@@ -13,46 +16,97 @@\n import org.telegram.telegrambots.bots.TelegramLongPollingBot;\n import org.telegram.telegrambots.exceptions.TelegramApiException;\n \n+import java.util.List;\n+\n+/**\n+ * TODO: Бот сохраняет в Базу не только сообщение пользователя но и своё сообщение!?\n+ */\n @Component\n @Slf4j\n public class LetsCodeBot extends TelegramLongPollingBot {\n     private static final String BOT_TOKEN = \"BOT_TOKEN\";\n     private static final String BOT_NAME = \"BOT_NAME\";\n \n-    private final MessageService messageService;\n+    private MessageService messageService;\n+    private KeyboardReply keyboardReply;\n+    private ButtonService buttonService;\n \n     @Autowired\n-    public LetsCodeBot(MessageService messageService) {\n+    public LetsCodeBot(MessageService messageService,\n+                       KeyboardReply keyboardReply,\n+                       ButtonService buttonService) {\n         this.messageService = messageService;\n+        this.keyboardReply = keyboardReply;\n+        this.buttonService = buttonService;\n+    }\n+\n+    public LetsCodeBot() {\n+\n     }\n \n+\n     public void onUpdateReceived(Update update) {\n         BotApiMethod message = null;\n         BotMessage botMessage = null;\n+        SendMessage sendMessage = null;\n+\n         boolean isIncoming = update.hasMessage() && update.getMessage().hasText();\n \n         if (isIncoming) {\n-            botMessage = messageService.saveIncoming(update.getMessage());\n+            Message receiveMessage = update.getMessage();\n+\n+            boolean isStarting = receiveMessage.getText().toLowerCase().equals(\"/start\");\n+            if (isStarting) {\n+\n+                send(createMessage(receiveMessage, \"Привет, \" + receiveMessage.getFrom().getFirstName() + \"!!!\"));\n+            }\n+            /*\n+            Проверяем приходящее сообщение является ли это командой с кнопки.\n+             */\n+            boolean isBottomButtonsPressed = Buttons.get(receiveMessage.getText())!=null && !update.hasCallbackQuery();\n+\n+            if (isBottomButtonsPressed) {\n+                buttonService.getData(receiveMessage, receiveMessage.getText());\n+            }\n+\n+            /*\n+            Проверяем является ли сообщение вопросом для сохранения в базу.\n+             */\n+            boolean isQuestions = receiveMessage.getText().substring(0,1).equals(\"?\");\n+\n+            if (isQuestions) {\n+                messageService.saveIncoming(receiveMessage);\n+                send(createMessage(receiveMessage,\"Ваш вопрос был сохранён, вы можете его найти в разделе мои вопросы.\"));\n+\n+            }\n+            /*\n+            Проверяем сообщение, является ли оно ответом\n+             */\n+            boolean isAnswer = (receiveMessage.getReplyToMessage()!=null);","path":"src/main/java/letscode/telegrambot/bot/LetsCodeBot.java","position":83,"original_position":83,"commit_id":"f66ed5197b4931ef998653ecd022b1cfbc6b4164","original_commit_id":"f66ed5197b4931ef998653ecd022b1cfbc6b4164","user":{"login":"nOy39","id":26793493,"node_id":"MDQ6VXNlcjI2NzkzNDkz","avatar_url":"https://avatars2.githubusercontent.com/u/26793493?v=4","gravatar_id":"","url":"https://api.github.com/users/nOy39","html_url":"https://github.com/nOy39","followers_url":"https://api.github.com/users/nOy39/followers","following_url":"https://api.github.com/users/nOy39/following{/other_user}","gists_url":"https://api.github.com/users/nOy39/gists{/gist_id}","starred_url":"https://api.github.com/users/nOy39/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nOy39/subscriptions","organizations_url":"https://api.github.com/users/nOy39/orgs","repos_url":"https://api.github.com/users/nOy39/repos","events_url":"https://api.github.com/users/nOy39/events{/privacy}","received_events_url":"https://api.github.com/users/nOy39/received_events","type":"User","site_admin":false},"body":"> а если это я отвечаю на твой вопрос \"какое бельгийское пиво вкуснее?\"?\r\n\r\nтогда он попробует из твоего сообщения дернуть ID и если найдет его, то сохранит в БД, если нет то выкинет ексепшн))) ну согласен, что есть не доработка... ","created_at":"2018-06-15T07:32:54Z","updated_at":"2018-06-15T07:32:54Z","html_url":"https://github.com/drucoder/letsCodeBot/pull/1#discussion_r195653000","pull_request_url":"https://api.github.com/repos/drucoder/letsCodeBot/pulls/1","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/drucoder/letsCodeBot/pulls/comments/195653000"},"html":{"href":"https://github.com/drucoder/letsCodeBot/pull/1#discussion_r195653000"},"pull_request":{"href":"https://api.github.com/repos/drucoder/letsCodeBot/pulls/1"}},"in_reply_to_id":195415558},"pull_request":{"url":"https://api.github.com/repos/drucoder/letsCodeBot/pulls/1","id":194605944,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk0NjA1OTQ0","html_url":"https://github.com/drucoder/letsCodeBot/pull/1","diff_url":"https://github.com/drucoder/letsCodeBot/pull/1.diff","patch_url":"https://github.com/drucoder/letsCodeBot/pull/1.patch","issue_url":"https://api.github.com/repos/drucoder/letsCodeBot/issues/1","number":1,"state":"open","locked":false,"title":"Adding questions to base","user":{"login":"nOy39","id":26793493,"node_id":"MDQ6VXNlcjI2NzkzNDkz","avatar_url":"https://avatars2.githubusercontent.com/u/26793493?v=4","gravatar_id":"","url":"https://api.github.com/users/nOy39","html_url":"https://github.com/nOy39","followers_url":"https://api.github.com/users/nOy39/followers","following_url":"https://api.github.com/users/nOy39/following{/other_user}","gists_url":"https://api.github.com/users/nOy39/gists{/gist_id}","starred_url":"https://api.github.com/users/nOy39/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nOy39/subscriptions","organizations_url":"https://api.github.com/users/nOy39/orgs","repos_url":"https://api.github.com/users/nOy39/repos","events_url":"https://api.github.com/users/nOy39/events{/privacy}","received_events_url":"https://api.github.com/users/nOy39/received_events","type":"User","site_admin":false},"body":"Сделал добавление вопроса из телеграма при установке в теле вопроса знака вопроса, 4 кнопки внизу чата, открывание списка нерешенных вопросов с кнопки \"открыть список вопросов\", вопросы открываются списков, каждый вопрос отдельным сообщением с заголовком не более 50 символов, и кнопкой \"открыть вопрос\" при нажатии на кнопку вопрос приходит сообщение с полным текстом вопроса, у автора вопроса есть кнопка \"закрыть вопрос\"","created_at":"2018-06-13T14:27:29Z","updated_at":"2018-06-15T07:32:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"abbbccb93693c0e778ac26ef9f6a113571f74374","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/drucoder/letsCodeBot/pulls/1/commits","review_comments_url":"https://api.github.com/repos/drucoder/letsCodeBot/pulls/1/comments","review_comment_url":"https://api.github.com/repos/drucoder/letsCodeBot/pulls/comments{/number}","comments_url":"https://api.github.com/repos/drucoder/letsCodeBot/issues/1/comments","statuses_url":"https://api.github.com/repos/drucoder/letsCodeBot/statuses/f66ed5197b4931ef998653ecd022b1cfbc6b4164","head":{"label":"nOy39:adding_questions_to_base","ref":"adding_questions_to_base","sha":"f66ed5197b4931ef998653ecd022b1cfbc6b4164","user":{"login":"nOy39","id":26793493,"node_id":"MDQ6VXNlcjI2NzkzNDkz","avatar_url":"https://avatars2.githubusercontent.com/u/26793493?v=4","gravatar_id":"","url":"https://api.github.com/users/nOy39","html_url":"https://github.com/nOy39","followers_url":"https://api.github.com/users/nOy39/followers","following_url":"https://api.github.com/users/nOy39/following{/other_user}","gists_url":"https://api.github.com/users/nOy39/gists{/gist_id}","starred_url":"https://api.github.com/users/nOy39/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nOy39/subscriptions","organizations_url":"https://api.github.com/users/nOy39/orgs","repos_url":"https://api.github.com/users/nOy39/repos","events_url":"https://api.github.com/users/nOy39/events{/privacy}","received_events_url":"https://api.github.com/users/nOy39/received_events","type":"User","site_admin":false},"repo":{"id":137109630,"node_id":"MDEwOlJlcG9zaXRvcnkxMzcxMDk2MzA=","name":"letsCodeBot","full_name":"nOy39/letsCodeBot","owner":{"login":"nOy39","id":26793493,"node_id":"MDQ6VXNlcjI2NzkzNDkz","avatar_url":"https://avatars2.githubusercontent.com/u/26793493?v=4","gravatar_id":"","url":"https://api.github.com/users/nOy39","html_url":"https://github.com/nOy39","followers_url":"https://api.github.com/users/nOy39/followers","following_url":"https://api.github.com/users/nOy39/following{/other_user}","gists_url":"https://api.github.com/users/nOy39/gists{/gist_id}","starred_url":"https://api.github.com/users/nOy39/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nOy39/subscriptions","organizations_url":"https://api.github.com/users/nOy39/orgs","repos_url":"https://api.github.com/users/nOy39/repos","events_url":"https://api.github.com/users/nOy39/events{/privacy}","received_events_url":"https://api.github.com/users/nOy39/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nOy39/letsCodeBot","description":null,"fork":true,"url":"https://api.github.com/repos/nOy39/letsCodeBot","forks_url":"https://api.github.com/repos/nOy39/letsCodeBot/forks","keys_url":"https://api.github.com/repos/nOy39/letsCodeBot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nOy39/letsCodeBot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nOy39/letsCodeBot/teams","hooks_url":"https://api.github.com/repos/nOy39/letsCodeBot/hooks","issue_events_url":"https://api.github.com/repos/nOy39/letsCodeBot/issues/events{/number}","events_url":"https://api.github.com/repos/nOy39/letsCodeBot/events","assignees_url":"https://api.github.com/repos/nOy39/letsCodeBot/assignees{/user}","branches_url":"https://api.github.com/repos/nOy39/letsCodeBot/branches{/branch}","tags_url":"https://api.github.com/repos/nOy39/letsCodeBot/tags","blobs_url":"https://api.github.com/repos/nOy39/letsCodeBot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nOy39/letsCodeBot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nOy39/letsCodeBot/git/refs{/sha}","trees_url":"https://api.github.com/repos/nOy39/letsCodeBot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nOy39/letsCodeBot/statuses/{sha}","languages_url":"https://api.github.com/repos/nOy39/letsCodeBot/languages","stargazers_url":"https://api.github.com/repos/nOy39/letsCodeBot/stargazers","contributors_url":"https://api.github.com/repos/nOy39/letsCodeBot/contributors","subscribers_url":"https://api.github.com/repos/nOy39/letsCodeBot/subscribers","subscription_url":"https://api.github.com/repos/nOy39/letsCodeBot/subscription","commits_url":"https://api.github.com/repos/nOy39/letsCodeBot/commits{/sha}","git_commits_url":"https://api.github.com/repos/nOy39/letsCodeBot/git/commits{/sha}","comments_url":"https://api.github.com/repos/nOy39/letsCodeBot/comments{/number}","issue_comment_url":"https://api.github.com/repos/nOy39/letsCodeBot/issues/comments{/number}","contents_url":"https://api.github.com/repos/nOy39/letsCodeBot/contents/{+path}","compare_url":"https://api.github.com/repos/nOy39/letsCodeBot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nOy39/letsCodeBot/merges","archive_url":"https://api.github.com/repos/nOy39/letsCodeBot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nOy39/letsCodeBot/downloads","issues_url":"https://api.github.com/repos/nOy39/letsCodeBot/issues{/number}","pulls_url":"https://api.github.com/repos/nOy39/letsCodeBot/pulls{/number}","milestones_url":"https://api.github.com/repos/nOy39/letsCodeBot/milestones{/number}","notifications_url":"https://api.github.com/repos/nOy39/letsCodeBot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nOy39/letsCodeBot/labels{/name}","releases_url":"https://api.github.com/repos/nOy39/letsCodeBot/releases{/id}","deployments_url":"https://api.github.com/repos/nOy39/letsCodeBot/deployments","created_at":"2018-06-12T18:03:31Z","updated_at":"2018-06-12T18:03:33Z","pushed_at":"2018-06-14T10:38:48Z","git_url":"git://github.com/nOy39/letsCodeBot.git","ssh_url":"git@github.com:nOy39/letsCodeBot.git","clone_url":"https://github.com/nOy39/letsCodeBot.git","svn_url":"https://github.com/nOy39/letsCodeBot","homepage":null,"size":25,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"drucoder:master","ref":"master","sha":"967bef9f26e9859d2a7723c92615310a89b58a97","user":{"login":"drucoder","id":16634404,"node_id":"MDQ6VXNlcjE2NjM0NDA0","avatar_url":"https://avatars3.githubusercontent.com/u/16634404?v=4","gravatar_id":"","url":"https://api.github.com/users/drucoder","html_url":"https://github.com/drucoder","followers_url":"https://api.github.com/users/drucoder/followers","following_url":"https://api.github.com/users/drucoder/following{/other_user}","gists_url":"https://api.github.com/users/drucoder/gists{/gist_id}","starred_url":"https://api.github.com/users/drucoder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drucoder/subscriptions","organizations_url":"https://api.github.com/users/drucoder/orgs","repos_url":"https://api.github.com/users/drucoder/repos","events_url":"https://api.github.com/users/drucoder/events{/privacy}","received_events_url":"https://api.github.com/users/drucoder/received_events","type":"User","site_admin":false},"repo":{"id":136208746,"node_id":"MDEwOlJlcG9zaXRvcnkxMzYyMDg3NDY=","name":"letsCodeBot","full_name":"drucoder/letsCodeBot","owner":{"login":"drucoder","id":16634404,"node_id":"MDQ6VXNlcjE2NjM0NDA0","avatar_url":"https://avatars3.githubusercontent.com/u/16634404?v=4","gravatar_id":"","url":"https://api.github.com/users/drucoder","html_url":"https://github.com/drucoder","followers_url":"https://api.github.com/users/drucoder/followers","following_url":"https://api.github.com/users/drucoder/following{/other_user}","gists_url":"https://api.github.com/users/drucoder/gists{/gist_id}","starred_url":"https://api.github.com/users/drucoder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drucoder/subscriptions","organizations_url":"https://api.github.com/users/drucoder/orgs","repos_url":"https://api.github.com/users/drucoder/repos","events_url":"https://api.github.com/users/drucoder/events{/privacy}","received_events_url":"https://api.github.com/users/drucoder/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/drucoder/letsCodeBot","description":null,"fork":false,"url":"https://api.github.com/repos/drucoder/letsCodeBot","forks_url":"https://api.github.com/repos/drucoder/letsCodeBot/forks","keys_url":"https://api.github.com/repos/drucoder/letsCodeBot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/drucoder/letsCodeBot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/drucoder/letsCodeBot/teams","hooks_url":"https://api.github.com/repos/drucoder/letsCodeBot/hooks","issue_events_url":"https://api.github.com/repos/drucoder/letsCodeBot/issues/events{/number}","events_url":"https://api.github.com/repos/drucoder/letsCodeBot/events","assignees_url":"https://api.github.com/repos/drucoder/letsCodeBot/assignees{/user}","branches_url":"https://api.github.com/repos/drucoder/letsCodeBot/branches{/branch}","tags_url":"https://api.github.com/repos/drucoder/letsCodeBot/tags","blobs_url":"https://api.github.com/repos/drucoder/letsCodeBot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/drucoder/letsCodeBot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/drucoder/letsCodeBot/git/refs{/sha}","trees_url":"https://api.github.com/repos/drucoder/letsCodeBot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/drucoder/letsCodeBot/statuses/{sha}","languages_url":"https://api.github.com/repos/drucoder/letsCodeBot/languages","stargazers_url":"https://api.github.com/repos/drucoder/letsCodeBot/stargazers","contributors_url":"https://api.github.com/repos/drucoder/letsCodeBot/contributors","subscribers_url":"https://api.github.com/repos/drucoder/letsCodeBot/subscribers","subscription_url":"https://api.github.com/repos/drucoder/letsCodeBot/subscription","commits_url":"https://api.github.com/repos/drucoder/letsCodeBot/commits{/sha}","git_commits_url":"https://api.github.com/repos/drucoder/letsCodeBot/git/commits{/sha}","comments_url":"https://api.github.com/repos/drucoder/letsCodeBot/comments{/number}","issue_comment_url":"https://api.github.com/repos/drucoder/letsCodeBot/issues/comments{/number}","contents_url":"https://api.github.com/repos/drucoder/letsCodeBot/contents/{+path}","compare_url":"https://api.github.com/repos/drucoder/letsCodeBot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/drucoder/letsCodeBot/merges","archive_url":"https://api.github.com/repos/drucoder/letsCodeBot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/drucoder/letsCodeBot/downloads","issues_url":"https://api.github.com/repos/drucoder/letsCodeBot/issues{/number}","pulls_url":"https://api.github.com/repos/drucoder/letsCodeBot/pulls{/number}","milestones_url":"https://api.github.com/repos/drucoder/letsCodeBot/milestones{/number}","notifications_url":"https://api.github.com/repos/drucoder/letsCodeBot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/drucoder/letsCodeBot/labels{/name}","releases_url":"https://api.github.com/repos/drucoder/letsCodeBot/releases{/id}","deployments_url":"https://api.github.com/repos/drucoder/letsCodeBot/deployments","created_at":"2018-06-05T16:59:20Z","updated_at":"2018-06-12T17:36:17Z","pushed_at":"2018-06-14T10:38:49Z","git_url":"git://github.com/drucoder/letsCodeBot.git","ssh_url":"git@github.com:drucoder/letsCodeBot.git","clone_url":"https://github.com/drucoder/letsCodeBot.git","svn_url":"https://github.com/drucoder/letsCodeBot","homepage":null,"size":8,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":3,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/drucoder/letsCodeBot/pulls/1"},"html":{"href":"https://github.com/drucoder/letsCodeBot/pull/1"},"issue":{"href":"https://api.github.com/repos/drucoder/letsCodeBot/issues/1"},"comments":{"href":"https://api.github.com/repos/drucoder/letsCodeBot/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/drucoder/letsCodeBot/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/drucoder/letsCodeBot/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/drucoder/letsCodeBot/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/drucoder/letsCodeBot/statuses/f66ed5197b4931ef998653ecd022b1cfbc6b4164"}},"author_association":"NONE"}}
{"actor":{"display_login":"nOy39"}}