Skip to content

Commit

Permalink
Merge pull request #9 from ConnectAI-E/feature-callback-v2
Browse files Browse the repository at this point in the history
feature callback v2
  • Loading branch information
OPChips authored Nov 5, 2024
2 parents 9b1ad37 + 5aa67cb commit a62c675
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "botops",
"type": "module",
"version": "0.0.11",
"version": "0.0.12",
"packageManager": "[email protected]",
"description": "📦A modern cli tool that deploy chatbot fast,supporting Feishu, DingTalk, Discord, and Slack.",
"author": "river <[email protected]>",
Expand Down Expand Up @@ -83,7 +83,7 @@
"typescript": "^5.0.4",
"unbuild": "^1.2.1",
"vite": "^4.3.9",
"vitest": "^0.31.3"
"vitest": "^1.6.0"
},
"simple-git-hooks": {
"pre-commit": "pnpm lint-staged"
Expand Down
29 changes: 29 additions & 0 deletions packages/feishuapi/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,35 @@ class BotManager {

return result.data
}

async addBotCallBackV2(appId: string, url: string) {
let result
try {
result = await this.cfg.aPostRequest(`developers/v1/callback/update_url/${appId}`, {
verificationUrl: url,
})
}
catch (e: any) {
console.log(e.response.data)
}
return result.data
}

async updateBotCallBackV2(appId: string, callbacks: string[], operation: 'add' | 'del' = 'add') {
// callbacks: ["card.action.trigger", "card.action.trigger_v1", "url.preview.get", "profile.view.get"]
let result
try {
result = await this.cfg.aPostRequest(`developers/v1/callback/update/${appId}`, {
callbackMode: 1,
callbacks,
operation,
})
}
catch (e: any) {
console.log(e.response.data)
}
return result.data
}
}

export interface versionMeta {
Expand Down
18 changes: 15 additions & 3 deletions packages/feishuapi/test/app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import type { AppInfo, EventUrlInfo } from '../src/app'
import { FeishuAppPlus, OpenApp } from '../src/app'

const testConfig: FeishuLoginCookies = {
lark_oapi_csrf_token: 'iWlO+bXQoO+StV+YXqROtR+IFnmSckEYFQdLCaynZgI=',
session: 'XN0YXJ0-02asc1af-0e16-4dbe-97a5-c192d4b72016-WVuZA',
lark_oapi_csrf_token: '',
session: '',
}

const config = new Configuration(testConfig)
Expand Down Expand Up @@ -138,7 +138,7 @@ describe('scoop', async () => {
})
describe('bot', async () => {
await app.init()
const id = 'cli_a52ca0ba25b2100d'
const id = 'cli_a55e2240aeb85013'
it('enable bot', async () => {
const result = await app.botManager.enableBot(id)
console.log(JSON.stringify(result))
Expand Down Expand Up @@ -183,6 +183,18 @@ describe('bot', async () => {
console.log(JSON.stringify(result))
expect(result).not.toBeUndefined()
})
it('add BotCallBack v2', async () => {
const verificationUrl = ''
const result = await app.botManager.addBotCallBackV2(id, verificationUrl)
console.log(JSON.stringify(result))
expect(result).not.toBeUndefined()
})
it('update BotCallBack v2', async () => {
const callbacks = ['card.action.trigger']
const result = await app.botManager.updateBotCallBackV2(id, callbacks)
console.log(JSON.stringify(result))
expect(result).not.toBeUndefined()
})
})
describe('event test', async () => {
await app.init()
Expand Down

0 comments on commit a62c675

Please sign in to comment.