Skip to content

Commit

Permalink
feat(core): add bot avatar in send events
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Apr 7, 2021
1 parent c0738b7 commit 59ebaa4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/adapter-onebot/src/bot.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Bot, Session, segment, camelCase, snakeCase } from 'koishi-core'
import { Bot, Session, segment, camelCase, snakeCase, BotOptions, Adapter } from 'koishi-core'
import * as OneBot from './utils'

export class SenderError extends Error {
Expand Down Expand Up @@ -36,6 +36,11 @@ export class CQBot extends Bot {

_request?(action: string, params: Record<string, any>): Promise<OneBot.Response>

constructor(adapter: Adapter<'onebot'>, options: BotOptions) {
super(adapter, options)
this.avatar = `http://q.qlogo.cn/headimg_dl?dst_uin=${options.selfId}&spec=640`
}

async [Session.send](message: Session, content: string) {
if (!content) return
const { userId, groupId, channelId, channelName } = message
Expand Down
3 changes: 3 additions & 0 deletions packages/koishi-core/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@ export class Bot<P extends Platform> {
author: {
userId: this.selfId,
username: this.username,
avatar: this.avatar,
discriminator: this.discriminator,
isBot: true,
},
})
}
Expand Down

0 comments on commit 59ebaa4

Please sign in to comment.