{"action":"created","comment":{"url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/pulls/comments/169962623","pull_request_review_id":98573217,"id":169962623,"diff_hunk":"@@ -12,14 +13,35 @@ import { DiscordBridgeConfig } from \"./config\";\n import * as Discord from \"discord.js\";\n import * as log from \"npmlog\";\n import * as Bluebird from \"bluebird\";\n+import { Permissions } from \"discord.js\";\n \n const ICON_URL = \"https://matrix.org/_matrix/media/r0/download/matrix.org/mlxoESwIsTbJrfXyAAogrNxA\";\n const JOIN_DELAY = 6000;\n const HTTP_UNSUPPORTED = 501;\n const ROOM_NAME_PARTS = 2;\n const AGE_LIMIT = 900000; // 15 * 60 * 1000\n+const RETRY_INVITE_ACCEPT_DELAY = 5000; // ms\n \n export class MatrixRoomHandler {\n+\n+  public static GetBotLink(config: any): string {","path":"src/matrixroomhandler.ts","position":23,"original_position":23,"commit_id":"2f2da15671abd641869308d3158f1b8f2a6b3461","original_commit_id":"2f2da15671abd641869308d3158f1b8f2a6b3461","user":{"login":"turt2live","id":1190097,"avatar_url":"https://avatars2.githubusercontent.com/u/1190097?v=4","gravatar_id":"","url":"https://api.github.com/users/turt2live","html_url":"https://github.com/turt2live","followers_url":"https://api.github.com/users/turt2live/followers","following_url":"https://api.github.com/users/turt2live/following{/other_user}","gists_url":"https://api.github.com/users/turt2live/gists{/gist_id}","starred_url":"https://api.github.com/users/turt2live/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/turt2live/subscriptions","organizations_url":"https://api.github.com/users/turt2live/orgs","repos_url":"https://api.github.com/users/turt2live/repos","events_url":"https://api.github.com/users/turt2live/events{/privacy}","received_events_url":"https://api.github.com/users/turt2live/received_events","type":"User","site_admin":false},"body":"This is what tslint made me do :p\r\n\r\nI can update the rule too if desired. This method also feels like it's in the wrong class anyways.","created_at":"2018-02-22T14:01:25Z","updated_at":"2018-02-22T14:01:25Z","html_url":"https://github.com/Half-Shot/matrix-appservice-discord/pull/90#discussion_r169962623","pull_request_url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/pulls/90","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/pulls/comments/169962623"},"html":{"href":"https://github.com/Half-Shot/matrix-appservice-discord/pull/90#discussion_r169962623"},"pull_request":{"href":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/pulls/90"}},"in_reply_to_id":169910233},"pull_request":{"url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/pulls/90","id":170655345,"html_url":"https://github.com/Half-Shot/matrix-appservice-discord/pull/90","diff_url":"https://github.com/Half-Shot/matrix-appservice-discord/pull/90.diff","patch_url":"https://github.com/Half-Shot/matrix-appservice-discord/pull/90.patch","issue_url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/issues/90","number":90,"state":"open","locked":false,"title":"[WIP] Self-service bridging (for existing matrix rooms)","user":{"login":"turt2live","id":1190097,"avatar_url":"https://avatars2.githubusercontent.com/u/1190097?v=4","gravatar_id":"","url":"https://api.github.com/users/turt2live","html_url":"https://github.com/turt2live","followers_url":"https://api.github.com/users/turt2live/followers","following_url":"https://api.github.com/users/turt2live/following{/other_user}","gists_url":"https://api.github.com/users/turt2live/gists{/gist_id}","starred_url":"https://api.github.com/users/turt2live/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/turt2live/subscriptions","organizations_url":"https://api.github.com/users/turt2live/orgs","repos_url":"https://api.github.com/users/turt2live/repos","events_url":"https://api.github.com/users/turt2live/events{/privacy}","received_events_url":"https://api.github.com/users/turt2live/received_events","type":"User","site_admin":false},"body":"# Work in progress\r\n\r\nThis isn't ready to be merged yet, however some initial review would be nice. There's still a couple things to do before I'd say this is safe to merge:\r\n* [ ] Somehow prevent random users from bridging random channels to random rooms (ie: get the permission of the guild to bridge to the new matrix room)\r\n    * This could maybe be done by inspecting the Discord roles/permissions and picking a suitable role/permission for someone in the channel to have. The Discord user could respond to the request to bridge with `!accept` or `!decline` where after 900 seconds `!decline` is assumed (much like the IRC bridge)\r\n* [ ] More extensive testing beyond a local development environment\r\n\r\n# Description\r\n\r\nAddresses https://github.com/Half-Shot/matrix-appservice-discord/issues/72\r\n\r\nThis is done by adding a fairly basic command handler to the bridge. If enabled in the configuration, users around matrix may use `!discord help` in a room of their choice to get more information about how to bridge a channel to their room. By default the self-service options are disabled to prevent accidentally sharing the bot link. This is because up until now the bridge operator was the one to give out the bot link.\r\n\r\nUsers can bridge existing matrix rooms by inviting the bridge to the matrix room (and discord guild), then sending the message `!discord bridge <guild id> <channel id>`. Users need at least power level 50, in most rooms, to bridge a Discord guild. Similarly, they can terminate the bridge in the room by using `!discord unbridge`.\r\n\r\nOnly one channel is permitted per room because the bridge makes heavy use of the context API, which only provides the first `RemoteRoom` it finds. To avoid having to make the switch to a different system, I've opted for a single channel in a room (which is going to be the most popular case anyways).","created_at":"2018-02-22T04:38:29Z","updated_at":"2018-02-22T14:01:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"df90ccaa60bd2aa1fc73e716ef52be80415ed146","assignee":{"login":"Half-Shot","id":2072976,"avatar_url":"https://avatars1.githubusercontent.com/u/2072976?v=4","gravatar_id":"","url":"https://api.github.com/users/Half-Shot","html_url":"https://github.com/Half-Shot","followers_url":"https://api.github.com/users/Half-Shot/followers","following_url":"https://api.github.com/users/Half-Shot/following{/other_user}","gists_url":"https://api.github.com/users/Half-Shot/gists{/gist_id}","starred_url":"https://api.github.com/users/Half-Shot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Half-Shot/subscriptions","organizations_url":"https://api.github.com/users/Half-Shot/orgs","repos_url":"https://api.github.com/users/Half-Shot/repos","events_url":"https://api.github.com/users/Half-Shot/events{/privacy}","received_events_url":"https://api.github.com/users/Half-Shot/received_events","type":"User","site_admin":false},"assignees":[{"login":"Half-Shot","id":2072976,"avatar_url":"https://avatars1.githubusercontent.com/u/2072976?v=4","gravatar_id":"","url":"https://api.github.com/users/Half-Shot","html_url":"https://github.com/Half-Shot","followers_url":"https://api.github.com/users/Half-Shot/followers","following_url":"https://api.github.com/users/Half-Shot/following{/other_user}","gists_url":"https://api.github.com/users/Half-Shot/gists{/gist_id}","starred_url":"https://api.github.com/users/Half-Shot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Half-Shot/subscriptions","organizations_url":"https://api.github.com/users/Half-Shot/orgs","repos_url":"https://api.github.com/users/Half-Shot/repos","events_url":"https://api.github.com/users/Half-Shot/events{/privacy}","received_events_url":"https://api.github.com/users/Half-Shot/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/pulls/90/commits","review_comments_url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/pulls/90/comments","review_comment_url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/issues/90/comments","statuses_url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/statuses/2f2da15671abd641869308d3158f1b8f2a6b3461","head":{"label":"turt2live:travis/self-service","ref":"travis/self-service","sha":"2f2da15671abd641869308d3158f1b8f2a6b3461","user":{"login":"turt2live","id":1190097,"avatar_url":"https://avatars2.githubusercontent.com/u/1190097?v=4","gravatar_id":"","url":"https://api.github.com/users/turt2live","html_url":"https://github.com/turt2live","followers_url":"https://api.github.com/users/turt2live/followers","following_url":"https://api.github.com/users/turt2live/following{/other_user}","gists_url":"https://api.github.com/users/turt2live/gists{/gist_id}","starred_url":"https://api.github.com/users/turt2live/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/turt2live/subscriptions","organizations_url":"https://api.github.com/users/turt2live/orgs","repos_url":"https://api.github.com/users/turt2live/repos","events_url":"https://api.github.com/users/turt2live/events{/privacy}","received_events_url":"https://api.github.com/users/turt2live/received_events","type":"User","site_admin":false},"repo":{"id":95470199,"name":"matrix-appservice-discord","full_name":"turt2live/matrix-appservice-discord","owner":{"login":"turt2live","id":1190097,"avatar_url":"https://avatars2.githubusercontent.com/u/1190097?v=4","gravatar_id":"","url":"https://api.github.com/users/turt2live","html_url":"https://github.com/turt2live","followers_url":"https://api.github.com/users/turt2live/followers","following_url":"https://api.github.com/users/turt2live/following{/other_user}","gists_url":"https://api.github.com/users/turt2live/gists{/gist_id}","starred_url":"https://api.github.com/users/turt2live/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/turt2live/subscriptions","organizations_url":"https://api.github.com/users/turt2live/orgs","repos_url":"https://api.github.com/users/turt2live/repos","events_url":"https://api.github.com/users/turt2live/events{/privacy}","received_events_url":"https://api.github.com/users/turt2live/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/turt2live/matrix-appservice-discord","description":"A bridge between Matrix and Discord.","fork":true,"url":"https://api.github.com/repos/turt2live/matrix-appservice-discord","forks_url":"https://api.github.com/repos/turt2live/matrix-appservice-discord/forks","keys_url":"https://api.github.com/repos/turt2live/matrix-appservice-discord/keys{/key_id}","collaborators_url":"https://api.github.com/repos/turt2live/matrix-appservice-discord/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/turt2live/matrix-appservice-discord/teams","hooks_url":"https://api.github.com/repos/turt2live/matrix-appservice-discord/hooks","issue_events_url":"https://api.github.com/repos/turt2live/matrix-appservice-discord/issues/events{/number}","events_url":"https://api.github.com/repos/turt2live/matrix-appservice-discord/events","assignees_url":"https://api.github.com/repos/turt2live/matrix-appservice-discord/assignees{/user}","branches_url":"https://api.github.com/repos/turt2live/matrix-appservice-discord/branches{/branch}","tags_url":"https://api.github.com/repos/turt2live/matrix-appservice-discord/tags","blobs_url":"https://api.github.com/repos/turt2live/matrix-appservice-discord/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/turt2live/matrix-appservice-discord/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/turt2live/matrix-appservice-discord/git/refs{/sha}","trees_url":"https://api.github.com/repos/turt2live/matrix-appservice-discord/git/trees{/sha}","statuses_url":"https://api.github.com/repos/turt2live/matrix-appservice-discord/statuses/{sha}","languages_url":"https://api.github.com/repos/turt2live/matrix-appservice-discord/languages","stargazers_url":"https://api.github.com/repos/turt2live/matrix-appservice-discord/stargazers","contributors_url":"https://api.github.com/repos/turt2live/matrix-appservice-discord/contributors","subscribers_url":"https://api.github.com/repos/turt2live/matrix-appservice-discord/subscribers","subscription_url":"https://api.github.com/repos/turt2live/matrix-appservice-discord/subscription","commits_url":"https://api.github.com/repos/turt2live/matrix-appservice-discord/commits{/sha}","git_commits_url":"https://api.github.com/repos/turt2live/matrix-appservice-discord/git/commits{/sha}","comments_url":"https://api.github.com/repos/turt2live/matrix-appservice-discord/comments{/number}","issue_comment_url":"https://api.github.com/repos/turt2live/matrix-appservice-discord/issues/comments{/number}","contents_url":"https://api.github.com/repos/turt2live/matrix-appservice-discord/contents/{+path}","compare_url":"https://api.github.com/repos/turt2live/matrix-appservice-discord/compare/{base}...{head}","merges_url":"https://api.github.com/repos/turt2live/matrix-appservice-discord/merges","archive_url":"https://api.github.com/repos/turt2live/matrix-appservice-discord/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/turt2live/matrix-appservice-discord/downloads","issues_url":"https://api.github.com/repos/turt2live/matrix-appservice-discord/issues{/number}","pulls_url":"https://api.github.com/repos/turt2live/matrix-appservice-discord/pulls{/number}","milestones_url":"https://api.github.com/repos/turt2live/matrix-appservice-discord/milestones{/number}","notifications_url":"https://api.github.com/repos/turt2live/matrix-appservice-discord/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/turt2live/matrix-appservice-discord/labels{/name}","releases_url":"https://api.github.com/repos/turt2live/matrix-appservice-discord/releases{/id}","deployments_url":"https://api.github.com/repos/turt2live/matrix-appservice-discord/deployments","created_at":"2017-06-26T17:11:09Z","updated_at":"2017-06-26T17:11:11Z","pushed_at":"2018-02-22T04:28:49Z","git_url":"git://github.com/turt2live/matrix-appservice-discord.git","ssh_url":"git@github.com:turt2live/matrix-appservice-discord.git","clone_url":"https://github.com/turt2live/matrix-appservice-discord.git","svn_url":"https://github.com/turt2live/matrix-appservice-discord","homepage":"","size":1092,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"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":"Half-Shot:develop","ref":"develop","sha":"fdd2b18e11244a5909bad9ce6b47a1a59765ecf5","user":{"login":"Half-Shot","id":2072976,"avatar_url":"https://avatars1.githubusercontent.com/u/2072976?v=4","gravatar_id":"","url":"https://api.github.com/users/Half-Shot","html_url":"https://github.com/Half-Shot","followers_url":"https://api.github.com/users/Half-Shot/followers","following_url":"https://api.github.com/users/Half-Shot/following{/other_user}","gists_url":"https://api.github.com/users/Half-Shot/gists{/gist_id}","starred_url":"https://api.github.com/users/Half-Shot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Half-Shot/subscriptions","organizations_url":"https://api.github.com/users/Half-Shot/orgs","repos_url":"https://api.github.com/users/Half-Shot/repos","events_url":"https://api.github.com/users/Half-Shot/events{/privacy}","received_events_url":"https://api.github.com/users/Half-Shot/received_events","type":"User","site_admin":false},"repo":{"id":61456075,"name":"matrix-appservice-discord","full_name":"Half-Shot/matrix-appservice-discord","owner":{"login":"Half-Shot","id":2072976,"avatar_url":"https://avatars1.githubusercontent.com/u/2072976?v=4","gravatar_id":"","url":"https://api.github.com/users/Half-Shot","html_url":"https://github.com/Half-Shot","followers_url":"https://api.github.com/users/Half-Shot/followers","following_url":"https://api.github.com/users/Half-Shot/following{/other_user}","gists_url":"https://api.github.com/users/Half-Shot/gists{/gist_id}","starred_url":"https://api.github.com/users/Half-Shot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Half-Shot/subscriptions","organizations_url":"https://api.github.com/users/Half-Shot/orgs","repos_url":"https://api.github.com/users/Half-Shot/repos","events_url":"https://api.github.com/users/Half-Shot/events{/privacy}","received_events_url":"https://api.github.com/users/Half-Shot/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Half-Shot/matrix-appservice-discord","description":"A bridge between Matrix and Discord.","fork":false,"url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord","forks_url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/forks","keys_url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/teams","hooks_url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/hooks","issue_events_url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/issues/events{/number}","events_url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/events","assignees_url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/assignees{/user}","branches_url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/branches{/branch}","tags_url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/tags","blobs_url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/git/refs{/sha}","trees_url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/statuses/{sha}","languages_url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/languages","stargazers_url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/stargazers","contributors_url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/contributors","subscribers_url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/subscribers","subscription_url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/subscription","commits_url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/commits{/sha}","git_commits_url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/git/commits{/sha}","comments_url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/comments{/number}","issue_comment_url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/issues/comments{/number}","contents_url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/contents/{+path}","compare_url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/merges","archive_url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/downloads","issues_url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/issues{/number}","pulls_url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/pulls{/number}","milestones_url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/milestones{/number}","notifications_url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/labels{/name}","releases_url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/releases{/id}","deployments_url":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/deployments","created_at":"2016-06-18T23:09:33Z","updated_at":"2018-02-22T08:46:40Z","pushed_at":"2018-02-22T04:38:30Z","git_url":"git://github.com/Half-Shot/matrix-appservice-discord.git","ssh_url":"git@github.com:Half-Shot/matrix-appservice-discord.git","clone_url":"https://github.com/Half-Shot/matrix-appservice-discord.git","svn_url":"https://github.com/Half-Shot/matrix-appservice-discord","homepage":"","size":1052,"stargazers_count":59,"watchers_count":59,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14,"mirror_url":null,"archived":false,"open_issues_count":32,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":14,"open_issues":32,"watchers":59,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/pulls/90"},"html":{"href":"https://github.com/Half-Shot/matrix-appservice-discord/pull/90"},"issue":{"href":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/issues/90"},"comments":{"href":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/issues/90/comments"},"review_comments":{"href":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/pulls/90/comments"},"review_comment":{"href":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/pulls/90/commits"},"statuses":{"href":"https://api.github.com/repos/Half-Shot/matrix-appservice-discord/statuses/2f2da15671abd641869308d3158f1b8f2a6b3461"}},"author_association":"NONE"}}
{"actor":{"display_login":"turt2live"}}