Skip to content

Commit 0a6152a

Browse files
author
Frank
committed
fix /opencode trigger
1 parent f108910 commit 0a6152a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

github/index.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ let exitCode = 0
128128
type PromptFiles = Awaited<ReturnType<typeof getUserPrompt>>["promptFiles"]
129129

130130
try {
131-
await assertOpencodeConnected()
132-
133131
assertContextEvent("issue_comment")
132+
assertPayloadKeyword()
133+
await assertOpencodeConnected()
134134

135135
accessToken = await getAccessToken()
136136
octoRest = new Octokit({ auth: accessToken })
@@ -241,6 +241,14 @@ function createOpencode() {
241241
}
242242
}
243243

244+
function assertPayloadKeyword() {
245+
const payload = useContext().payload as IssueCommentEvent
246+
const body = payload.comment.body.trim()
247+
if (!body.match(/(?:^|\s)(?:\/opencode|\/oc)(?=$|\s)/)) {
248+
throw new Error("Comments must mention `/opencode` or `/oc`")
249+
}
250+
}
251+
244252
async function assertOpencodeConnected() {
245253
let retry = 0
246254
let connected = false

0 commit comments

Comments
 (0)