feat: github卡片支持issue和pr (#47)

This commit is contained in:
ikechan8370
2023-05-09 17:37:55 +08:00
committed by GitHub
parent 8ac8e537c1
commit ef57aaa5f7

View File

@@ -182,14 +182,16 @@ export class Fun extends plugin {
async GH (e) {
const api = 'https://opengraph.githubassets.com'
let reg = /github.com\/[a-zA-Z0-9-]{1,39}\/[a-zA-Z0-9_-]{1,100}/
let reg = /github.com\/[a-zA-Z0-9-]{1,39}\/[a-zA-Z0-9_-]{1,100}(?:\/(?:pull|issue)\/\d+)?/
const isMatched = e.msg.match(reg)
const id = 'Yenai'
if (isMatched) {
const res = isMatched[0].split('/')
const [user, repo] = [res[1], res[2].split('#')[0]]
e.reply(segment.image(`${api}/${id}/${user}/${repo}`))
// const res = isMatched[0].split('/')
let path = isMatched[0].replace('github.com/', '')
e.reply(segment.image(`${api}/${id}/${path}`))
// const [user, repo] = [res[1], res[2].split('#')[0]]
// e.reply(segment.image(`${api}/${id}/${user}/${repo}`))
}
}