mirror of
https://github.com/flibusta-apps/book_bot.git
synced 2025-12-06 15:35:35 +01:00
Add author annotations
This commit is contained in:
@@ -150,6 +150,18 @@ export async function createApprovedBot(token: string, state: BotState): Promise
|
||||
ctx.reply(annotation.text);
|
||||
});
|
||||
|
||||
bot.hears(/^\/a_info_[\d]+$/gm, async (ctx: Context) => {
|
||||
if (!ctx.message || !('text' in ctx.message)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const authorId = ctx.message.text.split('_')[2];
|
||||
|
||||
const annotation = await BookLibrary.getAuthorAnnotation(parseInt(authorId));
|
||||
|
||||
ctx.reply(annotation.text);
|
||||
});
|
||||
|
||||
bot.hears(/^\/a_[\d]+$/gm, async (ctx: Context) => {
|
||||
if (!ctx.message || !('text' in ctx.message)) {
|
||||
return;
|
||||
|
||||
@@ -69,6 +69,14 @@ export interface Sequence {
|
||||
}
|
||||
|
||||
|
||||
export interface AuthorAnnnotation {
|
||||
id: number;
|
||||
title: string;
|
||||
text: string;
|
||||
file: string | null;
|
||||
}
|
||||
|
||||
|
||||
export interface BookAnnotation {
|
||||
id: number;
|
||||
title: string;
|
||||
@@ -127,6 +135,11 @@ export async function getBookAnnotation(bookId: number): Promise<BookAnnotation>
|
||||
}
|
||||
|
||||
|
||||
export async function getAuthorAnnotation(authorId: number): Promise<AuthorAnnnotation> {
|
||||
return _makeRequest<AuthorAnnnotation>(`/api/v1/authors/${authorId}/annotation`);
|
||||
}
|
||||
|
||||
|
||||
export async function getAuthorBooks(authorId: number, page: number, allowedLangs: string[]): Promise<Page<AuthorBook>> {
|
||||
const searchParams = getAllowedLangsSearchParams(allowedLangs);
|
||||
searchParams.append('page', page.toString());
|
||||
|
||||
Reference in New Issue
Block a user