{"action":"created","comment":{"url":"https://api.github.com/repos/hackforgood-noname/bairrobot/pulls/comments/128925022","pull_request_review_id":51648703,"id":128925022,"diff_hunk":"@@ -0,0 +1,62 @@\n+require 'bairrobot/repositories/in_memory_session'\n+\n+module Bairrobot\n+  class MessageProcessor\n+    private\n+\n+    attr_accessor :session_repository\n+\n+    HELLO_MESSAGE = [\n+      \"مرحبا بكم في لوكالنوسبوت! يرجى تحديد لغتك.\",\n+      \"Bem vindo ao localnewsbot! Por favor escolhe a tua língua.\",\n+      \"Welcome to localnewsbot! Please select your language.\",\n+    ].join(\"\\n\").freeze\n+\n+    public\n+\n+    def initialize(environment = {})\n+      @session_repository = environment[:session_repository] || Bairrobot::Repositories::InMemorySession.new","path":"lib/bairrobot/message_processor.rb","position":18,"original_position":18,"commit_id":"3b275491ebedf1dc52211af8fd9cb92365e63468","original_commit_id":"3b275491ebedf1dc52211af8fd9cb92365e63468","user":{"login":"jcmfernandes","id":1144866,"avatar_url":"https://avatars1.githubusercontent.com/u/1144866?v=4","gravatar_id":"","url":"https://api.github.com/users/jcmfernandes","html_url":"https://github.com/jcmfernandes","followers_url":"https://api.github.com/users/jcmfernandes/followers","following_url":"https://api.github.com/users/jcmfernandes/following{/other_user}","gists_url":"https://api.github.com/users/jcmfernandes/gists{/gist_id}","starred_url":"https://api.github.com/users/jcmfernandes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcmfernandes/subscriptions","organizations_url":"https://api.github.com/users/jcmfernandes/orgs","repos_url":"https://api.github.com/users/jcmfernandes/repos","events_url":"https://api.github.com/users/jcmfernandes/events{/privacy}","received_events_url":"https://api.github.com/users/jcmfernandes/received_events","type":"User","site_admin":false},"body":"Either we ditch `dry-auto_inject` and ditch that part of the boilerplate, or we make use of it.","created_at":"2017-07-23T17:31:19Z","updated_at":"2017-07-23T17:35:15Z","html_url":"https://github.com/hackforgood-noname/bairrobot/pull/4#discussion_r128925022","pull_request_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/hackforgood-noname/bairrobot/pulls/comments/128925022"},"html":{"href":"https://github.com/hackforgood-noname/bairrobot/pull/4#discussion_r128925022"},"pull_request":{"href":"https://api.github.com/repos/hackforgood-noname/bairrobot/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/hackforgood-noname/bairrobot/pulls/4","id":131908083,"html_url":"https://github.com/hackforgood-noname/bairrobot/pull/4","diff_url":"https://github.com/hackforgood-noname/bairrobot/pull/4.diff","patch_url":"https://github.com/hackforgood-noname/bairrobot/pull/4.patch","issue_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/issues/4","number":4,"state":"open","locked":false,"title":"Start application with a simple telegram endpoint","user":{"login":"ivoanjo","id":2785847,"avatar_url":"https://avatars2.githubusercontent.com/u/2785847?v=4","gravatar_id":"","url":"https://api.github.com/users/ivoanjo","html_url":"https://github.com/ivoanjo","followers_url":"https://api.github.com/users/ivoanjo/followers","following_url":"https://api.github.com/users/ivoanjo/following{/other_user}","gists_url":"https://api.github.com/users/ivoanjo/gists{/gist_id}","starred_url":"https://api.github.com/users/ivoanjo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ivoanjo/subscriptions","organizations_url":"https://api.github.com/users/ivoanjo/orgs","repos_url":"https://api.github.com/users/ivoanjo/repos","events_url":"https://api.github.com/users/ivoanjo/events{/privacy}","received_events_url":"https://api.github.com/users/ivoanjo/received_events","type":"User","site_admin":false},"body":"This albeit incomplete and slightly hackish PR gets us as far as being able to process the first hello message from a user, asking for her language, and then just replying with some fixed message.\r\n\r\nAdding the first parts of the architecture with no defined architecture is always a bit hard, so I struggled a bit and:\r\n* We still need to fix the dependency injection\r\n* We still need to inject the logger\r\n* We still need to add some domain entities (e.g. session and message) that I got away with representing only as messages for now\r\n* We still need to add some quick documentation explaining how to create a telegram bot and get the token. If you need to test and don't want to bother creating one, ping me for one of the keys I have.\r\n\r\nI was thinking that we could avoid the usual mistake of doing request/response and instead we could have several actors/threads that would serve as the endpoints, that would then call to a message processor and pass it some kind of object (currently only a proc) that the message processor could, at its own leisure, use to respond to the message.\r\n\r\nThat way we fully decouple:\r\n* message reception\r\n* message processing\r\n* message sending\r\n\r\nFeedback is very welcome on this one!","created_at":"2017-07-22T18:17:22Z","updated_at":"2017-07-23T17:35:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"05ee918875b199c5fe9142c599afd650423e4442","assignee":null,"assignees":[],"requested_reviewers":[{"login":"tadassce","id":234778,"avatar_url":"https://avatars2.githubusercontent.com/u/234778?v=4","gravatar_id":"","url":"https://api.github.com/users/tadassce","html_url":"https://github.com/tadassce","followers_url":"https://api.github.com/users/tadassce/followers","following_url":"https://api.github.com/users/tadassce/following{/other_user}","gists_url":"https://api.github.com/users/tadassce/gists{/gist_id}","starred_url":"https://api.github.com/users/tadassce/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tadassce/subscriptions","organizations_url":"https://api.github.com/users/tadassce/orgs","repos_url":"https://api.github.com/users/tadassce/repos","events_url":"https://api.github.com/users/tadassce/events{/privacy}","received_events_url":"https://api.github.com/users/tadassce/received_events","type":"User","site_admin":false},{"login":"cfonseca","id":464366,"avatar_url":"https://avatars1.githubusercontent.com/u/464366?v=4","gravatar_id":"","url":"https://api.github.com/users/cfonseca","html_url":"https://github.com/cfonseca","followers_url":"https://api.github.com/users/cfonseca/followers","following_url":"https://api.github.com/users/cfonseca/following{/other_user}","gists_url":"https://api.github.com/users/cfonseca/gists{/gist_id}","starred_url":"https://api.github.com/users/cfonseca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cfonseca/subscriptions","organizations_url":"https://api.github.com/users/cfonseca/orgs","repos_url":"https://api.github.com/users/cfonseca/repos","events_url":"https://api.github.com/users/cfonseca/events{/privacy}","received_events_url":"https://api.github.com/users/cfonseca/received_events","type":"User","site_admin":false},{"login":"axfcampos","id":5682801,"avatar_url":"https://avatars0.githubusercontent.com/u/5682801?v=4","gravatar_id":"","url":"https://api.github.com/users/axfcampos","html_url":"https://github.com/axfcampos","followers_url":"https://api.github.com/users/axfcampos/followers","following_url":"https://api.github.com/users/axfcampos/following{/other_user}","gists_url":"https://api.github.com/users/axfcampos/gists{/gist_id}","starred_url":"https://api.github.com/users/axfcampos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/axfcampos/subscriptions","organizations_url":"https://api.github.com/users/axfcampos/orgs","repos_url":"https://api.github.com/users/axfcampos/repos","events_url":"https://api.github.com/users/axfcampos/events{/privacy}","received_events_url":"https://api.github.com/users/axfcampos/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/pulls/4/commits","review_comments_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/pulls/4/comments","review_comment_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/issues/4/comments","statuses_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/statuses/3b275491ebedf1dc52211af8fd9cb92365e63468","head":{"label":"hackforgood-noname:add-simple-telegram-endpoint","ref":"add-simple-telegram-endpoint","sha":"3b275491ebedf1dc52211af8fd9cb92365e63468","user":{"login":"hackforgood-noname","id":29681036,"avatar_url":"https://avatars1.githubusercontent.com/u/29681036?v=4","gravatar_id":"","url":"https://api.github.com/users/hackforgood-noname","html_url":"https://github.com/hackforgood-noname","followers_url":"https://api.github.com/users/hackforgood-noname/followers","following_url":"https://api.github.com/users/hackforgood-noname/following{/other_user}","gists_url":"https://api.github.com/users/hackforgood-noname/gists{/gist_id}","starred_url":"https://api.github.com/users/hackforgood-noname/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hackforgood-noname/subscriptions","organizations_url":"https://api.github.com/users/hackforgood-noname/orgs","repos_url":"https://api.github.com/users/hackforgood-noname/repos","events_url":"https://api.github.com/users/hackforgood-noname/events{/privacy}","received_events_url":"https://api.github.com/users/hackforgood-noname/received_events","type":"Organization","site_admin":false},"repo":{"id":96474325,"name":"bairrobot","full_name":"hackforgood-noname/bairrobot","owner":{"login":"hackforgood-noname","id":29681036,"avatar_url":"https://avatars1.githubusercontent.com/u/29681036?v=4","gravatar_id":"","url":"https://api.github.com/users/hackforgood-noname","html_url":"https://github.com/hackforgood-noname","followers_url":"https://api.github.com/users/hackforgood-noname/followers","following_url":"https://api.github.com/users/hackforgood-noname/following{/other_user}","gists_url":"https://api.github.com/users/hackforgood-noname/gists{/gist_id}","starred_url":"https://api.github.com/users/hackforgood-noname/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hackforgood-noname/subscriptions","organizations_url":"https://api.github.com/users/hackforgood-noname/orgs","repos_url":"https://api.github.com/users/hackforgood-noname/repos","events_url":"https://api.github.com/users/hackforgood-noname/events{/privacy}","received_events_url":"https://api.github.com/users/hackforgood-noname/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hackforgood-noname/bairrobot","description":"Your friendly neighbourhood local news chatbot","fork":false,"url":"https://api.github.com/repos/hackforgood-noname/bairrobot","forks_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/forks","keys_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/teams","hooks_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/hooks","issue_events_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/issues/events{/number}","events_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/events","assignees_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/assignees{/user}","branches_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/branches{/branch}","tags_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/tags","blobs_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/git/refs{/sha}","trees_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/statuses/{sha}","languages_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/languages","stargazers_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/stargazers","contributors_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/contributors","subscribers_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/subscribers","subscription_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/subscription","commits_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/commits{/sha}","git_commits_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/git/commits{/sha}","comments_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/comments{/number}","issue_comment_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/issues/comments{/number}","contents_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/contents/{+path}","compare_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/merges","archive_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/downloads","issues_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/issues{/number}","pulls_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/pulls{/number}","milestones_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/milestones{/number}","notifications_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/labels{/name}","releases_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/releases{/id}","deployments_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/deployments","created_at":"2017-07-06T21:42:01Z","updated_at":"2017-07-20T10:57:10Z","pushed_at":"2017-07-22T18:17:23Z","git_url":"git://github.com/hackforgood-noname/bairrobot.git","ssh_url":"git@github.com:hackforgood-noname/bairrobot.git","clone_url":"https://github.com/hackforgood-noname/bairrobot.git","svn_url":"https://github.com/hackforgood-noname/bairrobot","homepage":null,"size":30,"stargazers_count":2,"watchers_count":2,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":2,"default_branch":"master"}},"base":{"label":"hackforgood-noname:master","ref":"master","sha":"b9ef5d7900ad780285447f56d8d42783d753be45","user":{"login":"hackforgood-noname","id":29681036,"avatar_url":"https://avatars1.githubusercontent.com/u/29681036?v=4","gravatar_id":"","url":"https://api.github.com/users/hackforgood-noname","html_url":"https://github.com/hackforgood-noname","followers_url":"https://api.github.com/users/hackforgood-noname/followers","following_url":"https://api.github.com/users/hackforgood-noname/following{/other_user}","gists_url":"https://api.github.com/users/hackforgood-noname/gists{/gist_id}","starred_url":"https://api.github.com/users/hackforgood-noname/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hackforgood-noname/subscriptions","organizations_url":"https://api.github.com/users/hackforgood-noname/orgs","repos_url":"https://api.github.com/users/hackforgood-noname/repos","events_url":"https://api.github.com/users/hackforgood-noname/events{/privacy}","received_events_url":"https://api.github.com/users/hackforgood-noname/received_events","type":"Organization","site_admin":false},"repo":{"id":96474325,"name":"bairrobot","full_name":"hackforgood-noname/bairrobot","owner":{"login":"hackforgood-noname","id":29681036,"avatar_url":"https://avatars1.githubusercontent.com/u/29681036?v=4","gravatar_id":"","url":"https://api.github.com/users/hackforgood-noname","html_url":"https://github.com/hackforgood-noname","followers_url":"https://api.github.com/users/hackforgood-noname/followers","following_url":"https://api.github.com/users/hackforgood-noname/following{/other_user}","gists_url":"https://api.github.com/users/hackforgood-noname/gists{/gist_id}","starred_url":"https://api.github.com/users/hackforgood-noname/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hackforgood-noname/subscriptions","organizations_url":"https://api.github.com/users/hackforgood-noname/orgs","repos_url":"https://api.github.com/users/hackforgood-noname/repos","events_url":"https://api.github.com/users/hackforgood-noname/events{/privacy}","received_events_url":"https://api.github.com/users/hackforgood-noname/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hackforgood-noname/bairrobot","description":"Your friendly neighbourhood local news chatbot","fork":false,"url":"https://api.github.com/repos/hackforgood-noname/bairrobot","forks_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/forks","keys_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/teams","hooks_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/hooks","issue_events_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/issues/events{/number}","events_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/events","assignees_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/assignees{/user}","branches_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/branches{/branch}","tags_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/tags","blobs_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/git/refs{/sha}","trees_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/statuses/{sha}","languages_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/languages","stargazers_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/stargazers","contributors_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/contributors","subscribers_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/subscribers","subscription_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/subscription","commits_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/commits{/sha}","git_commits_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/git/commits{/sha}","comments_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/comments{/number}","issue_comment_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/issues/comments{/number}","contents_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/contents/{+path}","compare_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/merges","archive_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/downloads","issues_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/issues{/number}","pulls_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/pulls{/number}","milestones_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/milestones{/number}","notifications_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/labels{/name}","releases_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/releases{/id}","deployments_url":"https://api.github.com/repos/hackforgood-noname/bairrobot/deployments","created_at":"2017-07-06T21:42:01Z","updated_at":"2017-07-20T10:57:10Z","pushed_at":"2017-07-22T18:17:23Z","git_url":"git://github.com/hackforgood-noname/bairrobot.git","ssh_url":"git@github.com:hackforgood-noname/bairrobot.git","clone_url":"https://github.com/hackforgood-noname/bairrobot.git","svn_url":"https://github.com/hackforgood-noname/bairrobot","homepage":null,"size":30,"stargazers_count":2,"watchers_count":2,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hackforgood-noname/bairrobot/pulls/4"},"html":{"href":"https://github.com/hackforgood-noname/bairrobot/pull/4"},"issue":{"href":"https://api.github.com/repos/hackforgood-noname/bairrobot/issues/4"},"comments":{"href":"https://api.github.com/repos/hackforgood-noname/bairrobot/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/hackforgood-noname/bairrobot/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/hackforgood-noname/bairrobot/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hackforgood-noname/bairrobot/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/hackforgood-noname/bairrobot/statuses/3b275491ebedf1dc52211af8fd9cb92365e63468"}}}}
{"actor":{"display_login":"jcmfernandes"}}