mirror of
https://github.com/flibusta-apps/book_bot.git
synced 2025-12-06 15:35:35 +01:00
Fix annotations command
This commit is contained in:
@@ -9,8 +9,8 @@ export const AUTHOR_BOOKS_PREFIX = 'ba_';
|
|||||||
export const TRANSLATOR_BOOKS_PREFIX = 'bt_';
|
export const TRANSLATOR_BOOKS_PREFIX = 'bt_';
|
||||||
export const SEQUENCE_BOOKS_PREFIX = 'bs_';
|
export const SEQUENCE_BOOKS_PREFIX = 'bs_';
|
||||||
|
|
||||||
export const BOOK_ANNOTATION_PREFIX = 'a_info_';
|
export const BOOK_ANNOTATION_PREFIX = 'a_an_';
|
||||||
export const AUTHOR_ANNOTATION_PREFIX = 'b_info_';
|
export const AUTHOR_ANNOTATION_PREFIX = 'b_an_';
|
||||||
|
|
||||||
export const RANDOM_BOOK = 'random_book';
|
export const RANDOM_BOOK = 'random_book';
|
||||||
export const RANDOM_AUTHOR = 'random_author';
|
export const RANDOM_AUTHOR = 'random_author';
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ export function formatBook(book: AllBookTypes, short: boolean = false): string {
|
|||||||
response.push(`📖 ${book.title} | ${book.lang}`);
|
response.push(`📖 ${book.title} | ${book.lang}`);
|
||||||
|
|
||||||
if (book.annotation_exists) {
|
if (book.annotation_exists) {
|
||||||
response.push(`📝 Аннотация: /b_info_${book.id}`)
|
response.push(`📝 Аннотация: /b_an_${book.id}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isTranslatorBook(book) && book.authors.length > 0) {
|
if (isTranslatorBook(book) && book.authors.length > 0) {
|
||||||
@@ -58,7 +58,7 @@ export function formatAuthor(author: Author): string {
|
|||||||
response.push(`/a_${author.id}`);
|
response.push(`/a_${author.id}`);
|
||||||
|
|
||||||
if (author.annotation_exists) {
|
if (author.annotation_exists) {
|
||||||
response.push(`📝 Аннотация: /a_info_${author.id}`);
|
response.push(`📝 Аннотация: /a_an_${author.id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return response.join('\n');
|
return response.join('\n');
|
||||||
@@ -72,7 +72,7 @@ export function formatTranslator(author: Author): string {
|
|||||||
response.push(`/t_${author.id}`);
|
response.push(`/t_${author.id}`);
|
||||||
|
|
||||||
if (author.annotation_exists) {
|
if (author.annotation_exists) {
|
||||||
response.push(`📝 Аннотация: /a_info_${author.id}`);
|
response.push(`📝 Аннотация: /a_an_${author.id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return response.join('\n');
|
return response.join('\n');
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ export async function createApprovedBot(token: string, state: BotState): Promise
|
|||||||
|
|
||||||
bot.hears(new RegExp(`^/d_[a-zA-Z0-9]+_[\\d]+(@${me.username})*$`), async (ctx) => sendFile(ctx, state));
|
bot.hears(new RegExp(`^/d_[a-zA-Z0-9]+_[\\d]+(@${me.username})*$`), async (ctx) => sendFile(ctx, state));
|
||||||
|
|
||||||
bot.hears(new RegExp(`^/b_info_[\\d]+(@${me.username})*$`), async (ctx: Context) => {
|
bot.hears(new RegExp(`^/b_an_[\\d]+(@${me.username})*$`), async (ctx: Context) => {
|
||||||
if (!ctx.message || !('text' in ctx.message)) {
|
if (!ctx.message || !('text' in ctx.message)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -235,7 +235,7 @@ export async function createApprovedBot(token: string, state: BotState): Promise
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
bot.hears(new RegExp(`^/a_info_[\\d]+(@${me.username})*$`), async (ctx: Context) => {
|
bot.hears(new RegExp(`^/a_an_[\\d]+(@${me.username})*$`), async (ctx: Context) => {
|
||||||
if (!ctx.message || !('text' in ctx.message)) {
|
if (!ctx.message || !('text' in ctx.message)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user