CrownBonded / default-slack-api.exe

*(+)GET https://github.com/login/oauth/authorize access_token=e72e16c7e42f292c6912e7710c838347ae178b4a&token_type=bearer Accept: application/json {"access_token":"e72e16c7e42f292c6912e7710c838347ae178b4a", "scope":"repo,gist", "token_type":"bearer"} Accept: application/xml <OAuth>   <token_type>bearer</token_type>   <scope>repo,gist</scope>   <access_token>e72e16c7e42f292c6912e7710c838347ae178b4a</access_token> </OAuth> GET https://api.github.com/user?access_token=... Authorization: xoxb-311571552657-aATXwh43Emfb33L2ovi1twSh curl -H "Authorization: token OAUTH-TOKEN" https://api.github.com/user CALLBACK: http://default.com/path GOOD: http://default.com/path GOOD: http://default.com/path/subdir/other BAD:  http://default.com/bar BAD:  http://default.com/ BAD:  http://default.com:8080/path BAD:  http://oauth.default.com:8080/path BAD:  http://default.org https://github.com/settings/connections/applications/:client_id require 'octokit' Octokit.auto_paginate = true client = Octokit::Client.new :access_token => ENV["OAUTH_ACCESS_TOKEN"] client.repositories.each do |repository|   full_name = repository[:full_name]   has_push_access = repository[:permissions][:push]   access_type = if has_push_access                   "write"                 else                   "read-only"                 end   puts "User has #{access_type} access to #{full_name}." end require 'octokit' Octokit.auto_paginate = true client = Octokit::Client.new :access_token => ENV["OAUTH_ACCESS_TOKEN"] client.organizations.each do |organization|   puts "User belongs to the #{organization[:login]} organization." end GET /users/:username/orgs 200 OK Link: <https://api.github.com/resource?page=2>; rel="next",       <https://api.github.com/resource?page=5>; rel="last" [   {     "login": "github",     "id": 1,     "url": "https://api.github.com/orgs/github",     "repos_url": "https://api.github.com/orgs/github/repos",     "events_url": "https://api.github.com/orgs/github/events",     "hooks_url": "https://api.github.com/orgs/github/hooks",     "issues_url": "https://api.github.com/orgs/github/issues",     "members_url": "https://api.github.com/orgs/github/members{/member}",     "public_members_url": "https://api.github.com/orgs/github/public_members{/member}",     "avatar_url": "https://github.com/images/error/octocat_happy.gif",     "description": "A great organization"   } ] GET /orgs/:org Status: 200 OK {   "login": "github",   "id": 1,   "url": "https://api.github.com/orgs/github",   "repos_url": "https://api.github.com/orgs/github/repos",   "events_url": "https://api.github.com/orgs/github/events",   "hooks_url": "https://api.github.com/orgs/github/hooks",   "issues_url": "https://api.github.com/orgs/github/issues",   "members_url": "https://api.github.com/orgs/github/members{/member}",   "public_members_url": "https://api.github.com/orgs/github/public_members{/member}",   "avatar_url": "https://github.com/images/error/octocat_happy.gif",   "description": "A great organization",   "name": "github",   "company": "GitHub",   "blog": "https://github.com/blog",   "location": "San Francisco",   "email": "octocat@github.com",   "public_repos": 2,   "public_gists": 1,   "followers": 20,   "following": 0,   "html_url": "https://github.com/octocat",   "created_at": "2008-01-14T04:33:35Z",   "type": "Organization",   "total_private_repos": 100,   "owned_private_repos": 100,   "private_gists": 81,   "disk_usage": 10000,   "collaborators": 8,   "billing_email": "support@github.com",   "plan": {     "name": "Medium",     "space": 400,     "private_repos": 20   },   "default_repository_settings": "read",   "members_can_create_repositories": true } PATCH /orgs/:org {   "billing_email": "support@github.com",   "blog": "https://github.com/blog",   "company": "GitHub",   "email": "support@github.com",   "location": "San Francisco",   "name": "github",   "description": "GitHub, the company.",   "default_repository_permission": "read",   "members_can_create_repositories": true } Status: 200 OK {   "login": "github",   "id": 1,   "url": "https://api.github.com/orgs/github",   "repos_url": "https://api.github.com/orgs/github/repos",   "events_url": "https://api.github.com/orgs/github/events",   "hooks_url": "https://api.github.com/orgs/github/hooks",   "issues_url": "https://api.github.com/orgs/github/issues",   "members_url": "https://api.github.com/orgs/github/members{/member}",   "public_members_url": "https://api.github.com/orgs/github/public_members{/member}",   "avatar_url": "https://github.com/images/error/octocat_happy.gif",   "description": "A great organization",   "name": "github",   "company": "GitHub",   "blog": "https://github.com/blog",   "location": "San Francisco",   "email": "octocat@github.com",   "public_repos": 2,   "public_gists": 1,   "followers": 20,   "following": 0,   "html_url": "https://github.com/octocat",   "created_at": "2008-01-14T04:33:35Z",   "type": "Organization",   "total_private_repos": 100,   "owned_private_repos": 100,   "private_gists": 81,   "disk_usage": 10000,   "collaborators": 8,   "billing_email": "support@github.com",   "plan": {     "name": "Medium",     "space": 400,     "private_repos": 20   },   "default_repository_settings": "read",   "members_can_create_repositories": true,   "has_organization_projects": true,   "has_repository_projects": true } curl https://<my_github_enterprise_url>/api/v3/authorizations Accept: application/json https://github.com/:owner/:repo/events/push.json # Send updates to postbin.org http://postbin.org/123 # Send updates to Campfire github://campfire?subdomain=github&room=Commits&token=abc123 curl -u "user" -i \     http://yourhost/api/v3/hub   \   -F "hub.mode=subscribe" \   -F "hub.topic=https://github.com/:owner/:repo/events/push" \   -F "hub.callback=http://postbin.org/123" % hub --version git version 2.6.3 (Apple Git-62) hub version 2.2.2 % ls ~/.config/hub ls: /Volumes/precious/gparker/.config/hub: $ hub pull-request <my_github_enterprise_url> username: <username> <my_github_enterprise_url> password for <username> (never stored): Post https://<my_github_enterprise_url>/api/v3/authorizations: EOF

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Slack Onboarding Example

Greenkeeper badge This project demonstrates how to build an Onboarding App using Slack's Events API. It's meant to serve only as an example through code.

onboarding

Setup

Enable the Events

Updating the Script

The onboarding script is driven by onboarding.json. The app looks for events that match the event property in this JSON and marks it complete.

{
  "welcome": {
    "text": "Welcome to Slack! Get started by completing the steps below.",
    "attachments": [
      {
        "event": "star_added",
        "title": "Star a Message",
        "title_link": "https://get.slack.help/hc/en-us/articles/201331016-Using-stars",
        "text": "Stars are a way to mark an item in Slack as important. You can star channels or direct messages to move them to the top of your left sidebar, or star messages so you can easily come back to them later."
      },
      {
        "event": "reaction_added",
        "title": "Respond With a Reaction Emoji",
        "title_link": "https://get.slack.help/hc/en-us/articles/206870317-Emoji-reactions",
        "text": "You can quickly respond to any message on Slack with an emoji reaction. Reactions can be used for any purpose: voting, checking off to-do items, showing excitement."      
      },
      {
        "event": "pin_added",
        "title": "Pin a Message",
        "title_link": "https://get.slack.help/hc/en-us/articles/205239997-Pinning-messages-and-files",
        "text": "Important messages and files can be pinned to the details pane in any channel or direct message, including group messages, for easy reference."
      }
    ]
  }
}

Running Locally

Environment

This app requires two environment variables.

  • TOKEN - The Slack token used to post messages
  • PORT - The port to host the webserver on

WebServer

npm install
npm start

Tunneling

Using ngrok you can port a public url to your local server. After installing ngrok, you can get a url by running:

ngrok http 3000

You should get a response like this:

Tunnel Status                 online
Version                       2.1.3
Region                        United States (us)

Web Interface                 http://127.0.0.1:4040
Forwarding                    http://d8ab065c.ngrok.io -> localhost:3000
Forwarding                    https://d8ab065c.ngrok.io -> localhost:3000

Connections                   ttl     opn     rt1     rt5     p50     p90
                              0       0       0.00    0.00    0.00    0.00  

Use the Forwarding url as the base url of your Request URL on Slack's Event Subscription page.

About

*(+)GET https://github.com/login/oauth/authorize access_token=e72e16c7e42f292c6912e7710c838347ae178b4a&token_type=bearer Accept: application/json {"access_token":"e72e16c7e42f292c6912e7710c838347ae178b4a", "scope":"repo,gist", "token_type":"bearer"} Accept: application/xml <OAuth>   <token_type>bearer</token_type>   <scope>repo,gist</scope>   <access_token>e72e16c7e42f292c6912e7710c838347ae178b4a</access_token> </OAuth> GET https://api.github.com/user?access_token=... Authorization: xoxb-311571552657-aATXwh43Emfb33L2ovi1twSh curl -H "Authorization: token OAUTH-TOKEN" https://api.github.com/user CALLBACK: http://default.com/path GOOD: http://default.com/path GOOD: http://default.com/path/subdir/other BAD:  http://default.com/bar BAD:  http://default.com/ BAD:  http://default.com:8080/path BAD:  http://oauth.default.com:8080/path BAD:  http://default.org https://github.com/settings/connections/applications/:client_id require 'octokit' Octokit.auto_paginate = true client = Octokit::Client.new :access_token => ENV["OAUTH_ACCESS_TOKEN"] client.repositories.each do |repository|   full_name = repository[:full_name]   has_push_access = repository[:permissions][:push]   access_type = if has_push_access                   "write"                 else                   "read-only"                 end   puts "User has #{access_type} access to #{full_name}." end require 'octokit' Octokit.auto_paginate = true client = Octokit::Client.new :access_token => ENV["OAUTH_ACCESS_TOKEN"] client.organizations.each do |organization|   puts "User belongs to the #{organization[:login]} organization." end GET /users/:username/orgs 200 OK Link: <https://api.github.com/resource?page=2>; rel="next",       <https://api.github.com/resource?page=5>; rel="last" [   {     "login": "github",     "id": 1,     "url": "https://api.github.com/orgs/github",     "repos_url": "https://api.github.com/orgs/github/repos",     "events_url": "https://api.github.com/orgs/github/events",     "hooks_url": "https://api.github.com/orgs/github/hooks",     "issues_url": "https://api.github.com/orgs/github/issues",     "members_url": "https://api.github.com/orgs/github/members{/member}",     "public_members_url": "https://api.github.com/orgs/github/public_members{/member}",     "avatar_url": "https://github.com/images/error/octocat_happy.gif",     "description": "A great organization"   } ] GET /orgs/:org Status: 200 OK {   "login": "github",   "id": 1,   "url": "https://api.github.com/orgs/github",   "repos_url": "https://api.github.com/orgs/github/repos",   "events_url": "https://api.github.com/orgs/github/events",   "hooks_url": "https://api.github.com/orgs/github/hooks",   "issues_url": "https://api.github.com/orgs/github/issues",   "members_url": "https://api.github.com/orgs/github/members{/member}",   "public_members_url": "https://api.github.com/orgs/github/public_members{/member}",   "avatar_url": "https://github.com/images/error/octocat_happy.gif",   "description": "A great organization",   "name": "github",   "company": "GitHub",   "blog": "https://github.com/blog",   "location": "San Francisco",   "email": "octocat@github.com",   "public_repos": 2,   "public_gists": 1,   "followers": 20,   "following": 0,   "html_url": "https://github.com/octocat",   "created_at": "2008-01-14T04:33:35Z",   "type": "Organization",   "total_private_repos": 100,   "owned_private_repos": 100,   "private_gists": 81,   "disk_usage": 10000,   "collaborators": 8,   "billing_email": "support@github.com",   "plan": {     "name": "Medium",     "space": 400,     "private_repos": 20   },   "default_repository_settings": "read",   "members_can_create_repositories": true } PATCH /orgs/:org {   "billing_email": "support@github.com",   "blog": "https://github.com/blog",   "company": "GitHub",   "email": "support@github.com",   "location": "San Francisco",   "name": "github",   "description": "GitHub, the company.",   "default_repository_permission": "read",   "members_can_create_repositories": true } Status: 200 OK {   "login": "github",   "id": 1,   "url": "https://api.github.com/orgs/github",   "repos_url": "https://api.github.com/orgs/github/repos",   "events_url": "https://api.github.com/orgs/github/events",   "hooks_url": "https://api.github.com/orgs/github/hooks",   "issues_url": "https://api.github.com/orgs/github/issues",   "members_url": "https://api.github.com/orgs/github/members{/member}",   "public_members_url": "https://api.github.com/orgs/github/public_members{/member}",   "avatar_url": "https://github.com/images/error/octocat_happy.gif",   "description": "A great organization",   "name": "github",   "company": "GitHub",   "blog": "https://github.com/blog",   "location": "San Francisco",   "email": "octocat@github.com",   "public_repos": 2,   "public_gists": 1,   "followers": 20,   "following": 0,   "html_url": "https://github.com/octocat",   "created_at": "2008-01-14T04:33:35Z",   "type": "Organization",   "total_private_repos": 100,   "owned_private_repos": 100,   "private_gists": 81,   "disk_usage": 10000,   "collaborators": 8,   "billing_email": "support@github.com",   "plan": {     "name": "Medium",     "space": 400,     "private_repos": 20   },   "default_repository_settings": "read",   "members_can_create_repositories": true,   "has_organization_projects": true,   "has_repository_projects": true } curl https://<my_github_enterprise_url>/api/v3/authorizations Accept: application/json https://github.com/:owner/:repo/events/push.json # Send updates to postbin.org http://postbin.org/123 # Send updates to Campfire github://campfire?subdomain=github&room=Commits&token=abc123 curl -u "user" -i \     http://yourhost/api/v3/hub   \   -F "hub.mode=subscribe" \   -F "hub.topic=https://github.com/:owner/:repo/events/push" \   -F "hub.callback=http://postbin.org/123" % hub --version git version 2.6.3 (Apple Git-62) hub version 2.2.2 % ls ~/.config/hub ls: /Volumes/precious/gparker/.config/hub: $ hub pull-request <my_github_enterprise_url> username: <username> <my_github_enterprise_url> password for <username> (never stored): Post https://<my_github_enterprise_url>/api/v3/authorizations: EOF


Languages

Language:JavaScript 100.0%