{"action":"created","comment":{"url":"https://api.github.com/repos/riking/marvin/pulls/comments/135935283","pull_request_review_id":59406890,"id":135935283,"diff_hunk":"@@ -0,0 +1,101 @@\n+package restart\n+\n+import (\n+\t\"github.com/riking/marvin\"\n+\t\"fmt\"\n+\t\"syscall\"\n+\t\"os/exec\"\n+\t\"os\"\n+)\n+\n+func init() {\n+\tmarvin.RegisterModule(NewRestartModule)\n+}\n+\n+const Identifier = \"restart\"\n+\n+var RecompileInProgress = false\n+var RestartInProgress = false\n+\n+type RestartModule struct {\n+\tteam marvin.Team\n+}\n+\n+func NewRestartModule(t marvin.Team) marvin.Module {\n+\tmod := &RestartModule{\n+\t\tteam: t,\n+\t}\n+\treturn mod\n+}\n+\n+func (mod *RestartModule) Identifier() marvin.ModuleID {\n+\treturn Identifier\n+}\n+\n+func (mod *RestartModule) Load(t marvin.Team) {\n+}\n+\n+func (mod *RestartModule) Enable(team marvin.Team) {\n+\tcmd := team.RegisterCommandFunc(\"restart\", mod.RestartCommand,\n+\t\t\"`@marvin restart`\"+\n+\t\t\t\"This restarts the active Marvin instance.\\n\")\n+\tcmd2 := team.RegisterCommandFunc(\"recompile\", mod.RecompileCommand,\n+\t\t\"`@marvin recompile`\"+\n+\t\t\t\"This recompiles Marvin from git.\\n\")\n+\tteam.RegisterCommand(\"restart\", cmd)\n+\tteam.RegisterCommand(\"recompile\", cmd2)\n+}\n+\n+func (mod *RestartModule) Disable(t marvin.Team) {\n+}\n+\n+\n+func (mod *RestartModule) RecompileCommand(t marvin.Team, args *marvin.CommandArguments) marvin.CommandResult {\n+\tif args.Source.AccessLevel() < marvin.AccessLevelAdmin {\n+\t\treturn marvin.CmdFailuref(args, \"This command is restricted to admins only.\")\n+\t}\n+\n+\tif RecompileInProgress {\n+\t\treturn marvin.CmdFailuref(args, \"There is an already existing recompile in progress.\")\n+\t}\n+\n+\tgo mod.RecompileMarvin(t)","path":"modules/restart/restart.go","position":62,"original_position":62,"commit_id":"3b1c9be5558928d5a84da4adef9e7f7a3b4b46f8","original_commit_id":"3b1c9be5558928d5a84da4adef9e7f7a3b4b46f8","user":{"login":"riking","id":627891,"avatar_url":"https://avatars0.githubusercontent.com/u/627891?v=4","gravatar_id":"","url":"https://api.github.com/users/riking","html_url":"https://github.com/riking","followers_url":"https://api.github.com/users/riking/followers","following_url":"https://api.github.com/users/riking/following{/other_user}","gists_url":"https://api.github.com/users/riking/gists{/gist_id}","starred_url":"https://api.github.com/users/riking/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/riking/subscriptions","organizations_url":"https://api.github.com/users/riking/orgs","repos_url":"https://api.github.com/users/riking/repos","events_url":"https://api.github.com/users/riking/events{/privacy}","received_events_url":"https://api.github.com/users/riking/received_events","type":"User","site_admin":false},"body":"No need to pass the team when it's a field of the module.","created_at":"2017-08-29T23:12:09Z","updated_at":"2017-08-29T23:17:01Z","html_url":"https://github.com/riking/marvin/pull/10#discussion_r135935283","pull_request_url":"https://api.github.com/repos/riking/marvin/pulls/10","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/riking/marvin/pulls/comments/135935283"},"html":{"href":"https://github.com/riking/marvin/pull/10#discussion_r135935283"},"pull_request":{"href":"https://api.github.com/repos/riking/marvin/pulls/10"}},"in_reply_to_id":135934631},"pull_request":{"url":"https://api.github.com/repos/riking/marvin/pulls/10","id":138303678,"html_url":"https://github.com/riking/marvin/pull/10","diff_url":"https://github.com/riking/marvin/pull/10.diff","patch_url":"https://github.com/riking/marvin/pull/10.patch","issue_url":"https://api.github.com/repos/riking/marvin/issues/10","number":10,"state":"open","locked":false,"title":"Added the restart and recompile commands.  Fixes #4","user":{"login":"SuperSpyTX","id":978263,"avatar_url":"https://avatars1.githubusercontent.com/u/978263?v=4","gravatar_id":"","url":"https://api.github.com/users/SuperSpyTX","html_url":"https://github.com/SuperSpyTX","followers_url":"https://api.github.com/users/SuperSpyTX/followers","following_url":"https://api.github.com/users/SuperSpyTX/following{/other_user}","gists_url":"https://api.github.com/users/SuperSpyTX/gists{/gist_id}","starred_url":"https://api.github.com/users/SuperSpyTX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SuperSpyTX/subscriptions","organizations_url":"https://api.github.com/users/SuperSpyTX/orgs","repos_url":"https://api.github.com/users/SuperSpyTX/repos","events_url":"https://api.github.com/users/SuperSpyTX/events{/privacy}","received_events_url":"https://api.github.com/users/SuperSpyTX/received_events","type":"User","site_admin":false},"body":"See #4 \r\n\r\nThis works according to what was requested.  It exits with 14 (only) if the restart command is executed.  Compile errors go to both console & the log channel if necessary.  It does not automatically restart after the recompile.\r\n\r\nYou may need to refine the recompile.sh script accordingly, as this works when the current directory is in the GOPATH (go/src/github.com/riking/marvin).\r\n\r\nI'm also not too sure about how to pass the flag for the exit code to occur (if the command was executed) without importing the module (see [here](https://github.com/riking/marvin/compare/master...SuperSpyTX:patch-restart-recompile?expand=1#diff-047912ae4e22f5323fe4d8a2a8004712)), so if that matters to you, I can try to find another way.\r\n\r\nEDIT: Make sure you're redirecting stderr to stdout, or else Marvin won't have logs to read.  Eg: `2>&1`","created_at":"2017-08-29T23:04:49Z","updated_at":"2017-08-29T23:17:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"899757cb3bff86b51300ad23b338e0ddfbe953f1","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/riking/marvin/pulls/10/commits","review_comments_url":"https://api.github.com/repos/riking/marvin/pulls/10/comments","review_comment_url":"https://api.github.com/repos/riking/marvin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/riking/marvin/issues/10/comments","statuses_url":"https://api.github.com/repos/riking/marvin/statuses/3b1c9be5558928d5a84da4adef9e7f7a3b4b46f8","head":{"label":"SuperSpyTX:patch-restart-recompile","ref":"patch-restart-recompile","sha":"3b1c9be5558928d5a84da4adef9e7f7a3b4b46f8","user":{"login":"SuperSpyTX","id":978263,"avatar_url":"https://avatars1.githubusercontent.com/u/978263?v=4","gravatar_id":"","url":"https://api.github.com/users/SuperSpyTX","html_url":"https://github.com/SuperSpyTX","followers_url":"https://api.github.com/users/SuperSpyTX/followers","following_url":"https://api.github.com/users/SuperSpyTX/following{/other_user}","gists_url":"https://api.github.com/users/SuperSpyTX/gists{/gist_id}","starred_url":"https://api.github.com/users/SuperSpyTX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SuperSpyTX/subscriptions","organizations_url":"https://api.github.com/users/SuperSpyTX/orgs","repos_url":"https://api.github.com/users/SuperSpyTX/repos","events_url":"https://api.github.com/users/SuperSpyTX/events{/privacy}","received_events_url":"https://api.github.com/users/SuperSpyTX/received_events","type":"User","site_admin":false},"repo":{"id":101725843,"name":"marvin","full_name":"SuperSpyTX/marvin","owner":{"login":"SuperSpyTX","id":978263,"avatar_url":"https://avatars1.githubusercontent.com/u/978263?v=4","gravatar_id":"","url":"https://api.github.com/users/SuperSpyTX","html_url":"https://github.com/SuperSpyTX","followers_url":"https://api.github.com/users/SuperSpyTX/followers","following_url":"https://api.github.com/users/SuperSpyTX/following{/other_user}","gists_url":"https://api.github.com/users/SuperSpyTX/gists{/gist_id}","starred_url":"https://api.github.com/users/SuperSpyTX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SuperSpyTX/subscriptions","organizations_url":"https://api.github.com/users/SuperSpyTX/orgs","repos_url":"https://api.github.com/users/SuperSpyTX/repos","events_url":"https://api.github.com/users/SuperSpyTX/events{/privacy}","received_events_url":"https://api.github.com/users/SuperSpyTX/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/SuperSpyTX/marvin","description":"Slack bot for 42 USA","fork":true,"url":"https://api.github.com/repos/SuperSpyTX/marvin","forks_url":"https://api.github.com/repos/SuperSpyTX/marvin/forks","keys_url":"https://api.github.com/repos/SuperSpyTX/marvin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SuperSpyTX/marvin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SuperSpyTX/marvin/teams","hooks_url":"https://api.github.com/repos/SuperSpyTX/marvin/hooks","issue_events_url":"https://api.github.com/repos/SuperSpyTX/marvin/issues/events{/number}","events_url":"https://api.github.com/repos/SuperSpyTX/marvin/events","assignees_url":"https://api.github.com/repos/SuperSpyTX/marvin/assignees{/user}","branches_url":"https://api.github.com/repos/SuperSpyTX/marvin/branches{/branch}","tags_url":"https://api.github.com/repos/SuperSpyTX/marvin/tags","blobs_url":"https://api.github.com/repos/SuperSpyTX/marvin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SuperSpyTX/marvin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SuperSpyTX/marvin/git/refs{/sha}","trees_url":"https://api.github.com/repos/SuperSpyTX/marvin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SuperSpyTX/marvin/statuses/{sha}","languages_url":"https://api.github.com/repos/SuperSpyTX/marvin/languages","stargazers_url":"https://api.github.com/repos/SuperSpyTX/marvin/stargazers","contributors_url":"https://api.github.com/repos/SuperSpyTX/marvin/contributors","subscribers_url":"https://api.github.com/repos/SuperSpyTX/marvin/subscribers","subscription_url":"https://api.github.com/repos/SuperSpyTX/marvin/subscription","commits_url":"https://api.github.com/repos/SuperSpyTX/marvin/commits{/sha}","git_commits_url":"https://api.github.com/repos/SuperSpyTX/marvin/git/commits{/sha}","comments_url":"https://api.github.com/repos/SuperSpyTX/marvin/comments{/number}","issue_comment_url":"https://api.github.com/repos/SuperSpyTX/marvin/issues/comments{/number}","contents_url":"https://api.github.com/repos/SuperSpyTX/marvin/contents/{+path}","compare_url":"https://api.github.com/repos/SuperSpyTX/marvin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SuperSpyTX/marvin/merges","archive_url":"https://api.github.com/repos/SuperSpyTX/marvin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SuperSpyTX/marvin/downloads","issues_url":"https://api.github.com/repos/SuperSpyTX/marvin/issues{/number}","pulls_url":"https://api.github.com/repos/SuperSpyTX/marvin/pulls{/number}","milestones_url":"https://api.github.com/repos/SuperSpyTX/marvin/milestones{/number}","notifications_url":"https://api.github.com/repos/SuperSpyTX/marvin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SuperSpyTX/marvin/labels{/name}","releases_url":"https://api.github.com/repos/SuperSpyTX/marvin/releases{/id}","deployments_url":"https://api.github.com/repos/SuperSpyTX/marvin/deployments","created_at":"2017-08-29T06:15:40Z","updated_at":"2017-08-29T06:15:42Z","pushed_at":"2017-08-29T22:57:20Z","git_url":"git://github.com/SuperSpyTX/marvin.git","ssh_url":"git@github.com:SuperSpyTX/marvin.git","clone_url":"https://github.com/SuperSpyTX/marvin.git","svn_url":"https://github.com/SuperSpyTX/marvin","homepage":null,"size":3299,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"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":"riking:master","ref":"master","sha":"0250faa5f2eb7c8a77dfa15be71a60d6a42a282c","user":{"login":"riking","id":627891,"avatar_url":"https://avatars0.githubusercontent.com/u/627891?v=4","gravatar_id":"","url":"https://api.github.com/users/riking","html_url":"https://github.com/riking","followers_url":"https://api.github.com/users/riking/followers","following_url":"https://api.github.com/users/riking/following{/other_user}","gists_url":"https://api.github.com/users/riking/gists{/gist_id}","starred_url":"https://api.github.com/users/riking/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/riking/subscriptions","organizations_url":"https://api.github.com/users/riking/orgs","repos_url":"https://api.github.com/users/riking/repos","events_url":"https://api.github.com/users/riking/events{/privacy}","received_events_url":"https://api.github.com/users/riking/received_events","type":"User","site_admin":false},"repo":{"id":79275300,"name":"marvin","full_name":"riking/marvin","owner":{"login":"riking","id":627891,"avatar_url":"https://avatars0.githubusercontent.com/u/627891?v=4","gravatar_id":"","url":"https://api.github.com/users/riking","html_url":"https://github.com/riking","followers_url":"https://api.github.com/users/riking/followers","following_url":"https://api.github.com/users/riking/following{/other_user}","gists_url":"https://api.github.com/users/riking/gists{/gist_id}","starred_url":"https://api.github.com/users/riking/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/riking/subscriptions","organizations_url":"https://api.github.com/users/riking/orgs","repos_url":"https://api.github.com/users/riking/repos","events_url":"https://api.github.com/users/riking/events{/privacy}","received_events_url":"https://api.github.com/users/riking/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/riking/marvin","description":"Slack bot for 42 USA","fork":false,"url":"https://api.github.com/repos/riking/marvin","forks_url":"https://api.github.com/repos/riking/marvin/forks","keys_url":"https://api.github.com/repos/riking/marvin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/riking/marvin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/riking/marvin/teams","hooks_url":"https://api.github.com/repos/riking/marvin/hooks","issue_events_url":"https://api.github.com/repos/riking/marvin/issues/events{/number}","events_url":"https://api.github.com/repos/riking/marvin/events","assignees_url":"https://api.github.com/repos/riking/marvin/assignees{/user}","branches_url":"https://api.github.com/repos/riking/marvin/branches{/branch}","tags_url":"https://api.github.com/repos/riking/marvin/tags","blobs_url":"https://api.github.com/repos/riking/marvin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/riking/marvin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/riking/marvin/git/refs{/sha}","trees_url":"https://api.github.com/repos/riking/marvin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/riking/marvin/statuses/{sha}","languages_url":"https://api.github.com/repos/riking/marvin/languages","stargazers_url":"https://api.github.com/repos/riking/marvin/stargazers","contributors_url":"https://api.github.com/repos/riking/marvin/contributors","subscribers_url":"https://api.github.com/repos/riking/marvin/subscribers","subscription_url":"https://api.github.com/repos/riking/marvin/subscription","commits_url":"https://api.github.com/repos/riking/marvin/commits{/sha}","git_commits_url":"https://api.github.com/repos/riking/marvin/git/commits{/sha}","comments_url":"https://api.github.com/repos/riking/marvin/comments{/number}","issue_comment_url":"https://api.github.com/repos/riking/marvin/issues/comments{/number}","contents_url":"https://api.github.com/repos/riking/marvin/contents/{+path}","compare_url":"https://api.github.com/repos/riking/marvin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/riking/marvin/merges","archive_url":"https://api.github.com/repos/riking/marvin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/riking/marvin/downloads","issues_url":"https://api.github.com/repos/riking/marvin/issues{/number}","pulls_url":"https://api.github.com/repos/riking/marvin/pulls{/number}","milestones_url":"https://api.github.com/repos/riking/marvin/milestones{/number}","notifications_url":"https://api.github.com/repos/riking/marvin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/riking/marvin/labels{/name}","releases_url":"https://api.github.com/repos/riking/marvin/releases{/id}","deployments_url":"https://api.github.com/repos/riking/marvin/deployments","created_at":"2017-01-17T21:47:21Z","updated_at":"2017-08-29T19:03:29Z","pushed_at":"2017-08-29T23:04:50Z","git_url":"git://github.com/riking/marvin.git","ssh_url":"git@github.com:riking/marvin.git","clone_url":"https://github.com/riking/marvin.git","svn_url":"https://github.com/riking/marvin","homepage":null,"size":3299,"stargazers_count":5,"watchers_count":5,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":10,"forks":2,"open_issues":10,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/riking/marvin/pulls/10"},"html":{"href":"https://github.com/riking/marvin/pull/10"},"issue":{"href":"https://api.github.com/repos/riking/marvin/issues/10"},"comments":{"href":"https://api.github.com/repos/riking/marvin/issues/10/comments"},"review_comments":{"href":"https://api.github.com/repos/riking/marvin/pulls/10/comments"},"review_comment":{"href":"https://api.github.com/repos/riking/marvin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/riking/marvin/pulls/10/commits"},"statuses":{"href":"https://api.github.com/repos/riking/marvin/statuses/3b1c9be5558928d5a84da4adef9e7f7a3b4b46f8"}},"author_association":"NONE"}}
{"actor":{"display_login":"riking"}}