-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(qq): internal api, logging, retries (#230)
- Loading branch information
1 parent
bfaff44
commit 92c471b
Showing
9 changed files
with
380 additions
and
370 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,37 @@ | ||
import { Quester } from '@satorijs/satori' | ||
import * as QQ from '../types' | ||
import { GroupInternal } from '.' | ||
|
||
export class GroupInternal { | ||
constructor(private http: () => Quester) { } | ||
|
||
async sendPrivateMessage(openid: string, data: QQ.Message.Request) { | ||
return this.http().post<{ | ||
sendResult: { | ||
msg_id: string | ||
err_msg: string | ||
index: string | ||
} | ||
// id: string | ||
// timestamp: number | ||
}>(`/v2/users/${openid}/messages`, data) | ||
} | ||
|
||
async sendMessage(group_openid: string, data: QQ.Message.Request) { | ||
return this.http().post<{ | ||
group_code: string | ||
msg: string | ||
declare module './internal' { | ||
interface GroupInternal { | ||
sendMessage(channel_id: string, data: QQ.Message.Request): Promise<{ | ||
id: string | ||
timestamp: string | ||
} & { | ||
code: number | ||
message: string | ||
data: any | ||
}>(`/v2/groups/${group_openid}/messages`, data) | ||
}> | ||
sendPrivateMessage(openid: string, data: QQ.Message.Request): Promise<any> | ||
sendFilePrivate(openid: string, data: QQ.Message.File.Request): Promise<any> | ||
sendFileGuild(group_openid: string, data: QQ.Message.File.Request): Promise<any> | ||
acknowledgeInteraction(interaction_id: string, code: number): Promise<any> | ||
} | ||
|
||
async sendFilePrivate(openid: string, data: QQ.Message.File.Request) { | ||
return this.http().post<QQ.Message.File.Response>(`/v2/users/${openid}/files`, data) | ||
} | ||
|
||
async sendFileGuild(group_openid: string, data: QQ.Message.File.Request) { | ||
return this.http().post<QQ.Message.File.Response>(`/v2/groups/${group_openid}/files`, data) | ||
} | ||
|
||
// @TODO enum | ||
async acknowledgeInteraction(interaction_id: string, code: number) { | ||
return this.http().put(`/interactions/${interaction_id}`, { | ||
code, | ||
}) | ||
} | ||
|
||
// async getGuildMembers(group_openid: string, start_index: 0) { | ||
// return this.http().get<{ | ||
// members: { | ||
// member_openid: string | ||
// join_timestamp: number | ||
// }[] | ||
// next_index: number | ||
// }>(`/v2/groups/${group_openid}/members`, { | ||
// params: { | ||
// limit: 500, | ||
// start_index, | ||
// }, | ||
// }) | ||
// } | ||
} | ||
|
||
GroupInternal.define(false, { | ||
'/v2/groups/{channel.id}/messages': { | ||
POST: 'sendMessage', | ||
}, | ||
'/v2/users/{user.id}/messages': { | ||
POST: 'sendPrivateMessage', | ||
}, | ||
'/v2/users/{user.id}/files': { | ||
POST: 'sendFilePrivate', | ||
}, | ||
'/v2/groups/{channel.id}/files': { | ||
POST: 'sendFileGuild', | ||
}, | ||
'/interactions/{interaction.id}/{interaction.token}/callback': { | ||
POST: 'acknowledgeInteraction', | ||
}, | ||
}) |
Oops, something went wrong.