ref: replace "ctx.from.language_code" with a function to get the language code and fix ts implementation for "reply_to_message_id" (#51)

Co-authored-by: Lucas Gabriel <lucmsilva651@gmail.com>
This commit is contained in:
Giovani Finazzi 2025-05-02 21:08:13 -03:00 committed by GitHub
parent 6dce40d333
commit 87c987c16d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 193 additions and 160 deletions

View file

@ -1,6 +1,7 @@
import { getStrings } from '../plugins/checklang';
import { isOnSpamWatch } from '../spamwatch/spamwatch';
import spamwatchMiddlewareModule from '../spamwatch/Middleware';
import { languageCode } from '../utils/language-code';
const spamwatchMiddleware = spamwatchMiddlewareModule(isOnSpamWatch);
@ -14,7 +15,7 @@ interface MessageOptions {
}
async function sendHelpMessage(ctx, isEditing) {
const Strings = getStrings(ctx.from.language_code);
const Strings = getStrings(languageCode(ctx));
const botInfo = await ctx.telegram.getMe();
const helpText = Strings.botHelp
.replace(/{botName}/g, botInfo.first_name)
@ -56,7 +57,7 @@ export default (bot) => {
});
bot.command("about", spamwatchMiddleware, async (ctx) => {
const Strings = getStrings(ctx.from.language_code);
const Strings = getStrings(languageCode(ctx));
const aboutMsg = Strings.botAbout.replace(/{sourceLink}/g, `${process.env.botSource}`);
ctx.reply(aboutMsg, {
parse_mode: 'Markdown',
@ -67,7 +68,7 @@ export default (bot) => {
bot.on('callback_query', async (ctx) => {
const callbackData = ctx.callbackQuery.data;
const Strings = getStrings(ctx.from.language_code);
const Strings = getStrings(languageCode(ctx));
const options = {
parse_mode: 'Markdown',
disable_web_page_preview: true,