|
|
@ -44,17 +44,19 @@ export function app(app: Probot) {
|
|
|
|
const { tailchatClient, groupId, panelId } =
|
|
|
|
const { tailchatClient, groupId, panelId } =
|
|
|
|
createTailchatContextWithConfig(data.content);
|
|
|
|
createTailchatContextWithConfig(data.content);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.log('配置信息', { tailchatClient, groupId, panelId });
|
|
|
|
|
|
|
|
|
|
|
|
// 发送到tailchat
|
|
|
|
// 发送到tailchat
|
|
|
|
const topic = await tailchatClient.call(
|
|
|
|
const { data: topic } = await tailchatClient.call(
|
|
|
|
'plugin:com.msgbyte.topic.create',
|
|
|
|
'plugin:com.msgbyte.topic.create',
|
|
|
|
{
|
|
|
|
{
|
|
|
|
groupId,
|
|
|
|
groupId,
|
|
|
|
panelId,
|
|
|
|
panelId,
|
|
|
|
content: `${ctx.payload.issue.user.login} create Issue\n\ntitle: ${
|
|
|
|
content: `[b]${
|
|
|
|
ctx.payload.issue.title
|
|
|
|
ctx.payload.issue.user.login
|
|
|
|
}\ncontent: ${ctx.payload.issue.body ?? ''}\n\nwebsite: ${
|
|
|
|
}[/b] create Issue:\n\nTitle: ${ctx.payload.issue.title}\nContent: ${
|
|
|
|
ctx.payload.issue.html_url
|
|
|
|
ctx.payload.issue.body ?? ''
|
|
|
|
}`,
|
|
|
|
}\n\nWebsite: ${ctx.payload.issue.html_url}`,
|
|
|
|
meta: {
|
|
|
|
meta: {
|
|
|
|
githubRepoOwner: ctx.payload.repository.owner,
|
|
|
|
githubRepoOwner: ctx.payload.repository.owner,
|
|
|
|
githubRepoName: ctx.payload.repository.name,
|
|
|
|
githubRepoName: ctx.payload.repository.name,
|
|
|
@ -63,6 +65,8 @@ export function app(app: Probot) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.log('Tailchat Topic 创建成功', topic);
|
|
|
|
|
|
|
|
|
|
|
|
await Promise.all([
|
|
|
|
await Promise.all([
|
|
|
|
ctx.octokit.issues.createComment(
|
|
|
|
ctx.octokit.issues.createComment(
|
|
|
|
ctx.issue({
|
|
|
|
ctx.issue({
|
|
|
@ -77,6 +81,8 @@ export function app(app: Probot) {
|
|
|
|
),
|
|
|
|
),
|
|
|
|
metadata(ctx).set(TOPIC_KEY, topic._id),
|
|
|
|
metadata(ctx).set(TOPIC_KEY, topic._id),
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.log('发送相关信息到 Github 完毕');
|
|
|
|
} catch (err) {
|
|
|
|
} catch (err) {
|
|
|
|
console.error(err);
|
|
|
|
console.error(err);
|
|
|
|
|
|
|
|
|
|
|
@ -90,6 +96,7 @@ export function app(app: Probot) {
|
|
|
|
|
|
|
|
|
|
|
|
app.on('issue_comment.created', async (ctx) => {
|
|
|
|
app.on('issue_comment.created', async (ctx) => {
|
|
|
|
if (ctx.isBot) {
|
|
|
|
if (ctx.isBot) {
|
|
|
|
|
|
|
|
console.error('This comment created by Bot, Skip!');
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 发送到tailchat
|
|
|
|
// 发送到tailchat
|
|
|
@ -97,6 +104,7 @@ export function app(app: Probot) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const topicId = await metadata(ctx).get(TOPIC_KEY);
|
|
|
|
const topicId = await metadata(ctx).get(TOPIC_KEY);
|
|
|
|
if (!topicId) {
|
|
|
|
if (!topicId) {
|
|
|
|
|
|
|
|
console.error('Not found topic id, Skip!');
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -107,7 +115,7 @@ export function app(app: Probot) {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
if (!(!Array.isArray(data) && 'content' in data)) {
|
|
|
|
if (!(!Array.isArray(data) && 'content' in data)) {
|
|
|
|
throw new Error('config file type error');
|
|
|
|
throw new Error('Config file type error');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 是配置文件
|
|
|
|
// 是配置文件
|
|
|
@ -120,8 +128,10 @@ export function app(app: Probot) {
|
|
|
|
groupId,
|
|
|
|
groupId,
|
|
|
|
panelId,
|
|
|
|
panelId,
|
|
|
|
topicId,
|
|
|
|
topicId,
|
|
|
|
content: `${ctx.payload.comment.user.login} reply Issue\n\ncontent: ${
|
|
|
|
content: `[b]${
|
|
|
|
ctx.payload.issue.body ?? ''
|
|
|
|
ctx.payload.comment.user.login
|
|
|
|
|
|
|
|
}[/b] reply Issue:\n\nContent: ${
|
|
|
|
|
|
|
|
ctx.payload.comment.body ?? ''
|
|
|
|
}\n\nWebsite: ${ctx.payload.comment.html_url}`,
|
|
|
|
}\n\nWebsite: ${ctx.payload.comment.html_url}`,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} catch (err) {
|
|
|
|
} catch (err) {
|
|
|
|