Skip to content

Commit

Permalink
Merge pull request #379 from psalm/dependabot/npm_and_yarn/probot-12.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dependabot[bot] authored Jul 2, 2021
2 parents bf077fe + 453ba9b commit 236c7de
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 81 deletions.
132 changes: 67 additions & 65 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"test:watch": "jest --watch --notify --notifyMode=change --coverage"
},
"dependencies": {
"probot": "^11.1.0"
"probot": "^12.0.0"
},
"devDependencies": {
"@types/express": "^4.17.12",
Expand Down
30 changes: 15 additions & 15 deletions src/Bot/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {EventPayloads} from '@octokit/webhooks';
import {Context, Probot} from "probot";
import {CommentParser, LinkEntry} from '../CommentParser';
import {Responder} from "../Responder";
Expand All @@ -19,41 +18,42 @@ export class Bot {
this.responses = new Map()
}

async onIssueOpened(context:Context<EventPayloads.WebhookPayloadIssues>) {
async onIssueOpened(context: Context<'issues.opened'>) {
// @ts-ignore - Expression produces a union type that is too complex to represent
const responded = await this.respond(context)
if (false === responded) {
await this.greet(context)
}
}

async onIssueCommentCreated(context: Context<EventPayloads.WebhookPayloadIssueComment>) {
async onIssueCommentCreated(context: Context<'issue_comment.created'>) {
await this.respond(context)
}

async onIssueEdited(context: Context<EventPayloads.WebhookPayloadIssues>) {
async onIssueEdited(context: Context<'issues.edited'>) {
await this.updateResponse(context)
}

async onIssueCommentEdited(context: Context<EventPayloads.WebhookPayloadIssueComment>) {
async onIssueCommentEdited(context: Context<'issue_comment.edited'>) {
await this.updateResponse(context)
}

async onIssueCommentDeleted(context: Context<EventPayloads.WebhookPayloadIssueComment>) {
async onIssueCommentDeleted(context: Context<'issue_comment.deleted'>) {
await this.deleteResponse(context);
}

async onPullRequestOpened(context: Context<EventPayloads.WebhookPayloadPullRequest>) {
async onPullRequestOpened(context: Context<'pull_request.opened'>) {
await this.respond(context)
}

async onPullRequestEdited(context: Context<EventPayloads.WebhookPayloadPullRequest>) {
async onPullRequestEdited(context: Context<'pull_request.edited'>) {
await this.updateResponse(context)
}


private async greet(context: Context<EventPayloads.WebhookPayloadIssues>) {
private async greet(context: Context<'issues'>) {
const issue = context.payload.issue
if (this.responder.shouldGreet(issue.body, context.payload.repository.full_name)) {
if (this.responder.shouldGreet(issue.body ?? '', context.payload.repository.full_name)) {
const issueComment = context.issue({
body: this.responder.greet(issue.user.login)
})
Expand All @@ -63,7 +63,7 @@ export class Bot {
}
}

private async respond(context: Context<EventPayloads.WebhookPayloadIssues>|Context<EventPayloads.WebhookPayloadIssueComment>|Context<EventPayloads.WebhookPayloadPullRequest>): Promise<boolean | null> {
private async respond(context: Context<'issues'>|Context<'issue_comment'>|Context<'pull_request'>): Promise<boolean | null> {
if (context.isBot) {
return null
}
Expand All @@ -77,7 +77,7 @@ export class Bot {
respondingTo = context.payload.issue
}

const links = this.parser.parseComment(respondingTo.body)
const links = this.parser.parseComment(respondingTo.body ?? '')
if (links.length) {
const issueComment = context.issue({
body: await this.makeResponse(links)
Expand All @@ -91,7 +91,7 @@ export class Bot {
}


private async updateResponse(context: Context<EventPayloads.WebhookPayloadIssues>|Context<EventPayloads.WebhookPayloadIssueComment>|Context<EventPayloads.WebhookPayloadPullRequest>) {
private async updateResponse(context: Context<'issues'>|Context<'issue_comment'>|Context<'pull_request'>) {
let respondingTo;
if ('comment' in context.payload) {
respondingTo = context.payload.comment
Expand All @@ -103,7 +103,7 @@ export class Bot {

if (this.responses.has(respondingTo.id)) {
const existingResponseId = this.responses.get(respondingTo.id) as number
const links = this.parser.parseComment(respondingTo.body)
const links = this.parser.parseComment(respondingTo.body ?? '')

if (links.length) {
const issueComment = context.issue({
Expand All @@ -121,7 +121,7 @@ export class Bot {
}


private async deleteResponse(context: Context<EventPayloads.WebhookPayloadIssueComment>) {
private async deleteResponse(context: Context<'issue_comment'>) {
const comment = context.payload.comment;
if (this.responses.has(comment.id)) {
const existingResponseId = this.responses.get(comment.id) as number;
Expand Down

0 comments on commit 236c7de

Please sign in to comment.