{"action":"created","comment":{"url":"https://api.github.com/repos/zulip/python-zulip-api/pulls/comments/178370833","pull_request_review_id":108426661,"id":178370833,"diff_hunk":"@@ -112,9 +112,13 @@ def main():\n     args = parse_args()\n     if os.path.isfile(args.bot):\n         bot_path = os.path.abspath(args.bot)\n+        bot_dir = os.path.dirname(bot_path)\n+        sys.path.insert(0, bot_dir)\n         bot_name = os.path.splitext(basename(bot_path))[0]\n     else:\n         bot_path = os.path.abspath(os.path.join(current_dir, 'bots', args.bot, args.bot+'.py'))\n+        bot_dir = os.path.join(current_dir, 'bots', args.bot)\n+        sys.path.insert(0, bot_dir)","path":"zulip_bots/zulip_bots/run.py","position":10,"original_position":10,"commit_id":"3b39ee37d1cd200f1bb6fd39ba6b31a514c997a8","original_commit_id":"3b39ee37d1cd200f1bb6fd39ba6b31a514c997a8","user":{"login":"timabbott","id":2746074,"avatar_url":"https://avatars0.githubusercontent.com/u/2746074?v=4","gravatar_id":"","url":"https://api.github.com/users/timabbott","html_url":"https://github.com/timabbott","followers_url":"https://api.github.com/users/timabbott/followers","following_url":"https://api.github.com/users/timabbott/following{/other_user}","gists_url":"https://api.github.com/users/timabbott/gists{/gist_id}","starred_url":"https://api.github.com/users/timabbott/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timabbott/subscriptions","organizations_url":"https://api.github.com/users/timabbott/orgs","repos_url":"https://api.github.com/users/timabbott/repos","events_url":"https://api.github.com/users/timabbott/events{/privacy}","received_events_url":"https://api.github.com/users/timabbott/received_events","type":"User","site_admin":false},"body":"OK.  We can move the `sys.path.insert` part out, though; just not `bot_dir`.  We might also want to do something with these redundant-sounding names; I think `bot_path` should probably become `bot_module_path` in a follow-up commit.","created_at":"2018-03-30T20:25:42Z","updated_at":"2018-03-30T20:25:42Z","html_url":"https://github.com/zulip/python-zulip-api/pull/361#discussion_r178370833","pull_request_url":"https://api.github.com/repos/zulip/python-zulip-api/pulls/361","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/zulip/python-zulip-api/pulls/comments/178370833"},"html":{"href":"https://github.com/zulip/python-zulip-api/pull/361#discussion_r178370833"},"pull_request":{"href":"https://api.github.com/repos/zulip/python-zulip-api/pulls/361"}},"in_reply_to_id":178369879},"pull_request":{"url":"https://api.github.com/repos/zulip/python-zulip-api/pulls/361","id":178528661,"html_url":"https://github.com/zulip/python-zulip-api/pull/361","diff_url":"https://github.com/zulip/python-zulip-api/pull/361.diff","patch_url":"https://github.com/zulip/python-zulip-api/pull/361.patch","issue_url":"https://api.github.com/repos/zulip/python-zulip-api/issues/361","number":361,"state":"open","locked":false,"title":"Automatically add a bot handler's parent dir to the python path.","user":{"login":"Anupam-dagar","id":21174572,"avatar_url":"https://avatars1.githubusercontent.com/u/21174572?v=4","gravatar_id":"","url":"https://api.github.com/users/Anupam-dagar","html_url":"https://github.com/Anupam-dagar","followers_url":"https://api.github.com/users/Anupam-dagar/followers","following_url":"https://api.github.com/users/Anupam-dagar/following{/other_user}","gists_url":"https://api.github.com/users/Anupam-dagar/gists{/gist_id}","starred_url":"https://api.github.com/users/Anupam-dagar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Anupam-dagar/subscriptions","organizations_url":"https://api.github.com/users/Anupam-dagar/orgs","repos_url":"https://api.github.com/users/Anupam-dagar/repos","events_url":"https://api.github.com/users/Anupam-dagar/events{/privacy}","received_events_url":"https://api.github.com/users/Anupam-dagar/received_events","type":"User","site_admin":false},"body":"Fixes: #356 \r\n\r\nI tested this in two ways:\r\n1. Copied `helloworld` bot outside `python-zulip-api` in my local repo. Created one module in helloworld directory and imported in `helloworld.py`.\r\nran the bot using `zulip-run-bot path_to_helloworld.py -c path_to_zuliprc`\r\n2. For the helloworld bot residing in zulip repository, created a module in helloworld directory and imported in `helloworld.py`.\r\nran the bot using `zulip-run-bot helloworld -c path_to_zuliprc`\r\nThis also makes it possible to import modules in subdirectories.","created_at":"2018-03-30T09:41:41Z","updated_at":"2018-03-30T20:25:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d463458073c13b26c7be4e958bd37402d407795e","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":674416437,"url":"https://api.github.com/repos/zulip/python-zulip-api/labels/priority:%20high","name":"priority: high","color":"5319e7","default":false},{"id":805897858,"url":"https://api.github.com/repos/zulip/python-zulip-api/labels/size:%20XS","name":"size: XS","color":"ededed","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/zulip/python-zulip-api/pulls/361/commits","review_comments_url":"https://api.github.com/repos/zulip/python-zulip-api/pulls/361/comments","review_comment_url":"https://api.github.com/repos/zulip/python-zulip-api/pulls/comments{/number}","comments_url":"https://api.github.com/repos/zulip/python-zulip-api/issues/361/comments","statuses_url":"https://api.github.com/repos/zulip/python-zulip-api/statuses/3b39ee37d1cd200f1bb6fd39ba6b31a514c997a8","head":{"label":"Anupam-dagar:import_module","ref":"import_module","sha":"3b39ee37d1cd200f1bb6fd39ba6b31a514c997a8","user":{"login":"Anupam-dagar","id":21174572,"avatar_url":"https://avatars1.githubusercontent.com/u/21174572?v=4","gravatar_id":"","url":"https://api.github.com/users/Anupam-dagar","html_url":"https://github.com/Anupam-dagar","followers_url":"https://api.github.com/users/Anupam-dagar/followers","following_url":"https://api.github.com/users/Anupam-dagar/following{/other_user}","gists_url":"https://api.github.com/users/Anupam-dagar/gists{/gist_id}","starred_url":"https://api.github.com/users/Anupam-dagar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Anupam-dagar/subscriptions","organizations_url":"https://api.github.com/users/Anupam-dagar/orgs","repos_url":"https://api.github.com/users/Anupam-dagar/repos","events_url":"https://api.github.com/users/Anupam-dagar/events{/privacy}","received_events_url":"https://api.github.com/users/Anupam-dagar/received_events","type":"User","site_admin":false},"repo":{"id":124874894,"name":"python-zulip-api","full_name":"Anupam-dagar/python-zulip-api","owner":{"login":"Anupam-dagar","id":21174572,"avatar_url":"https://avatars1.githubusercontent.com/u/21174572?v=4","gravatar_id":"","url":"https://api.github.com/users/Anupam-dagar","html_url":"https://github.com/Anupam-dagar","followers_url":"https://api.github.com/users/Anupam-dagar/followers","following_url":"https://api.github.com/users/Anupam-dagar/following{/other_user}","gists_url":"https://api.github.com/users/Anupam-dagar/gists{/gist_id}","starred_url":"https://api.github.com/users/Anupam-dagar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Anupam-dagar/subscriptions","organizations_url":"https://api.github.com/users/Anupam-dagar/orgs","repos_url":"https://api.github.com/users/Anupam-dagar/repos","events_url":"https://api.github.com/users/Anupam-dagar/events{/privacy}","received_events_url":"https://api.github.com/users/Anupam-dagar/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Anupam-dagar/python-zulip-api","description":null,"fork":true,"url":"https://api.github.com/repos/Anupam-dagar/python-zulip-api","forks_url":"https://api.github.com/repos/Anupam-dagar/python-zulip-api/forks","keys_url":"https://api.github.com/repos/Anupam-dagar/python-zulip-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Anupam-dagar/python-zulip-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Anupam-dagar/python-zulip-api/teams","hooks_url":"https://api.github.com/repos/Anupam-dagar/python-zulip-api/hooks","issue_events_url":"https://api.github.com/repos/Anupam-dagar/python-zulip-api/issues/events{/number}","events_url":"https://api.github.com/repos/Anupam-dagar/python-zulip-api/events","assignees_url":"https://api.github.com/repos/Anupam-dagar/python-zulip-api/assignees{/user}","branches_url":"https://api.github.com/repos/Anupam-dagar/python-zulip-api/branches{/branch}","tags_url":"https://api.github.com/repos/Anupam-dagar/python-zulip-api/tags","blobs_url":"https://api.github.com/repos/Anupam-dagar/python-zulip-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Anupam-dagar/python-zulip-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Anupam-dagar/python-zulip-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/Anupam-dagar/python-zulip-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Anupam-dagar/python-zulip-api/statuses/{sha}","languages_url":"https://api.github.com/repos/Anupam-dagar/python-zulip-api/languages","stargazers_url":"https://api.github.com/repos/Anupam-dagar/python-zulip-api/stargazers","contributors_url":"https://api.github.com/repos/Anupam-dagar/python-zulip-api/contributors","subscribers_url":"https://api.github.com/repos/Anupam-dagar/python-zulip-api/subscribers","subscription_url":"https://api.github.com/repos/Anupam-dagar/python-zulip-api/subscription","commits_url":"https://api.github.com/repos/Anupam-dagar/python-zulip-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/Anupam-dagar/python-zulip-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/Anupam-dagar/python-zulip-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/Anupam-dagar/python-zulip-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/Anupam-dagar/python-zulip-api/contents/{+path}","compare_url":"https://api.github.com/repos/Anupam-dagar/python-zulip-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Anupam-dagar/python-zulip-api/merges","archive_url":"https://api.github.com/repos/Anupam-dagar/python-zulip-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Anupam-dagar/python-zulip-api/downloads","issues_url":"https://api.github.com/repos/Anupam-dagar/python-zulip-api/issues{/number}","pulls_url":"https://api.github.com/repos/Anupam-dagar/python-zulip-api/pulls{/number}","milestones_url":"https://api.github.com/repos/Anupam-dagar/python-zulip-api/milestones{/number}","notifications_url":"https://api.github.com/repos/Anupam-dagar/python-zulip-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Anupam-dagar/python-zulip-api/labels{/name}","releases_url":"https://api.github.com/repos/Anupam-dagar/python-zulip-api/releases{/id}","deployments_url":"https://api.github.com/repos/Anupam-dagar/python-zulip-api/deployments","created_at":"2018-03-12T10:52:08Z","updated_at":"2018-03-29T08:00:26Z","pushed_at":"2018-03-30T09:33:30Z","git_url":"git://github.com/Anupam-dagar/python-zulip-api.git","ssh_url":"git@github.com:Anupam-dagar/python-zulip-api.git","clone_url":"https://github.com/Anupam-dagar/python-zulip-api.git","svn_url":"https://github.com/Anupam-dagar/python-zulip-api","homepage":"https://zulipchat.com/api","size":4156,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"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":"zulip:master","ref":"master","sha":"2f4b2767996049901152e2022809deb2e3ce058a","user":{"login":"zulip","id":4921959,"avatar_url":"https://avatars2.githubusercontent.com/u/4921959?v=4","gravatar_id":"","url":"https://api.github.com/users/zulip","html_url":"https://github.com/zulip","followers_url":"https://api.github.com/users/zulip/followers","following_url":"https://api.github.com/users/zulip/following{/other_user}","gists_url":"https://api.github.com/users/zulip/gists{/gist_id}","starred_url":"https://api.github.com/users/zulip/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zulip/subscriptions","organizations_url":"https://api.github.com/users/zulip/orgs","repos_url":"https://api.github.com/users/zulip/repos","events_url":"https://api.github.com/users/zulip/events{/privacy}","received_events_url":"https://api.github.com/users/zulip/received_events","type":"Organization","site_admin":false},"repo":{"id":96455158,"name":"python-zulip-api","full_name":"zulip/python-zulip-api","owner":{"login":"zulip","id":4921959,"avatar_url":"https://avatars2.githubusercontent.com/u/4921959?v=4","gravatar_id":"","url":"https://api.github.com/users/zulip","html_url":"https://github.com/zulip","followers_url":"https://api.github.com/users/zulip/followers","following_url":"https://api.github.com/users/zulip/following{/other_user}","gists_url":"https://api.github.com/users/zulip/gists{/gist_id}","starred_url":"https://api.github.com/users/zulip/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zulip/subscriptions","organizations_url":"https://api.github.com/users/zulip/orgs","repos_url":"https://api.github.com/users/zulip/repos","events_url":"https://api.github.com/users/zulip/events{/privacy}","received_events_url":"https://api.github.com/users/zulip/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/zulip/python-zulip-api","description":null,"fork":false,"url":"https://api.github.com/repos/zulip/python-zulip-api","forks_url":"https://api.github.com/repos/zulip/python-zulip-api/forks","keys_url":"https://api.github.com/repos/zulip/python-zulip-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zulip/python-zulip-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zulip/python-zulip-api/teams","hooks_url":"https://api.github.com/repos/zulip/python-zulip-api/hooks","issue_events_url":"https://api.github.com/repos/zulip/python-zulip-api/issues/events{/number}","events_url":"https://api.github.com/repos/zulip/python-zulip-api/events","assignees_url":"https://api.github.com/repos/zulip/python-zulip-api/assignees{/user}","branches_url":"https://api.github.com/repos/zulip/python-zulip-api/branches{/branch}","tags_url":"https://api.github.com/repos/zulip/python-zulip-api/tags","blobs_url":"https://api.github.com/repos/zulip/python-zulip-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zulip/python-zulip-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zulip/python-zulip-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/zulip/python-zulip-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zulip/python-zulip-api/statuses/{sha}","languages_url":"https://api.github.com/repos/zulip/python-zulip-api/languages","stargazers_url":"https://api.github.com/repos/zulip/python-zulip-api/stargazers","contributors_url":"https://api.github.com/repos/zulip/python-zulip-api/contributors","subscribers_url":"https://api.github.com/repos/zulip/python-zulip-api/subscribers","subscription_url":"https://api.github.com/repos/zulip/python-zulip-api/subscription","commits_url":"https://api.github.com/repos/zulip/python-zulip-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/zulip/python-zulip-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/zulip/python-zulip-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/zulip/python-zulip-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/zulip/python-zulip-api/contents/{+path}","compare_url":"https://api.github.com/repos/zulip/python-zulip-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zulip/python-zulip-api/merges","archive_url":"https://api.github.com/repos/zulip/python-zulip-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zulip/python-zulip-api/downloads","issues_url":"https://api.github.com/repos/zulip/python-zulip-api/issues{/number}","pulls_url":"https://api.github.com/repos/zulip/python-zulip-api/pulls{/number}","milestones_url":"https://api.github.com/repos/zulip/python-zulip-api/milestones{/number}","notifications_url":"https://api.github.com/repos/zulip/python-zulip-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zulip/python-zulip-api/labels{/name}","releases_url":"https://api.github.com/repos/zulip/python-zulip-api/releases{/id}","deployments_url":"https://api.github.com/repos/zulip/python-zulip-api/deployments","created_at":"2017-07-06T17:25:46Z","updated_at":"2018-03-30T20:10:09Z","pushed_at":"2018-03-30T20:24:11Z","git_url":"git://github.com/zulip/python-zulip-api.git","ssh_url":"git@github.com:zulip/python-zulip-api.git","clone_url":"https://github.com/zulip/python-zulip-api.git","svn_url":"https://github.com/zulip/python-zulip-api","homepage":"https://zulipchat.com/api","size":4158,"stargazers_count":163,"watchers_count":163,"language":"Python","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":85,"mirror_url":null,"archived":false,"open_issues_count":49,"license":null,"forks":85,"open_issues":49,"watchers":163,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/zulip/python-zulip-api/pulls/361"},"html":{"href":"https://github.com/zulip/python-zulip-api/pull/361"},"issue":{"href":"https://api.github.com/repos/zulip/python-zulip-api/issues/361"},"comments":{"href":"https://api.github.com/repos/zulip/python-zulip-api/issues/361/comments"},"review_comments":{"href":"https://api.github.com/repos/zulip/python-zulip-api/pulls/361/comments"},"review_comment":{"href":"https://api.github.com/repos/zulip/python-zulip-api/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/zulip/python-zulip-api/pulls/361/commits"},"statuses":{"href":"https://api.github.com/repos/zulip/python-zulip-api/statuses/3b39ee37d1cd200f1bb6fd39ba6b31a514c997a8"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"timabbott"}}