{"action":"created","comment":{"url":"https://api.github.com/repos/mrshu/brutal-plugins/pulls/comments/29529409","id":29529409,"diff_hunk":"@@ -11,23 +11,39 @@ def seen_evt(self, event):\n         events = ['quit', 'part', 'kick', 'join', 'rename', 'topic', 'message']\n         if event.event_type in events:\n             nick = event.meta['nick']\n-            self.seen[nick] = (event.event_type, gmtime())\n+            self.seen[nick] = (event.event_type, datetime.datetime.utcnow())\n \n     @cmd\n     def last_seen(self, event):\n-        \"\"\"\n-        Returns when was given user last seen.\n+        \"\"\"Return when was given user last seen.\n \n         Example: !last_seen <user>\n         \"\"\"\n         args = event.args\n         if len(args) < 1:\n-            return \"Name argument missing.\"\n+            return 'Name argument missing.'\n         user = args[0]\n \n         if user not in self.seen:\n-            return \"This user was never here.\"\n+            return 'This user has never been here.'\n \n         evt, time = self.seen[user]\n-        time = strftime(\"%H:%M %d.%m.%Y\", time)\n-        return \"{0} was last seen: {1} GMT({2})\".format(user, time, evt)\n+        diff_time = datetime.datetime.utcnow() - time\n+\n+        if diff_time.days == 0:\n+            hours = diff_time.seconds // 3600\n+            minutes = (diff_time.seconds - (hours * 3600)) // 60\n+\n+            min_format = 'minute' if minutes == 1 else 'minutes'\n+            if hours > 0:\n+                hour_format = 'hour' if hours == 1 else 'hours'\n+                msg = '{0} {1} and {2} {3}'.format(hours, hour_format,\n+                                                   minutes, min_format)\n+            elif minutes > 0:\n+                msg = '{0} {1}'.format(minutes, min_format)\n+            else:\n+                msg = 'less than 1 minute'\n+            return '{0} was last seen {1} ago'.format(user, msg)\n+\n+        time = time.strftime('%H:%M %d.%m.%Y')","path":"last_seen.py","position":52,"original_position":52,"commit_id":"47e950a509536dc86eab086e1496b4e508b338cd","original_commit_id":"47e950a509536dc86eab086e1496b4e508b338cd","user":{"login":"mrshu","id":461491,"avatar_url":"https://avatars.githubusercontent.com/u/461491?v=3","gravatar_id":"","url":"https://api.github.com/users/mrshu","html_url":"https://github.com/mrshu","followers_url":"https://api.github.com/users/mrshu/followers","following_url":"https://api.github.com/users/mrshu/following{/other_user}","gists_url":"https://api.github.com/users/mrshu/gists{/gist_id}","starred_url":"https://api.github.com/users/mrshu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrshu/subscriptions","organizations_url":"https://api.github.com/users/mrshu/orgs","repos_url":"https://api.github.com/users/mrshu/repos","events_url":"https://api.github.com/users/mrshu/events{/privacy}","received_events_url":"https://api.github.com/users/mrshu/received_events","type":"User","site_admin":false},"body":"@Adman I see, sorry about that.","created_at":"2015-05-01T20:03:51Z","updated_at":"2015-05-01T20:03:51Z","html_url":"https://github.com/mrshu/brutal-plugins/pull/98#discussion_r29529409","pull_request_url":"https://api.github.com/repos/mrshu/brutal-plugins/pulls/98","_links":{"self":{"href":"https://api.github.com/repos/mrshu/brutal-plugins/pulls/comments/29529409"},"html":{"href":"https://github.com/mrshu/brutal-plugins/pull/98#discussion_r29529409"},"pull_request":{"href":"https://api.github.com/repos/mrshu/brutal-plugins/pulls/98"}}},"pull_request":{"url":"https://api.github.com/repos/mrshu/brutal-plugins/pulls/98","id":34544575,"html_url":"https://github.com/mrshu/brutal-plugins/pull/98","diff_url":"https://github.com/mrshu/brutal-plugins/pull/98.diff","patch_url":"https://github.com/mrshu/brutal-plugins/pull/98.patch","issue_url":"https://api.github.com/repos/mrshu/brutal-plugins/issues/98","number":98,"state":"open","locked":false,"title":"last_seen: updated return message","user":{"login":"Adman","id":865063,"avatar_url":"https://avatars.githubusercontent.com/u/865063?v=3","gravatar_id":"","url":"https://api.github.com/users/Adman","html_url":"https://github.com/Adman","followers_url":"https://api.github.com/users/Adman/followers","following_url":"https://api.github.com/users/Adman/following{/other_user}","gists_url":"https://api.github.com/users/Adman/gists{/gist_id}","starred_url":"https://api.github.com/users/Adman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Adman/subscriptions","organizations_url":"https://api.github.com/users/Adman/orgs","repos_url":"https://api.github.com/users/Adman/repos","events_url":"https://api.github.com/users/Adman/events{/privacy}","received_events_url":"https://api.github.com/users/Adman/received_events","type":"User","site_admin":false},"body":"* using datetime library instead of time\r\n* if the user was seen less than 24 hours ago,\r\n  it shows just `x hours and y minutes ago`\r\n\r\nSigned-off-by: Adrian Matejov <a.matejov@centrum.sk>","created_at":"2015-05-01T15:38:10Z","updated_at":"2015-05-01T20:03:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1fcebfee59a5a54a06b6c397fcf0b88e69a07eae","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mrshu/brutal-plugins/pulls/98/commits","review_comments_url":"https://api.github.com/repos/mrshu/brutal-plugins/pulls/98/comments","review_comment_url":"https://api.github.com/repos/mrshu/brutal-plugins/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mrshu/brutal-plugins/issues/98/comments","statuses_url":"https://api.github.com/repos/mrshu/brutal-plugins/statuses/47e950a509536dc86eab086e1496b4e508b338cd","head":{"label":"Adman:lastseen-patch1","ref":"lastseen-patch1","sha":"47e950a509536dc86eab086e1496b4e508b338cd","user":{"login":"Adman","id":865063,"avatar_url":"https://avatars.githubusercontent.com/u/865063?v=3","gravatar_id":"","url":"https://api.github.com/users/Adman","html_url":"https://github.com/Adman","followers_url":"https://api.github.com/users/Adman/followers","following_url":"https://api.github.com/users/Adman/following{/other_user}","gists_url":"https://api.github.com/users/Adman/gists{/gist_id}","starred_url":"https://api.github.com/users/Adman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Adman/subscriptions","organizations_url":"https://api.github.com/users/Adman/orgs","repos_url":"https://api.github.com/users/Adman/repos","events_url":"https://api.github.com/users/Adman/events{/privacy}","received_events_url":"https://api.github.com/users/Adman/received_events","type":"User","site_admin":false},"repo":{"id":27332225,"name":"brutal-plugins","full_name":"Adman/brutal-plugins","owner":{"login":"Adman","id":865063,"avatar_url":"https://avatars.githubusercontent.com/u/865063?v=3","gravatar_id":"","url":"https://api.github.com/users/Adman","html_url":"https://github.com/Adman","followers_url":"https://api.github.com/users/Adman/followers","following_url":"https://api.github.com/users/Adman/following{/other_user}","gists_url":"https://api.github.com/users/Adman/gists{/gist_id}","starred_url":"https://api.github.com/users/Adman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Adman/subscriptions","organizations_url":"https://api.github.com/users/Adman/orgs","repos_url":"https://api.github.com/users/Adman/repos","events_url":"https://api.github.com/users/Adman/events{/privacy}","received_events_url":"https://api.github.com/users/Adman/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Adman/brutal-plugins","description":"A set of plugins for brutal, the mighty chatbot","fork":true,"url":"https://api.github.com/repos/Adman/brutal-plugins","forks_url":"https://api.github.com/repos/Adman/brutal-plugins/forks","keys_url":"https://api.github.com/repos/Adman/brutal-plugins/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Adman/brutal-plugins/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Adman/brutal-plugins/teams","hooks_url":"https://api.github.com/repos/Adman/brutal-plugins/hooks","issue_events_url":"https://api.github.com/repos/Adman/brutal-plugins/issues/events{/number}","events_url":"https://api.github.com/repos/Adman/brutal-plugins/events","assignees_url":"https://api.github.com/repos/Adman/brutal-plugins/assignees{/user}","branches_url":"https://api.github.com/repos/Adman/brutal-plugins/branches{/branch}","tags_url":"https://api.github.com/repos/Adman/brutal-plugins/tags","blobs_url":"https://api.github.com/repos/Adman/brutal-plugins/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Adman/brutal-plugins/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Adman/brutal-plugins/git/refs{/sha}","trees_url":"https://api.github.com/repos/Adman/brutal-plugins/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Adman/brutal-plugins/statuses/{sha}","languages_url":"https://api.github.com/repos/Adman/brutal-plugins/languages","stargazers_url":"https://api.github.com/repos/Adman/brutal-plugins/stargazers","contributors_url":"https://api.github.com/repos/Adman/brutal-plugins/contributors","subscribers_url":"https://api.github.com/repos/Adman/brutal-plugins/subscribers","subscription_url":"https://api.github.com/repos/Adman/brutal-plugins/subscription","commits_url":"https://api.github.com/repos/Adman/brutal-plugins/commits{/sha}","git_commits_url":"https://api.github.com/repos/Adman/brutal-plugins/git/commits{/sha}","comments_url":"https://api.github.com/repos/Adman/brutal-plugins/comments{/number}","issue_comment_url":"https://api.github.com/repos/Adman/brutal-plugins/issues/comments{/number}","contents_url":"https://api.github.com/repos/Adman/brutal-plugins/contents/{+path}","compare_url":"https://api.github.com/repos/Adman/brutal-plugins/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Adman/brutal-plugins/merges","archive_url":"https://api.github.com/repos/Adman/brutal-plugins/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Adman/brutal-plugins/downloads","issues_url":"https://api.github.com/repos/Adman/brutal-plugins/issues{/number}","pulls_url":"https://api.github.com/repos/Adman/brutal-plugins/pulls{/number}","milestones_url":"https://api.github.com/repos/Adman/brutal-plugins/milestones{/number}","notifications_url":"https://api.github.com/repos/Adman/brutal-plugins/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Adman/brutal-plugins/labels{/name}","releases_url":"https://api.github.com/repos/Adman/brutal-plugins/releases{/id}","created_at":"2014-11-30T10:40:37Z","updated_at":"2014-12-08T18:27:58Z","pushed_at":"2015-05-01T15:36:59Z","git_url":"git://github.com/Adman/brutal-plugins.git","ssh_url":"git@github.com:Adman/brutal-plugins.git","clone_url":"https://github.com/Adman/brutal-plugins.git","svn_url":"https://github.com/Adman/brutal-plugins","homepage":null,"size":407,"stargazers_count":0,"watchers_count":0,"language":"Python","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":"mrshu:master","ref":"master","sha":"bb0fb5b1ffcf8ce36d330f03936772769ca8e029","user":{"login":"mrshu","id":461491,"avatar_url":"https://avatars.githubusercontent.com/u/461491?v=3","gravatar_id":"","url":"https://api.github.com/users/mrshu","html_url":"https://github.com/mrshu","followers_url":"https://api.github.com/users/mrshu/followers","following_url":"https://api.github.com/users/mrshu/following{/other_user}","gists_url":"https://api.github.com/users/mrshu/gists{/gist_id}","starred_url":"https://api.github.com/users/mrshu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrshu/subscriptions","organizations_url":"https://api.github.com/users/mrshu/orgs","repos_url":"https://api.github.com/users/mrshu/repos","events_url":"https://api.github.com/users/mrshu/events{/privacy}","received_events_url":"https://api.github.com/users/mrshu/received_events","type":"User","site_admin":false},"repo":{"id":25275383,"name":"brutal-plugins","full_name":"mrshu/brutal-plugins","owner":{"login":"mrshu","id":461491,"avatar_url":"https://avatars.githubusercontent.com/u/461491?v=3","gravatar_id":"","url":"https://api.github.com/users/mrshu","html_url":"https://github.com/mrshu","followers_url":"https://api.github.com/users/mrshu/followers","following_url":"https://api.github.com/users/mrshu/following{/other_user}","gists_url":"https://api.github.com/users/mrshu/gists{/gist_id}","starred_url":"https://api.github.com/users/mrshu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrshu/subscriptions","organizations_url":"https://api.github.com/users/mrshu/orgs","repos_url":"https://api.github.com/users/mrshu/repos","events_url":"https://api.github.com/users/mrshu/events{/privacy}","received_events_url":"https://api.github.com/users/mrshu/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mrshu/brutal-plugins","description":"A set of plugins for brutal, the mighty chatbot","fork":false,"url":"https://api.github.com/repos/mrshu/brutal-plugins","forks_url":"https://api.github.com/repos/mrshu/brutal-plugins/forks","keys_url":"https://api.github.com/repos/mrshu/brutal-plugins/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mrshu/brutal-plugins/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mrshu/brutal-plugins/teams","hooks_url":"https://api.github.com/repos/mrshu/brutal-plugins/hooks","issue_events_url":"https://api.github.com/repos/mrshu/brutal-plugins/issues/events{/number}","events_url":"https://api.github.com/repos/mrshu/brutal-plugins/events","assignees_url":"https://api.github.com/repos/mrshu/brutal-plugins/assignees{/user}","branches_url":"https://api.github.com/repos/mrshu/brutal-plugins/branches{/branch}","tags_url":"https://api.github.com/repos/mrshu/brutal-plugins/tags","blobs_url":"https://api.github.com/repos/mrshu/brutal-plugins/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mrshu/brutal-plugins/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mrshu/brutal-plugins/git/refs{/sha}","trees_url":"https://api.github.com/repos/mrshu/brutal-plugins/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mrshu/brutal-plugins/statuses/{sha}","languages_url":"https://api.github.com/repos/mrshu/brutal-plugins/languages","stargazers_url":"https://api.github.com/repos/mrshu/brutal-plugins/stargazers","contributors_url":"https://api.github.com/repos/mrshu/brutal-plugins/contributors","subscribers_url":"https://api.github.com/repos/mrshu/brutal-plugins/subscribers","subscription_url":"https://api.github.com/repos/mrshu/brutal-plugins/subscription","commits_url":"https://api.github.com/repos/mrshu/brutal-plugins/commits{/sha}","git_commits_url":"https://api.github.com/repos/mrshu/brutal-plugins/git/commits{/sha}","comments_url":"https://api.github.com/repos/mrshu/brutal-plugins/comments{/number}","issue_comment_url":"https://api.github.com/repos/mrshu/brutal-plugins/issues/comments{/number}","contents_url":"https://api.github.com/repos/mrshu/brutal-plugins/contents/{+path}","compare_url":"https://api.github.com/repos/mrshu/brutal-plugins/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mrshu/brutal-plugins/merges","archive_url":"https://api.github.com/repos/mrshu/brutal-plugins/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mrshu/brutal-plugins/downloads","issues_url":"https://api.github.com/repos/mrshu/brutal-plugins/issues{/number}","pulls_url":"https://api.github.com/repos/mrshu/brutal-plugins/pulls{/number}","milestones_url":"https://api.github.com/repos/mrshu/brutal-plugins/milestones{/number}","notifications_url":"https://api.github.com/repos/mrshu/brutal-plugins/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mrshu/brutal-plugins/labels{/name}","releases_url":"https://api.github.com/repos/mrshu/brutal-plugins/releases{/id}","created_at":"2014-10-15T21:58:44Z","updated_at":"2015-05-01T13:37:34Z","pushed_at":"2015-05-01T15:38:10Z","git_url":"git://github.com/mrshu/brutal-plugins.git","ssh_url":"git@github.com:mrshu/brutal-plugins.git","clone_url":"https://github.com/mrshu/brutal-plugins.git","svn_url":"https://github.com/mrshu/brutal-plugins","homepage":null,"size":1623,"stargazers_count":3,"watchers_count":3,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":13,"forks":3,"open_issues":13,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mrshu/brutal-plugins/pulls/98"},"html":{"href":"https://github.com/mrshu/brutal-plugins/pull/98"},"issue":{"href":"https://api.github.com/repos/mrshu/brutal-plugins/issues/98"},"comments":{"href":"https://api.github.com/repos/mrshu/brutal-plugins/issues/98/comments"},"review_comments":{"href":"https://api.github.com/repos/mrshu/brutal-plugins/pulls/98/comments"},"review_comment":{"href":"https://api.github.com/repos/mrshu/brutal-plugins/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mrshu/brutal-plugins/pulls/98/commits"},"statuses":{"href":"https://api.github.com/repos/mrshu/brutal-plugins/statuses/47e950a509536dc86eab086e1496b4e508b338cd"}}}}