{"action":"created","comment":{"url":"https://api.github.com/repos/HackSoc/csbot/pulls/comments/292641942","pull_request_review_id":248415195,"id":292641942,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI5MjY0MTk0Mg==","diff_hunk":"@@ -0,0 +1,109 @@\n+from csbot.plugin import Plugin\n+from csbot.util import nick\n+\n+class IOU(Plugin):\n+    '''\n+    Records what we owe to each other\n+    '''\n+    db_owage = Plugin.use('mongodb', collection='owage')\n+\n+    def setup(self):\n+        super(IOU, self).setup()\n+\n+        #check if owage already exists\n+        if self.db_owage.find_one(\"example\"):\n+            self.initialised = True\n+            return\n+        \n+        #if owage doesn't exist yet, we want to make it\n+        self.initialised = False\n+\n+        self.blankuser = {\"_id\": \"example\", \"owee_nick\": 0}\n+\n+        x = self.db_owage.insert(self.blankuser)\n+    \n+    def get_owage(self, nick, owee_name):\n+        all_owed = self.db_owage.find_one(nick)\n+        if all_owed:\n+            if owee_name in all_owed:\n+                return all_owed[owee_name]/100\n+            return 0\n+        return 0 #this is what I keep recieving\n+    \n+    def update_owage(self, nick, owee_name, amount):\n+        all_owed = self.db_owage.find_one(nick)\n+        if all_owed:\n+            self.db_owage.delete_one(all_owed)\n+            if owee_name in all_owed:\n+                all_owed[owee_name] = int(all_owed[owee_name])\n+                all_owed[owee_name] += int(amount*100)\n+            else:\n+                all_owed[owee_name] = int(amount*100)\n+        else:\n+            all_owed = {\"_id\": nick, owee_name: int(amount*100)}\n+        \n+        self.db_owage.insert_one(all_owed)  #inserts updated value into db\n+        return self.get_owage(nick, owee_name)  #returns the updated amount\n+    \n+    def get_all_nicks(self):\n+        cursor = self.db_owage.find()\n+        nicks = []\n+        for document in cursor:\n+            nicks += cursor[\"_id\"] \n+        return nicks\n+\n+\n+\n+    @Plugin.command('IOU', help = ('IOU <nick>: returns what you owe to that person '\n+                                    '| IOU <nick> <amount> adds the amount (in pounds) to what you alread owe that person'))\n+    @Plugin.command('iou', help = ('equivalent to IOU'))\n+    def iou(self, e):\n+        nick_ = nick(e['user']).strip('<')\n+        nick_ = nick_.strip('>')","path":"src/csbot/plugins/iou.py","position":62,"original_position":62,"commit_id":"0d6d2bb3655182006decc61ffc932da35b50fede","original_commit_id":"0d6d2bb3655182006decc61ffc932da35b50fede","user":{"login":"LordAro","id":4007992,"node_id":"MDQ6VXNlcjQwMDc5OTI=","avatar_url":"https://avatars3.githubusercontent.com/u/4007992?v=4","gravatar_id":"","url":"https://api.github.com/users/LordAro","html_url":"https://github.com/LordAro","followers_url":"https://api.github.com/users/LordAro/followers","following_url":"https://api.github.com/users/LordAro/following{/other_user}","gists_url":"https://api.github.com/users/LordAro/gists{/gist_id}","starred_url":"https://api.github.com/users/LordAro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LordAro/subscriptions","organizations_url":"https://api.github.com/users/LordAro/orgs","repos_url":"https://api.github.com/users/LordAro/repos","events_url":"https://api.github.com/users/LordAro/events{/privacy}","received_events_url":"https://api.github.com/users/LordAro/received_events","type":"User","site_admin":false},"body":"nick would never contain these characters","created_at":"2019-06-11T20:20:07Z","updated_at":"2019-06-11T20:31:44Z","html_url":"https://github.com/HackSoc/csbot/pull/160#discussion_r292641942","pull_request_url":"https://api.github.com/repos/HackSoc/csbot/pulls/160","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/HackSoc/csbot/pulls/comments/292641942"},"html":{"href":"https://github.com/HackSoc/csbot/pull/160#discussion_r292641942"},"pull_request":{"href":"https://api.github.com/repos/HackSoc/csbot/pulls/160"}}},"pull_request":{"url":"https://api.github.com/repos/HackSoc/csbot/pulls/160","id":287094919,"node_id":"MDExOlB1bGxSZXF1ZXN0Mjg3MDk0OTE5","html_url":"https://github.com/HackSoc/csbot/pull/160","diff_url":"https://github.com/HackSoc/csbot/pull/160.diff","patch_url":"https://github.com/HackSoc/csbot/pull/160.patch","issue_url":"https://api.github.com/repos/HackSoc/csbot/issues/160","number":160,"state":"open","locked":false,"title":"iou plugin","user":{"login":"FromAnkyra","id":37625186,"node_id":"MDQ6VXNlcjM3NjI1MTg2","avatar_url":"https://avatars3.githubusercontent.com/u/37625186?v=4","gravatar_id":"","url":"https://api.github.com/users/FromAnkyra","html_url":"https://github.com/FromAnkyra","followers_url":"https://api.github.com/users/FromAnkyra/followers","following_url":"https://api.github.com/users/FromAnkyra/following{/other_user}","gists_url":"https://api.github.com/users/FromAnkyra/gists{/gist_id}","starred_url":"https://api.github.com/users/FromAnkyra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FromAnkyra/subscriptions","organizations_url":"https://api.github.com/users/FromAnkyra/orgs","repos_url":"https://api.github.com/users/FromAnkyra/repos","events_url":"https://api.github.com/users/FromAnkyra/events{/privacy}","received_events_url":"https://api.github.com/users/FromAnkyra/received_events","type":"User","site_admin":false},"body":"iou and iamowed commands, using iou plugin","created_at":"2019-06-11T13:38:34Z","updated_at":"2019-06-11T20:31:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f7285d628531ecf2ed54eabe8acea5b9ec581196","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/HackSoc/csbot/pulls/160/commits","review_comments_url":"https://api.github.com/repos/HackSoc/csbot/pulls/160/comments","review_comment_url":"https://api.github.com/repos/HackSoc/csbot/pulls/comments{/number}","comments_url":"https://api.github.com/repos/HackSoc/csbot/issues/160/comments","statuses_url":"https://api.github.com/repos/HackSoc/csbot/statuses/0d6d2bb3655182006decc61ffc932da35b50fede","head":{"label":"FromAnkyra:master","ref":"master","sha":"0d6d2bb3655182006decc61ffc932da35b50fede","user":{"login":"FromAnkyra","id":37625186,"node_id":"MDQ6VXNlcjM3NjI1MTg2","avatar_url":"https://avatars3.githubusercontent.com/u/37625186?v=4","gravatar_id":"","url":"https://api.github.com/users/FromAnkyra","html_url":"https://github.com/FromAnkyra","followers_url":"https://api.github.com/users/FromAnkyra/followers","following_url":"https://api.github.com/users/FromAnkyra/following{/other_user}","gists_url":"https://api.github.com/users/FromAnkyra/gists{/gist_id}","starred_url":"https://api.github.com/users/FromAnkyra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FromAnkyra/subscriptions","organizations_url":"https://api.github.com/users/FromAnkyra/orgs","repos_url":"https://api.github.com/users/FromAnkyra/repos","events_url":"https://api.github.com/users/FromAnkyra/events{/privacy}","received_events_url":"https://api.github.com/users/FromAnkyra/received_events","type":"User","site_admin":false},"repo":{"id":189294592,"node_id":"MDEwOlJlcG9zaXRvcnkxODkyOTQ1OTI=","name":"csbot","full_name":"FromAnkyra/csbot","private":false,"owner":{"login":"FromAnkyra","id":37625186,"node_id":"MDQ6VXNlcjM3NjI1MTg2","avatar_url":"https://avatars3.githubusercontent.com/u/37625186?v=4","gravatar_id":"","url":"https://api.github.com/users/FromAnkyra","html_url":"https://github.com/FromAnkyra","followers_url":"https://api.github.com/users/FromAnkyra/followers","following_url":"https://api.github.com/users/FromAnkyra/following{/other_user}","gists_url":"https://api.github.com/users/FromAnkyra/gists{/gist_id}","starred_url":"https://api.github.com/users/FromAnkyra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FromAnkyra/subscriptions","organizations_url":"https://api.github.com/users/FromAnkyra/orgs","repos_url":"https://api.github.com/users/FromAnkyra/repos","events_url":"https://api.github.com/users/FromAnkyra/events{/privacy}","received_events_url":"https://api.github.com/users/FromAnkyra/received_events","type":"User","site_admin":false},"html_url":"https://github.com/FromAnkyra/csbot","description":"An IRC bot and plugin system for the #cs-york channel on irc.freenode.net","fork":true,"url":"https://api.github.com/repos/FromAnkyra/csbot","forks_url":"https://api.github.com/repos/FromAnkyra/csbot/forks","keys_url":"https://api.github.com/repos/FromAnkyra/csbot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/FromAnkyra/csbot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/FromAnkyra/csbot/teams","hooks_url":"https://api.github.com/repos/FromAnkyra/csbot/hooks","issue_events_url":"https://api.github.com/repos/FromAnkyra/csbot/issues/events{/number}","events_url":"https://api.github.com/repos/FromAnkyra/csbot/events","assignees_url":"https://api.github.com/repos/FromAnkyra/csbot/assignees{/user}","branches_url":"https://api.github.com/repos/FromAnkyra/csbot/branches{/branch}","tags_url":"https://api.github.com/repos/FromAnkyra/csbot/tags","blobs_url":"https://api.github.com/repos/FromAnkyra/csbot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/FromAnkyra/csbot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/FromAnkyra/csbot/git/refs{/sha}","trees_url":"https://api.github.com/repos/FromAnkyra/csbot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/FromAnkyra/csbot/statuses/{sha}","languages_url":"https://api.github.com/repos/FromAnkyra/csbot/languages","stargazers_url":"https://api.github.com/repos/FromAnkyra/csbot/stargazers","contributors_url":"https://api.github.com/repos/FromAnkyra/csbot/contributors","subscribers_url":"https://api.github.com/repos/FromAnkyra/csbot/subscribers","subscription_url":"https://api.github.com/repos/FromAnkyra/csbot/subscription","commits_url":"https://api.github.com/repos/FromAnkyra/csbot/commits{/sha}","git_commits_url":"https://api.github.com/repos/FromAnkyra/csbot/git/commits{/sha}","comments_url":"https://api.github.com/repos/FromAnkyra/csbot/comments{/number}","issue_comment_url":"https://api.github.com/repos/FromAnkyra/csbot/issues/comments{/number}","contents_url":"https://api.github.com/repos/FromAnkyra/csbot/contents/{+path}","compare_url":"https://api.github.com/repos/FromAnkyra/csbot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/FromAnkyra/csbot/merges","archive_url":"https://api.github.com/repos/FromAnkyra/csbot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/FromAnkyra/csbot/downloads","issues_url":"https://api.github.com/repos/FromAnkyra/csbot/issues{/number}","pulls_url":"https://api.github.com/repos/FromAnkyra/csbot/pulls{/number}","milestones_url":"https://api.github.com/repos/FromAnkyra/csbot/milestones{/number}","notifications_url":"https://api.github.com/repos/FromAnkyra/csbot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/FromAnkyra/csbot/labels{/name}","releases_url":"https://api.github.com/repos/FromAnkyra/csbot/releases{/id}","deployments_url":"https://api.github.com/repos/FromAnkyra/csbot/deployments","created_at":"2019-05-29T20:37:49Z","updated_at":"2019-06-11T13:36:40Z","pushed_at":"2019-06-11T13:36:38Z","git_url":"git://github.com/FromAnkyra/csbot.git","ssh_url":"git@github.com:FromAnkyra/csbot.git","clone_url":"https://github.com/FromAnkyra/csbot.git","svn_url":"https://github.com/FromAnkyra/csbot","homepage":"","size":940,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"HackSoc:master","ref":"master","sha":"b62c1fd008bfef73709f82a0be943b14018fcafd","user":{"login":"HackSoc","id":2779397,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI3NzkzOTc=","avatar_url":"https://avatars0.githubusercontent.com/u/2779397?v=4","gravatar_id":"","url":"https://api.github.com/users/HackSoc","html_url":"https://github.com/HackSoc","followers_url":"https://api.github.com/users/HackSoc/followers","following_url":"https://api.github.com/users/HackSoc/following{/other_user}","gists_url":"https://api.github.com/users/HackSoc/gists{/gist_id}","starred_url":"https://api.github.com/users/HackSoc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HackSoc/subscriptions","organizations_url":"https://api.github.com/users/HackSoc/orgs","repos_url":"https://api.github.com/users/HackSoc/repos","events_url":"https://api.github.com/users/HackSoc/events{/privacy}","received_events_url":"https://api.github.com/users/HackSoc/received_events","type":"Organization","site_admin":false},"repo":{"id":3900408,"node_id":"MDEwOlJlcG9zaXRvcnkzOTAwNDA4","name":"csbot","full_name":"HackSoc/csbot","private":false,"owner":{"login":"HackSoc","id":2779397,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI3NzkzOTc=","avatar_url":"https://avatars0.githubusercontent.com/u/2779397?v=4","gravatar_id":"","url":"https://api.github.com/users/HackSoc","html_url":"https://github.com/HackSoc","followers_url":"https://api.github.com/users/HackSoc/followers","following_url":"https://api.github.com/users/HackSoc/following{/other_user}","gists_url":"https://api.github.com/users/HackSoc/gists{/gist_id}","starred_url":"https://api.github.com/users/HackSoc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HackSoc/subscriptions","organizations_url":"https://api.github.com/users/HackSoc/orgs","repos_url":"https://api.github.com/users/HackSoc/repos","events_url":"https://api.github.com/users/HackSoc/events{/privacy}","received_events_url":"https://api.github.com/users/HackSoc/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/HackSoc/csbot","description":"An IRC bot and plugin system for the #cs-york channel on irc.freenode.net","fork":false,"url":"https://api.github.com/repos/HackSoc/csbot","forks_url":"https://api.github.com/repos/HackSoc/csbot/forks","keys_url":"https://api.github.com/repos/HackSoc/csbot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/HackSoc/csbot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/HackSoc/csbot/teams","hooks_url":"https://api.github.com/repos/HackSoc/csbot/hooks","issue_events_url":"https://api.github.com/repos/HackSoc/csbot/issues/events{/number}","events_url":"https://api.github.com/repos/HackSoc/csbot/events","assignees_url":"https://api.github.com/repos/HackSoc/csbot/assignees{/user}","branches_url":"https://api.github.com/repos/HackSoc/csbot/branches{/branch}","tags_url":"https://api.github.com/repos/HackSoc/csbot/tags","blobs_url":"https://api.github.com/repos/HackSoc/csbot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/HackSoc/csbot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/HackSoc/csbot/git/refs{/sha}","trees_url":"https://api.github.com/repos/HackSoc/csbot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/HackSoc/csbot/statuses/{sha}","languages_url":"https://api.github.com/repos/HackSoc/csbot/languages","stargazers_url":"https://api.github.com/repos/HackSoc/csbot/stargazers","contributors_url":"https://api.github.com/repos/HackSoc/csbot/contributors","subscribers_url":"https://api.github.com/repos/HackSoc/csbot/subscribers","subscription_url":"https://api.github.com/repos/HackSoc/csbot/subscription","commits_url":"https://api.github.com/repos/HackSoc/csbot/commits{/sha}","git_commits_url":"https://api.github.com/repos/HackSoc/csbot/git/commits{/sha}","comments_url":"https://api.github.com/repos/HackSoc/csbot/comments{/number}","issue_comment_url":"https://api.github.com/repos/HackSoc/csbot/issues/comments{/number}","contents_url":"https://api.github.com/repos/HackSoc/csbot/contents/{+path}","compare_url":"https://api.github.com/repos/HackSoc/csbot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/HackSoc/csbot/merges","archive_url":"https://api.github.com/repos/HackSoc/csbot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/HackSoc/csbot/downloads","issues_url":"https://api.github.com/repos/HackSoc/csbot/issues{/number}","pulls_url":"https://api.github.com/repos/HackSoc/csbot/pulls{/number}","milestones_url":"https://api.github.com/repos/HackSoc/csbot/milestones{/number}","notifications_url":"https://api.github.com/repos/HackSoc/csbot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/HackSoc/csbot/labels{/name}","releases_url":"https://api.github.com/repos/HackSoc/csbot/releases{/id}","deployments_url":"https://api.github.com/repos/HackSoc/csbot/deployments","created_at":"2012-04-02T12:34:14Z","updated_at":"2019-06-08T21:08:47Z","pushed_at":"2019-06-11T13:38:35Z","git_url":"git://github.com/HackSoc/csbot.git","ssh_url":"git@github.com:HackSoc/csbot.git","clone_url":"https://github.com/HackSoc/csbot.git","svn_url":"https://github.com/HackSoc/csbot","homepage":"","size":933,"stargazers_count":10,"watchers_count":10,"language":"Python","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":15,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":14,"license":null,"forks":15,"open_issues":14,"watchers":10,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/HackSoc/csbot/pulls/160"},"html":{"href":"https://github.com/HackSoc/csbot/pull/160"},"issue":{"href":"https://api.github.com/repos/HackSoc/csbot/issues/160"},"comments":{"href":"https://api.github.com/repos/HackSoc/csbot/issues/160/comments"},"review_comments":{"href":"https://api.github.com/repos/HackSoc/csbot/pulls/160/comments"},"review_comment":{"href":"https://api.github.com/repos/HackSoc/csbot/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/HackSoc/csbot/pulls/160/commits"},"statuses":{"href":"https://api.github.com/repos/HackSoc/csbot/statuses/0d6d2bb3655182006decc61ffc932da35b50fede"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"LordAro"}}