Commit 16802e22 authored by Shawn Tabrizi's avatar Shawn Tabrizi
Browse files

initial commit

parent acd97a72
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
education, socio-economic status, nationality, personal appearance, race,
religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
- The use of sexualized language or imagery and unwelcome sexual attention or
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic
address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at
## Contributing
[fork]: /fork
[pr]: /compare
Hi there! We're thrilled that you'd like to contribute to this project. Your help is essential for keeping it great.
Please note that this project is released with a [Contributor Code of Conduct][code-of-conduct]. By participating in this project you agree to abide by its terms.
## Issues and PRs
If you have suggestions for how this project could be improved, or want to report a bug, open an issue! We'd love all and any contributions. If you have questions, too, we'd love to hear them.
We'd also love PRs. If you're thinking of a large PR, we advise opening up an issue first to talk about it, though! Look at the links below if you're not sure how to open a PR.
## Submitting a pull request
1. [Fork][fork] and clone the repository.
1. Configure and install the dependencies: `npm install`.
1. Make sure the tests pass on your machine: `npm test`, note: these tests also apply the linter, so there's no need to lint separately.
1. Create a new branch: `git checkout -b my-branch-name`.
1. Make your change, add tests, and make sure the tests still pass.
1. Push to your fork and [submit a pull request][pr].
1. Pat your self on the back and wait for your pull request to be reviewed and merged.
Here are a few things you can do that will increase the likelihood of your pull request being accepted:
- Write and update tests.
- Keep your changes as focused as possible. If there are multiple changes you would like to make that are not dependent upon each other, consider submitting them as separate pull requests.
- Write a [good commit message](
Work in Progress pull requests are also welcome to get feedback early on, or if there is something blocked you.
## Resources
- [How to Contribute to Open Source](
- [Using Pull Requests](
- [GitHub Help](
FROM node:12-slim
WORKDIR /usr/src/app
COPY package.json package-lock.json ./
RUN npm ci --production
RUN npm cache clean --force
ENV NODE_ENV="production"
COPY . .
CMD [ "npm", "start" ]
# substrate-tip-bot
A GitHub bot to submit tips on behalf of contributors
> A GitHub App built with [Probot]( that A GitHub bot to submit tips on behalf of the network.
## Setup
# Install dependencies
npm install
# Run the bot
npm start
## Docker
# 1. Build container
docker build -t substrate-tip-bot .
# 2. Start container
docker run -e APP_ID=<app-id> -e PRIVATE_KEY=<pem-value> substrate-tip-bot
## Contributing
If you have suggestions for how substrate-tip-bot could be improved, or want to report a bug, open an issue! We'd love all and any contributions.
For more, check out the [Contributing Guide](
## License
[ISC](LICENSE) © 2021 Shawn Tabrizi <>
# This is a GitHub App Manifest. These settings will be used by default when
# initially configuring your GitHub App.
# NOTE: changing this file will not update your GitHub App settings.
# You must visit to edit them.
# Read more about configuring your GitHub App:
# Read more about GitHub App Manifests:
# The list of events the GitHub App subscribes to.
# Uncomment the event names below to enable them.
# - check_run
# - check_suite
# - commit_comment
# - create
# - delete
# - deployment
# - deployment_status
# - fork
# - gollum
- issue_comment
- issues
# - label
# - milestone
# - member
# - membership
# - org_block
# - organization
# - page_build
# - project
# - project_card
# - project_column
# - public
# - pull_request
# - pull_request_review
# - pull_request_review_comment
# - push
# - release
# - repository
# - repository_import
# - status
# - team
# - team_add
# - watch
# The set of permissions needed by the GitHub App. The format of the object uses
# the permission name for the key (for example, issues) and the access type for
# the value (for example, write).
# Valid values are `read`, `write`, and `none`
# Repository creation, deletion, settings, teams, and collaborators.
# administration: read
# Checks on code.
# checks: read
# Repository contents, commits, branches, downloads, releases, and merges.
# contents: read
# Deployments and deployment statuses.
# deployments: read
# Issues and related comments, assignees, labels, and milestones.
issues: write
# Search repositories, list collaborators, and access repository metadata.
metadata: read
# Retrieve Pages statuses, configuration, and builds, as well as create new builds.
# pages: read
# Pull requests and related comments, assignees, labels, milestones, and merges.
# pull_requests: read
# Manage the post-receive hooks for a repository.
# repository_hooks: read
# Manage repository projects, columns, and cards.
# repository_projects: read
# Retrieve security vulnerability alerts.
# vulnerability_alerts: read
# Commit statuses.
# statuses: read
# Organization members and teams.
# members: read
# View and manage users blocked by the organization.
# organization_user_blocking: read
# Manage organization projects, columns, and cards.
# organization_projects: read
# Manage team discussions and related comments.
# team_discussions: read
# Manage the post-receive hooks for an organization.
# organization_hooks: read
# Get notified of, and update, content references.
# organization_administration: read
# The name of the GitHub App. Defaults to the name specified in package.json
# name: My Probot App
# The homepage of your GitHub App.
# url:
# A description of the GitHub App.
# description: A description of my awesome app
# Set to true when your GitHub App is available to the public or false when it is only accessible to the owner of the app.
# Default: true
# public: false
* This is the main entrypoint to your Probot app
* @param {import('probot').Probot} app
module.exports = (app) => {
// Your code here"Yay, the app was loaded!");
app.on("issue_comment", async (context) => {
let commentText = context.payload.comment.body
if (
!context.payload.issue.hasOwnProperty("pull_request") ||
context.payload.action !== "created" ||
) {
const repo =
const owner = context.payload.repository.owner.login
const pull_number = context.payload.issue.number
// text payload should be: "/tip {network} {small/medium/large/extra large}"
let textParts = commentText.split(" ");
if (textParts.length !== 3) {
postComment(context, `Invalid command! \n payload should be: /tip { network } { small / medium / large / extra large}`);
postComment(context, `Valid command: 1) ${textParts[0]}, 2) ${textParts[1]}, 3) ${textParts[2]}`);
// For more information on building apps:
// To get your app running against GitHub, see:
function postComment(context, body) {
const issueComment = context.issue({
body: body,
return context.octokit.issues.createComment(issueComment);
"name": "substrate-tip-bot",
"version": "1.0.0",
"private": true,
"description": "A GitHub bot to submit tips on behalf of the network.",
"author": "Shawn Tabrizi <>",
"license": "ISC",
"homepage": "",
"keywords": [
"scripts": {
"start": "probot run ./index.js",
"test": "jest"
"dependencies": {
"probot": "^11.0.1"
"devDependencies": {
"jest": "^26.6.3",
"nock": "^13.0.5",
"smee-client": "^1.2.2"
"engines": {
"node": ">= 10.13.0"
"jest": {
"testEnvironment": "node"
"action": "opened",
"issue": {
"number": 1,
"user": {
"login": "hiimbex"
"repository": {
"name": "testing-things",
"owner": {
"login": "hiimbex"
"installation": {
"id": 2
const nock = require("nock");
// Requiring our app implementation
const myProbotApp = require("..");
const { Probot, ProbotOctokit } = require("probot");
// Requiring our fixtures
const payload = require("./fixtures/issues.opened");
const issueCreatedBody = { body: "Thanks for opening this issue!" };
const fs = require("fs");
const path = require("path");
const privateKey = fs.readFileSync(
path.join(__dirname, "fixtures/mock-cert.pem"),
describe("My Probot app", () => {
let probot;
beforeEach(() => {
probot = new Probot({
appId: 123,
// disable request throttling and retries for testing
Octokit: ProbotOctokit.defaults({
retry: { enabled: false },
throttle: { enabled: false },
// Load our app into probot
test("creates a comment when an issue is opened", async () => {
const mock = nock("")
// Test that we correctly return a test token
.reply(200, {
token: "test",
permissions: {
issues: "write",
// Test that a comment is posted
.post("/repos/hiimbex/testing-things/issues/1/comments", (body) => {
return true;
// Receive a webhook event
await probot.receive({ name: "issues", payload });
afterEach(() => {
// For more information about testing with Jest see:
// For more information about testing with Nock see:
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment