{"action":"created","comment":{"url":"https://api.github.com/repos/akormushin/fizteh-java-2015/pulls/comments/41262193","id":41262193,"diff_hunk":"@@ -0,0 +1,186 @@\n+package ru.fizteh.fivt.students.roller145.TwitterStream;\n+\n+import com.beust.jcommander.JCommander;\n+import javafx.util.Pair;\n+import twitter4j.*;\n+\n+import java.io.IOException;\n+import java.util.List;\n+import java.util.Scanner;\n+import java.util.Timer;\n+import java.util.TimerTask;\n+\n+import static java.lang.Thread.sleep;\n+import static ru.fizteh.fivt.students.roller145.TwitterStream.GetGeolocation.getGeolocation;\n+import static ru.fizteh.fivt.students.roller145.TwitterStream.GetGeolocation.reCode;\n+import static ru.fizteh.fivt.students.roller145.TwitterStream.TimeMethods.MILISEC_IN_SEC;\n+import static ru.fizteh.fivt.students.roller145.TwitterStream.TimeMethods.printTime;\n+\n+public class TwitterStream {\n+\n+    public static void main(String[] args) throws Exception {\n+\n+        TwitterStreamParser twParse = new TwitterStreamParser();\n+        JCommander command = new JCommander(twParse, args);\n+        if (twParse.isHelpOn()) {\n+            printHelp(command);\n+        }\n+        if (twParse.isTweet()) {\n+            makeTweet();\n+        }\n+        if (twParse.isWhere()){\n+            reCode();\n+        }\n+        if (twParse.isStreamOn() && twParse.isLimit()) {\n+            System.out.println(\"Command conflict\");\n+            return;\n+        }\n+        if (twParse.isStreamOn()) {\n+            streamMode(twParse.isFilterRetweet(), twParse.getQueryWords(), twParse.getWhere(), twParse.isPlace());\n+        }\n+        if (twParse.isLimit()){\n+            limitedMode(twParse.isFilterRetweet(), twParse.getNumber(), twParse.getQueryWords(),twParse.getWhere(),twParse.isPlace());\n+        }\n+        return;\n+    }\n+\n+    public static final String ANSI_PURPLE = \"\\u001B[35m\";\n+    public static final String ANSI_RESET = \"\\u001B[0m\";\n+    public static final String UNIT_RADIUS = \"km\";\n+\n+    public static void printHelp(JCommander command){\n+        command.usage();\n+    }\n+\n+    public static void makeTweet() throws TwitterException {\n+        Twitter twitter = TwitterFactory.getSingleton();\n+        Scanner sc = new Scanner(System.in);\n+        String tweet;\n+        System.out.println(\"Your tweet: \");\n+        tweet = sc.nextLine();\n+        twitter.updateStatus(tweet);\n+    }\n+\n+    static void printName(String name){\n+        System.out.print(ANSI_PURPLE + \"@\" + name + \":\" + ANSI_RESET);\n+    }\n+    static void printTweet(Status tweet){\n+        printTime(tweet.getCreatedAt());\n+        printName(tweet.getUser().getScreenName());\n+        if (tweet.isRetweet()){\n+            System.out.print(\"retweeted \");\n+            String[] splited = tweet.getText().split(\" \");\n+            System.out.print(\n+                    \"@\" + ANSI_PURPLE + splited[1].split(\"@|:\")[1]\n+                            + ANSI_RESET + \": \");\n+            for (int i = 2; i < splited.length; ++i){\n+                System.out.print(splited[i]);\n+            }\n+            System.out.println();\n+        }\n+        else {\n+            System.out.println(tweet.getText() + \" (\" + tweet.getRetweetCount()\n+                            + \" retweet(s)\"+ \")\");\n+        }\n+\n+    }\n+\n+    private static void limitedMode(boolean filterRetweet, int numberOfTweets, String queryWords, String where, boolean isLocation) throws IOException {\n+        twitter4j.Twitter twitter = new TwitterFactory().getInstance();\n+        if (where == null && queryWords == null){\n+            System.out.println(\"Empty query\");\n+            return;\n+        }\n+        try {\n+            boolean isAnyTweets= false;\n+            Query query = new Query();\n+            if (queryWords == null){\n+                Pair<GeoLocation, Double> location = getGeolocation(where);\n+                query.setGeoCode(location.getKey(), location.getValue(), UNIT_RADIUS);\n+            }\n+            else {\n+                query.setQuery(queryWords);\n+                if (isLocation) {\n+                    Pair<GeoLocation, Double> location = getGeolocation(where);\n+                    query.setGeoCode(location.getKey(), location.getValue(), UNIT_RADIUS);\n+                    query.setCount(numberOfTweets);\n+                }\n+            }\n+            QueryResult result;\n+\n+            do {\n+                result = twitter.search(query);\n+                List<Status> tweets = result.getTweets();\n+                for (Status tweet : tweets) {\n+                    if (tweet.isRetweet() && !filterRetweet){\n+                        printTweet(tweet);\n+                        isAnyTweets = true;\n+                    }\n+                }\n+            } while ((query = result.nextQuery()) != null);\n+            if (!isAnyTweets) {\n+                System.out.println(\"\\nI can't find any tweets for the query \"\n+                                + queryWords + \" for \" +where\n+                                + \" \\n\\n\"\n+                                + \" Please, try to check spelling  or use more common worlds\\n\");\n+            }\n+            return;\n+        } catch (TwitterException te) {\n+            te.printStackTrace();\n+            System.out.println(\"Failed to search tweets: \" + te.getMessage());\n+            System.exit(-1);","path":"roller145/src/main/java/ru/fizteh/fivt/students/roller145/TwitterStream/TwitterStream.java","position":null,"original_position":131,"commit_id":"b7bda261b5dce5e22ab54bff16f58295801585ce","original_commit_id":"2e0a2a800f28204efb67d6f8b100faaa14d1e4a3","user":{"login":"roller145","id":8862299,"avatar_url":"https://avatars.githubusercontent.com/u/8862299?v=3","gravatar_id":"","url":"https://api.github.com/users/roller145","html_url":"https://github.com/roller145","followers_url":"https://api.github.com/users/roller145/followers","following_url":"https://api.github.com/users/roller145/following{/other_user}","gists_url":"https://api.github.com/users/roller145/gists{/gist_id}","starred_url":"https://api.github.com/users/roller145/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roller145/subscriptions","organizations_url":"https://api.github.com/users/roller145/orgs","repos_url":"https://api.github.com/users/roller145/repos","events_url":"https://api.github.com/users/roller145/events{/privacy}","received_events_url":"https://api.github.com/users/roller145/received_events","type":"User","site_admin":false},"body":"исправлено","created_at":"2015-10-06T13:22:56Z","updated_at":"2015-10-06T13:22:56Z","html_url":"https://github.com/akormushin/fizteh-java-2015/pull/62#discussion_r41262193","pull_request_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/pulls/62","_links":{"self":{"href":"https://api.github.com/repos/akormushin/fizteh-java-2015/pulls/comments/41262193"},"html":{"href":"https://github.com/akormushin/fizteh-java-2015/pull/62#discussion_r41262193"},"pull_request":{"href":"https://api.github.com/repos/akormushin/fizteh-java-2015/pulls/62"}}},"pull_request":{"url":"https://api.github.com/repos/akormushin/fizteh-java-2015/pulls/62","id":46187929,"html_url":"https://github.com/akormushin/fizteh-java-2015/pull/62","diff_url":"https://github.com/akormushin/fizteh-java-2015/pull/62.diff","patch_url":"https://github.com/akormushin/fizteh-java-2015/pull/62.patch","issue_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/issues/62","number":62,"state":"open","locked":false,"title":"Руденко Ирина, 494,TwitterStream","user":{"login":"roller145","id":8862299,"avatar_url":"https://avatars.githubusercontent.com/u/8862299?v=3","gravatar_id":"","url":"https://api.github.com/users/roller145","html_url":"https://github.com/roller145","followers_url":"https://api.github.com/users/roller145/followers","following_url":"https://api.github.com/users/roller145/following{/other_user}","gists_url":"https://api.github.com/users/roller145/gists{/gist_id}","starred_url":"https://api.github.com/users/roller145/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roller145/subscriptions","organizations_url":"https://api.github.com/users/roller145/orgs","repos_url":"https://api.github.com/users/roller145/repos","events_url":"https://api.github.com/users/roller145/events{/privacy}","received_events_url":"https://api.github.com/users/roller145/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-09-28T18:01:37Z","updated_at":"2015-10-06T13:22:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4952157b119c55fa16e3a01c47540b9cffa6c563","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/pulls/62/commits","review_comments_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/pulls/62/comments","review_comment_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/pulls/comments{/number}","comments_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/issues/62/comments","statuses_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/statuses/b7bda261b5dce5e22ab54bff16f58295801585ce","head":{"label":"roller145:master","ref":"master","sha":"b7bda261b5dce5e22ab54bff16f58295801585ce","user":{"login":"roller145","id":8862299,"avatar_url":"https://avatars.githubusercontent.com/u/8862299?v=3","gravatar_id":"","url":"https://api.github.com/users/roller145","html_url":"https://github.com/roller145","followers_url":"https://api.github.com/users/roller145/followers","following_url":"https://api.github.com/users/roller145/following{/other_user}","gists_url":"https://api.github.com/users/roller145/gists{/gist_id}","starred_url":"https://api.github.com/users/roller145/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roller145/subscriptions","organizations_url":"https://api.github.com/users/roller145/orgs","repos_url":"https://api.github.com/users/roller145/repos","events_url":"https://api.github.com/users/roller145/events{/privacy}","received_events_url":"https://api.github.com/users/roller145/received_events","type":"User","site_admin":false},"repo":{"id":42395504,"name":"fizteh-java-2015","full_name":"roller145/fizteh-java-2015","owner":{"login":"roller145","id":8862299,"avatar_url":"https://avatars.githubusercontent.com/u/8862299?v=3","gravatar_id":"","url":"https://api.github.com/users/roller145","html_url":"https://github.com/roller145","followers_url":"https://api.github.com/users/roller145/followers","following_url":"https://api.github.com/users/roller145/following{/other_user}","gists_url":"https://api.github.com/users/roller145/gists{/gist_id}","starred_url":"https://api.github.com/users/roller145/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roller145/subscriptions","organizations_url":"https://api.github.com/users/roller145/orgs","repos_url":"https://api.github.com/users/roller145/repos","events_url":"https://api.github.com/users/roller145/events{/privacy}","received_events_url":"https://api.github.com/users/roller145/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/roller145/fizteh-java-2015","description":"","fork":true,"url":"https://api.github.com/repos/roller145/fizteh-java-2015","forks_url":"https://api.github.com/repos/roller145/fizteh-java-2015/forks","keys_url":"https://api.github.com/repos/roller145/fizteh-java-2015/keys{/key_id}","collaborators_url":"https://api.github.com/repos/roller145/fizteh-java-2015/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/roller145/fizteh-java-2015/teams","hooks_url":"https://api.github.com/repos/roller145/fizteh-java-2015/hooks","issue_events_url":"https://api.github.com/repos/roller145/fizteh-java-2015/issues/events{/number}","events_url":"https://api.github.com/repos/roller145/fizteh-java-2015/events","assignees_url":"https://api.github.com/repos/roller145/fizteh-java-2015/assignees{/user}","branches_url":"https://api.github.com/repos/roller145/fizteh-java-2015/branches{/branch}","tags_url":"https://api.github.com/repos/roller145/fizteh-java-2015/tags","blobs_url":"https://api.github.com/repos/roller145/fizteh-java-2015/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/roller145/fizteh-java-2015/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/roller145/fizteh-java-2015/git/refs{/sha}","trees_url":"https://api.github.com/repos/roller145/fizteh-java-2015/git/trees{/sha}","statuses_url":"https://api.github.com/repos/roller145/fizteh-java-2015/statuses/{sha}","languages_url":"https://api.github.com/repos/roller145/fizteh-java-2015/languages","stargazers_url":"https://api.github.com/repos/roller145/fizteh-java-2015/stargazers","contributors_url":"https://api.github.com/repos/roller145/fizteh-java-2015/contributors","subscribers_url":"https://api.github.com/repos/roller145/fizteh-java-2015/subscribers","subscription_url":"https://api.github.com/repos/roller145/fizteh-java-2015/subscription","commits_url":"https://api.github.com/repos/roller145/fizteh-java-2015/commits{/sha}","git_commits_url":"https://api.github.com/repos/roller145/fizteh-java-2015/git/commits{/sha}","comments_url":"https://api.github.com/repos/roller145/fizteh-java-2015/comments{/number}","issue_comment_url":"https://api.github.com/repos/roller145/fizteh-java-2015/issues/comments{/number}","contents_url":"https://api.github.com/repos/roller145/fizteh-java-2015/contents/{+path}","compare_url":"https://api.github.com/repos/roller145/fizteh-java-2015/compare/{base}...{head}","merges_url":"https://api.github.com/repos/roller145/fizteh-java-2015/merges","archive_url":"https://api.github.com/repos/roller145/fizteh-java-2015/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/roller145/fizteh-java-2015/downloads","issues_url":"https://api.github.com/repos/roller145/fizteh-java-2015/issues{/number}","pulls_url":"https://api.github.com/repos/roller145/fizteh-java-2015/pulls{/number}","milestones_url":"https://api.github.com/repos/roller145/fizteh-java-2015/milestones{/number}","notifications_url":"https://api.github.com/repos/roller145/fizteh-java-2015/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/roller145/fizteh-java-2015/labels{/name}","releases_url":"https://api.github.com/repos/roller145/fizteh-java-2015/releases{/id}","created_at":"2015-09-13T12:46:59Z","updated_at":"2015-09-13T15:19:26Z","pushed_at":"2015-10-06T13:20:38Z","git_url":"git://github.com/roller145/fizteh-java-2015.git","ssh_url":"git@github.com:roller145/fizteh-java-2015.git","clone_url":"https://github.com/roller145/fizteh-java-2015.git","svn_url":"https://github.com/roller145/fizteh-java-2015","homepage":null,"size":193,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"akormushin:master","ref":"master","sha":"9220bc40f3d4aba8e97f1e3230b8c9896f63e28c","user":{"login":"akormushin","id":1074038,"avatar_url":"https://avatars.githubusercontent.com/u/1074038?v=3","gravatar_id":"","url":"https://api.github.com/users/akormushin","html_url":"https://github.com/akormushin","followers_url":"https://api.github.com/users/akormushin/followers","following_url":"https://api.github.com/users/akormushin/following{/other_user}","gists_url":"https://api.github.com/users/akormushin/gists{/gist_id}","starred_url":"https://api.github.com/users/akormushin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akormushin/subscriptions","organizations_url":"https://api.github.com/users/akormushin/orgs","repos_url":"https://api.github.com/users/akormushin/repos","events_url":"https://api.github.com/users/akormushin/events{/privacy}","received_events_url":"https://api.github.com/users/akormushin/received_events","type":"User","site_admin":false},"repo":{"id":42108549,"name":"fizteh-java-2015","full_name":"akormushin/fizteh-java-2015","owner":{"login":"akormushin","id":1074038,"avatar_url":"https://avatars.githubusercontent.com/u/1074038?v=3","gravatar_id":"","url":"https://api.github.com/users/akormushin","html_url":"https://github.com/akormushin","followers_url":"https://api.github.com/users/akormushin/followers","following_url":"https://api.github.com/users/akormushin/following{/other_user}","gists_url":"https://api.github.com/users/akormushin/gists{/gist_id}","starred_url":"https://api.github.com/users/akormushin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akormushin/subscriptions","organizations_url":"https://api.github.com/users/akormushin/orgs","repos_url":"https://api.github.com/users/akormushin/repos","events_url":"https://api.github.com/users/akormushin/events{/privacy}","received_events_url":"https://api.github.com/users/akormushin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/akormushin/fizteh-java-2015","description":"","fork":false,"url":"https://api.github.com/repos/akormushin/fizteh-java-2015","forks_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/forks","keys_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/keys{/key_id}","collaborators_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/teams","hooks_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/hooks","issue_events_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/issues/events{/number}","events_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/events","assignees_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/assignees{/user}","branches_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/branches{/branch}","tags_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/tags","blobs_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/git/refs{/sha}","trees_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/git/trees{/sha}","statuses_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/statuses/{sha}","languages_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/languages","stargazers_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/stargazers","contributors_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/contributors","subscribers_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/subscribers","subscription_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/subscription","commits_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/commits{/sha}","git_commits_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/git/commits{/sha}","comments_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/comments{/number}","issue_comment_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/issues/comments{/number}","contents_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/contents/{+path}","compare_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/compare/{base}...{head}","merges_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/merges","archive_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/downloads","issues_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/issues{/number}","pulls_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/pulls{/number}","milestones_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/milestones{/number}","notifications_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/labels{/name}","releases_url":"https://api.github.com/repos/akormushin/fizteh-java-2015/releases{/id}","created_at":"2015-09-08T11:37:54Z","updated_at":"2015-09-14T13:54:17Z","pushed_at":"2015-10-06T13:20:38Z","git_url":"git://github.com/akormushin/fizteh-java-2015.git","ssh_url":"git@github.com:akormushin/fizteh-java-2015.git","clone_url":"https://github.com/akormushin/fizteh-java-2015.git","svn_url":"https://github.com/akormushin/fizteh-java-2015","homepage":null,"size":3566,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":39,"mirror_url":null,"open_issues_count":27,"forks":39,"open_issues":27,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/akormushin/fizteh-java-2015/pulls/62"},"html":{"href":"https://github.com/akormushin/fizteh-java-2015/pull/62"},"issue":{"href":"https://api.github.com/repos/akormushin/fizteh-java-2015/issues/62"},"comments":{"href":"https://api.github.com/repos/akormushin/fizteh-java-2015/issues/62/comments"},"review_comments":{"href":"https://api.github.com/repos/akormushin/fizteh-java-2015/pulls/62/comments"},"review_comment":{"href":"https://api.github.com/repos/akormushin/fizteh-java-2015/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/akormushin/fizteh-java-2015/pulls/62/commits"},"statuses":{"href":"https://api.github.com/repos/akormushin/fizteh-java-2015/statuses/b7bda261b5dce5e22ab54bff16f58295801585ce"}}}}