From 19e282453843c5422c5e7c10d7a24b4741feca06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl?= Date: Thu, 25 Dec 2025 15:27:53 -0300 Subject: [PATCH] Remove .history folder from git and add to .gitignore --- .gitignore | 1 + .history/.env_20251216205724 | 2 - .history/.env_20251216210105 | 1 - .history/.env_20251217082418 | 2 - .history/README_20251216201331.md | 62 ------------- .history/README_20251216201351.md | 62 ------------- .history/about_20251216204253.md | 0 .history/about_20251216204256.md | 128 --------------------------- .history/bot_20251216201350.js | 86 ------------------ .history/bot_20251216201358.js | 85 ------------------ .history/bot_20251216201948.js | 97 -------------------- .history/bot_20251216201952.js | 107 ---------------------- .history/bot_20251216201956.js | 107 ---------------------- .history/bot_20251216202004.js | 107 ---------------------- .history/bot_20251216202006.js | 107 ---------------------- .history/bot_20251216202021.js | 107 ---------------------- .history/bot_20251216202022.js | 107 ---------------------- .history/bot_20251216202030.js | 107 ---------------------- .history/bot_20251216202045.js | 107 ---------------------- .history/bot_20251216202046.js | 107 ---------------------- .history/bot_20251216202047.js | 107 ---------------------- .history/bot_20251216202053.js | 107 ---------------------- .history/bot_20251216202108.js | 107 ---------------------- .history/bot_20251216202110.js | 107 ---------------------- .history/bot_20251216202111.js | 107 ---------------------- .history/bot_20251216202116.js | 107 ---------------------- .history/bot_20251216204344.js | 89 ------------------- .history/bot_20251216204356.js | 89 ------------------- .history/bot_20251216204358.js | 89 ------------------- .history/bot_20251216204824.js | 120 ------------------------- .history/bot_20251216204836.js | 120 ------------------------- .history/bot_20251216204928.js | 120 ------------------------- .history/bot_20251216204946.js | 120 ------------------------- .history/bot_20251216204950.js | 120 ------------------------- .history/bot_20251216205010.js | 120 ------------------------- .history/bot_20251216205016.js | 120 ------------------------- .history/bot_20251216205023.js | 120 ------------------------- .history/bot_20251216205028.js | 120 ------------------------- .history/bot_20251216205056.js | 122 ------------------------- .history/bot_20251216205100.js | 122 ------------------------- .history/bot_20251216205103.js | 122 ------------------------- .history/package_20251216201322.json | 23 ----- .history/package_20251216201351.json | 22 ----- .history/package_20251216202006.json | 22 ----- 44 files changed, 1 insertion(+), 3910 deletions(-) delete mode 100644 .history/.env_20251216205724 delete mode 100644 .history/.env_20251216210105 delete mode 100644 .history/.env_20251217082418 delete mode 100644 .history/README_20251216201331.md delete mode 100644 .history/README_20251216201351.md delete mode 100644 .history/about_20251216204253.md delete mode 100644 .history/about_20251216204256.md delete mode 100644 .history/bot_20251216201350.js delete mode 100644 .history/bot_20251216201358.js delete mode 100644 .history/bot_20251216201948.js delete mode 100644 .history/bot_20251216201952.js delete mode 100644 .history/bot_20251216201956.js delete mode 100644 .history/bot_20251216202004.js delete mode 100644 .history/bot_20251216202006.js delete mode 100644 .history/bot_20251216202021.js delete mode 100644 .history/bot_20251216202022.js delete mode 100644 .history/bot_20251216202030.js delete mode 100644 .history/bot_20251216202045.js delete mode 100644 .history/bot_20251216202046.js delete mode 100644 .history/bot_20251216202047.js delete mode 100644 .history/bot_20251216202053.js delete mode 100644 .history/bot_20251216202108.js delete mode 100644 .history/bot_20251216202110.js delete mode 100644 .history/bot_20251216202111.js delete mode 100644 .history/bot_20251216202116.js delete mode 100644 .history/bot_20251216204344.js delete mode 100644 .history/bot_20251216204356.js delete mode 100644 .history/bot_20251216204358.js delete mode 100644 .history/bot_20251216204824.js delete mode 100644 .history/bot_20251216204836.js delete mode 100644 .history/bot_20251216204928.js delete mode 100644 .history/bot_20251216204946.js delete mode 100644 .history/bot_20251216204950.js delete mode 100644 .history/bot_20251216205010.js delete mode 100644 .history/bot_20251216205016.js delete mode 100644 .history/bot_20251216205023.js delete mode 100644 .history/bot_20251216205028.js delete mode 100644 .history/bot_20251216205056.js delete mode 100644 .history/bot_20251216205100.js delete mode 100644 .history/bot_20251216205103.js delete mode 100644 .history/package_20251216201322.json delete mode 100644 .history/package_20251216201351.json delete mode 100644 .history/package_20251216202006.json diff --git a/.gitignore b/.gitignore index 9d82971..c52d64a 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ node_modules/ .env *.log .DS_Store +.history/ diff --git a/.history/.env_20251216205724 b/.history/.env_20251216205724 deleted file mode 100644 index d0ed4fc..0000000 --- a/.history/.env_20251216205724 +++ /dev/null @@ -1,2 +0,0 @@ -#BOT_TOKEN=8531569553:AAFT-SvBHGCDnF_8dvwyEiLRA1ome-p-ttc -BOT_TOKEN=8566687126:AAGw-zhiTml3qZyXfdEkF0Jag5MTCqhO1BU \ No newline at end of file diff --git a/.history/.env_20251216210105 b/.history/.env_20251216210105 deleted file mode 100644 index aee1ac2..0000000 --- a/.history/.env_20251216210105 +++ /dev/null @@ -1 +0,0 @@ -BOT_TOKEN=8531569553:AAFT-SvBHGCDnF_8dvwyEiLRA1ome-p-ttc \ No newline at end of file diff --git a/.history/.env_20251217082418 b/.history/.env_20251217082418 deleted file mode 100644 index d0ed4fc..0000000 --- a/.history/.env_20251217082418 +++ /dev/null @@ -1,2 +0,0 @@ -#BOT_TOKEN=8531569553:AAFT-SvBHGCDnF_8dvwyEiLRA1ome-p-ttc -BOT_TOKEN=8566687126:AAGw-zhiTml3qZyXfdEkF0Jag5MTCqhO1BU \ No newline at end of file diff --git a/.history/README_20251216201331.md b/.history/README_20251216201331.md deleted file mode 100644 index 4c1f45b..0000000 --- a/.history/README_20251216201331.md +++ /dev/null @@ -1,62 +0,0 @@ -# Keyboard Reset Bot - -A minimal Telegram bot that removes reply keyboard buttons in Telegram group chats by sending a keyboard reset message. - -## Features - -- Works only in group chats and supergroups -- Single command: `/resetkeyboard` -- Admin-only authorization -- Automatically removes its confirmation message after 7 seconds -- Stateless (no database, no data storage) - -## Setup - -1. **Get a Bot Token** - - Talk to [@BotFather](https://t.me/botfather) on Telegram - - Create a new bot with `/newbot` - - Copy the bot token - -2. **Install Dependencies** - ```bash - npm install - ``` - -3. **Configure Environment** - - Copy `.env.example` to `.env` - - Add your bot token: - ``` - BOT_TOKEN=your_bot_token_here - ``` - -4. **Run the Bot** - ```bash - npm start - ``` - -## Usage - -1. Add the bot to your Telegram group -2. Grant the bot "Read messages" permission (and optionally "Delete messages" for cleanup) -3. An admin can use `/resetkeyboard` to remove all reply keyboards in the group - -## Requirements - -- Node.js 14+ (ES modules support) -- Bot permissions: "Read messages" (required), "Delete messages" (optional) - -## How It Works - -When an admin sends `/resetkeyboard` in a group: -1. The bot verifies the user is an administrator -2. Sends a message with `ReplyKeyboardRemove` (selective: false) -3. This resets reply keyboards for all users who receive the message -4. The bot deletes its own message after 7 seconds - -## Notes - -- The bot ignores private chats -- Only group administrators can use the command -- The bot is stateless and does not store any data -- If another bot sends a keyboard after reset, it will appear again (expected behavior) - diff --git a/.history/README_20251216201351.md b/.history/README_20251216201351.md deleted file mode 100644 index 4c1f45b..0000000 --- a/.history/README_20251216201351.md +++ /dev/null @@ -1,62 +0,0 @@ -# Keyboard Reset Bot - -A minimal Telegram bot that removes reply keyboard buttons in Telegram group chats by sending a keyboard reset message. - -## Features - -- Works only in group chats and supergroups -- Single command: `/resetkeyboard` -- Admin-only authorization -- Automatically removes its confirmation message after 7 seconds -- Stateless (no database, no data storage) - -## Setup - -1. **Get a Bot Token** - - Talk to [@BotFather](https://t.me/botfather) on Telegram - - Create a new bot with `/newbot` - - Copy the bot token - -2. **Install Dependencies** - ```bash - npm install - ``` - -3. **Configure Environment** - - Copy `.env.example` to `.env` - - Add your bot token: - ``` - BOT_TOKEN=your_bot_token_here - ``` - -4. **Run the Bot** - ```bash - npm start - ``` - -## Usage - -1. Add the bot to your Telegram group -2. Grant the bot "Read messages" permission (and optionally "Delete messages" for cleanup) -3. An admin can use `/resetkeyboard` to remove all reply keyboards in the group - -## Requirements - -- Node.js 14+ (ES modules support) -- Bot permissions: "Read messages" (required), "Delete messages" (optional) - -## How It Works - -When an admin sends `/resetkeyboard` in a group: -1. The bot verifies the user is an administrator -2. Sends a message with `ReplyKeyboardRemove` (selective: false) -3. This resets reply keyboards for all users who receive the message -4. The bot deletes its own message after 7 seconds - -## Notes - -- The bot ignores private chats -- Only group administrators can use the command -- The bot is stateless and does not store any data -- If another bot sends a keyboard after reset, it will appear again (expected behavior) - diff --git a/.history/about_20251216204253.md b/.history/about_20251216204253.md deleted file mode 100644 index e69de29..0000000 diff --git a/.history/about_20251216204256.md b/.history/about_20251216204256.md deleted file mode 100644 index 4323eb8..0000000 --- a/.history/about_20251216204256.md +++ /dev/null @@ -1,128 +0,0 @@ -BOT NAME -Keyboard Reset Bot (working name) - -PURPOSE -A minimal Telegram bot whose only responsibility is to remove reply keyboard buttons in Telegram group chats by sending a keyboard reset message. - -This bot does not manage data, users, state, or configuration beyond a single slash command. - -CORE FUNCTIONAL REQUIREMENTS - -Supported chats -• Group chats -• Supergroups - -The bot must ignore private chats. - -If used in a private chat, it should reply once with: -“This bot only works in groups.” - -Command -Single slash command: - -/resetkeyboard - -No aliases. No parameters. - -Authorization -Only group administrators may trigger the command. - -Authorization rules: -• Check the user who sent /resetkeyboard -• If the user is an administrator or creator → allow -• Otherwise → ignore or reply with: -“Only group admins can use this command.” - -No role persistence. Authorization is checked per command invocation. - -Keyboard removal behavior -When triggered by an authorized user in a group: - -The bot sends one normal message to the group with: - -• reply_markup = ReplyKeyboardRemove -• selective = false - -This message must: -• Be visible (not silent) -• Not be inline -• Not target a specific user - -This resets the reply keyboard for all users who receive the message. - -Message content -Message text should be short and neutral, for example: - -“Keyboard reset.” - -No emojis. -No markdown. -No mentions. - -Message lifecycle -Optional but recommended: - -• The bot deletes its own confirmation message after 5–10 seconds -• Do NOT delete immediately (clients need time to process the keyboard reset) - -If deletion fails (permissions, race condition), the bot must silently continue. - -What the bot must NOT do -The bot must NOT: - -• Store data -• Track users -• Use a database -• React to normal messages -• Remove inline keyboards -• Delete other bots’ messages -• Re-send keyboards -• Perform scheduled actions - -This is a stateless utility bot. - -EDGE CASES AND EXPECTED BEHAVIOR - -• If another bot sends a keyboard after this bot runs, that keyboard will appear again. This is expected. -• If a user does not receive the message (offline/network), their keyboard may persist until the next reset. -• This is the only technically correct way to reset keyboards in Telegram. - -IMPLEMENTATION CONSTRAINTS - -Update handling -Either polling or webhook is acceptable. - -Polling is preferred for simplicity. - -Libraries -Any official or widely used Telegram library is acceptable, such as: - -• python-telegram-bot -• aiogram -• Telegraf (Node.js) -• Raw Bot API (HTTP) - -No unofficial wrappers. - -Permissions required -The bot must be granted: - -• “Read messages” -• “Delete messages” (optional, only for cleanup) - -No admin rights beyond this are required. - -LOGGING AND ERROR HANDLING - -• Log startup success -• Log command usage with chat ID and user ID -• Log authorization failures at debug level -• Fail silently on Telegram API errors (do not spam the group) - -SUCCESS CRITERIA - -The bot is considered correct if: - -• An admin sends /resetkeyboard in a group -• All visible reply keyboards disappear for users in that group -• The bot does nothing else \ No newline at end of file diff --git a/.history/bot_20251216201350.js b/.history/bot_20251216201350.js deleted file mode 100644 index a654944..0000000 --- a/.history/bot_20251216201350.js +++ /dev/null @@ -1,86 +0,0 @@ -import { Telegraf, Markup } from 'telegraf'; -import dotenv from 'dotenv'; - -dotenv.config(); - -const BOT_TOKEN = process.env.BOT_TOKEN; - -if (!BOT_TOKEN) { - console.error('Error: BOT_TOKEN environment variable is not set'); - process.exit(1); -} - -const bot = new Telegraf(BOT_TOKEN); - -// Log startup success -console.log('Keyboard Reset Bot started successfully'); - -// Handle /resetkeyboard command -bot.command('resetkeyboard', async (ctx) => { - const chatId = ctx.chat.id; - const userId = ctx.from.id; - const chatType = ctx.chat.type; - - // Log command usage - console.log(`Command received - Chat ID: ${chatId}, User ID: ${userId}, Chat Type: ${chatType}`); - - // Check if chat is a group or supergroup - if (chatType !== 'group' && chatType !== 'supergroup') { - await ctx.reply('This bot only works in groups.'); - return; - } - - try { - // Check if user is an administrator - const member = await ctx.getChatMember(userId); - const isAdmin = member.status === 'administrator' || member.status === 'creator'; - - if (!isAdmin) { - // Log authorization failure at debug level - console.log(`Authorization failed - Chat ID: ${chatId}, User ID: ${userId}`); - await ctx.reply('Only group admins can use this command.'); - return; - } - - // Send keyboard reset message - const sentMessage = await ctx.reply('Keyboard reset.', { - reply_markup: Markup.removeKeyboard() - }); - - // Log successful reset - console.log(`Keyboard reset successful - Chat ID: ${chatId}, User ID: ${userId}`); - - // Delete the confirmation message after 7 seconds - setTimeout(async () => { - try { - await ctx.deleteMessage(sentMessage.message_id); - } catch (error) { - // Silently continue if deletion fails (permissions, race condition, etc.) - // This is expected behavior - do not log or spam - } - }, 7000); - - } catch (error) { - // Fail silently on Telegram API errors (do not spam the group) - // Only log to console for debugging - console.error('Error processing command:', error.message); - } -}); - -// Handle errors -bot.catch((err, ctx) => { - console.error('Bot error:', err); -}); - -// Start polling -bot.launch().then(() => { - console.log('Bot is polling for updates...'); -}).catch((error) => { - console.error('Failed to start bot:', error); - process.exit(1); -}); - -// Enable graceful stop -process.once('SIGINT', () => bot.stop('SIGINT')); -process.once('SIGTERM', () => bot.stop('SIGTERM')); - diff --git a/.history/bot_20251216201358.js b/.history/bot_20251216201358.js deleted file mode 100644 index 3d47b14..0000000 --- a/.history/bot_20251216201358.js +++ /dev/null @@ -1,85 +0,0 @@ -import { Telegraf, Markup } from 'telegraf'; -import dotenv from 'dotenv'; - -dotenv.config(); - -const BOT_TOKEN = process.env.BOT_TOKEN; - -if (!BOT_TOKEN) { - console.error('Error: BOT_TOKEN environment variable is not set'); - process.exit(1); -} - -const bot = new Telegraf(BOT_TOKEN); - -// Log startup success -console.log('Keyboard Reset Bot started successfully'); - -// Handle /resetkeyboard command -bot.command('resetkeyboard', async(ctx) => { - const chatId = ctx.chat.id; - const userId = ctx.from.id; - const chatType = ctx.chat.type; - - // Log command usage - console.log(`Command received - Chat ID: ${chatId}, User ID: ${userId}, Chat Type: ${chatType}`); - - // Check if chat is a group or supergroup - if (chatType !== 'group' && chatType !== 'supergroup') { - await ctx.reply('This bot only works in groups.'); - return; - } - - try { - // Check if user is an administrator - const member = await ctx.getChatMember(userId); - const isAdmin = member.status === 'administrator' || member.status === 'creator'; - - if (!isAdmin) { - // Log authorization failure at debug level - console.log(`Authorization failed - Chat ID: ${chatId}, User ID: ${userId}`); - await ctx.reply('Only group admins can use this command.'); - return; - } - - // Send keyboard reset message - const sentMessage = await ctx.reply('Keyboard reset.', { - reply_markup: Markup.removeKeyboard() - }); - - // Log successful reset - console.log(`Keyboard reset successful - Chat ID: ${chatId}, User ID: ${userId}`); - - // Delete the confirmation message after 7 seconds - setTimeout(async() => { - try { - await ctx.deleteMessage(sentMessage.message_id); - } catch (error) { - // Silently continue if deletion fails (permissions, race condition, etc.) - // This is expected behavior - do not log or spam - } - }, 7000); - - } catch (error) { - // Fail silently on Telegram API errors (do not spam the group) - // Only log to console for debugging - console.error('Error processing command:', error.message); - } -}); - -// Handle errors -bot.catch((err, ctx) => { - console.error('Bot error:', err); -}); - -// Start polling -bot.launch().then(() => { - console.log('Bot is polling for updates...'); -}).catch((error) => { - console.error('Failed to start bot:', error); - process.exit(1); -}); - -// Enable graceful stop -process.once('SIGINT', () => bot.stop('SIGINT')); -process.once('SIGTERM', () => bot.stop('SIGTERM')); \ No newline at end of file diff --git a/.history/bot_20251216201948.js b/.history/bot_20251216201948.js deleted file mode 100644 index 685003e..0000000 --- a/.history/bot_20251216201948.js +++ /dev/null @@ -1,97 +0,0 @@ -import { Telegraf, Markup } from 'telegraf'; -import dotenv from 'dotenv'; - -dotenv.config(); - -const BOT_TOKEN = process.env.BOT_TOKEN; - -if (!BOT_TOKEN) { - console.error('Error: BOT_TOKEN environment variable is not set'); - process.exit(1); -} - -const bot = new Telegraf(BOT_TOKEN); - -// Log startup success -console.log('Keyboard Reset Bot started successfully'); - -// Debug: Log all incoming updates to see if bot is receiving messages -bot.use(async (ctx, next) => { - console.log('Update received:', { - updateType: ctx.updateType, - chatType: ctx.chat?.type, - chatId: ctx.chat?.id, - fromId: ctx.from?.id, - text: ctx.message?.text || ctx.update.message?.text || 'N/A' - }); - return next(); -}); - -// Handle /resetkeyboard command -bot.command('resetkeyboard', async(ctx) => { - const chatId = ctx.chat.id; - const userId = ctx.from.id; - const chatType = ctx.chat.type; - - // Log command usage - console.log(`Command received - Chat ID: ${chatId}, User ID: ${userId}, Chat Type: ${chatType}`); - - // Check if chat is a group or supergroup - if (chatType !== 'group' && chatType !== 'supergroup') { - await ctx.reply('This bot only works in groups.'); - return; - } - - try { - // Check if user is an administrator - const member = await ctx.getChatMember(userId); - const isAdmin = member.status === 'administrator' || member.status === 'creator'; - - if (!isAdmin) { - // Log authorization failure at debug level - console.log(`Authorization failed - Chat ID: ${chatId}, User ID: ${userId}`); - await ctx.reply('Only group admins can use this command.'); - return; - } - - // Send keyboard reset message - const sentMessage = await ctx.reply('Keyboard reset.', { - reply_markup: Markup.removeKeyboard() - }); - - // Log successful reset - console.log(`Keyboard reset successful - Chat ID: ${chatId}, User ID: ${userId}`); - - // Delete the confirmation message after 7 seconds - setTimeout(async() => { - try { - await ctx.deleteMessage(sentMessage.message_id); - } catch (error) { - // Silently continue if deletion fails (permissions, race condition, etc.) - // This is expected behavior - do not log or spam - } - }, 7000); - - } catch (error) { - // Fail silently on Telegram API errors (do not spam the group) - // Only log to console for debugging - console.error('Error processing command:', error.message); - } -}); - -// Handle errors -bot.catch((err, ctx) => { - console.error('Bot error:', err); -}); - -// Start polling -bot.launch().then(() => { - console.log('Bot is polling for updates...'); -}).catch((error) => { - console.error('Failed to start bot:', error); - process.exit(1); -}); - -// Enable graceful stop -process.once('SIGINT', () => bot.stop('SIGINT')); -process.once('SIGTERM', () => bot.stop('SIGTERM')); \ No newline at end of file diff --git a/.history/bot_20251216201952.js b/.history/bot_20251216201952.js deleted file mode 100644 index 7cb4497..0000000 --- a/.history/bot_20251216201952.js +++ /dev/null @@ -1,107 +0,0 @@ -import { Telegraf, Markup } from 'telegraf'; -import dotenv from 'dotenv'; - -dotenv.config(); - -const BOT_TOKEN = process.env.BOT_TOKEN; - -if (!BOT_TOKEN) { - console.error('Error: BOT_TOKEN environment variable is not set'); - process.exit(1); -} - -const bot = new Telegraf(BOT_TOKEN); - -// Log startup success -console.log('Keyboard Reset Bot started successfully'); - -// Debug: Log all incoming updates to see if bot is receiving messages -bot.use(async (ctx, next) => { - console.log('Update received:', { - updateType: ctx.updateType, - chatType: ctx.chat?.type, - chatId: ctx.chat?.id, - fromId: ctx.from?.id, - text: ctx.message?.text || ctx.update.message?.text || 'N/A' - }); - return next(); -}); - -// Handle /resetkeyboard command -bot.command('resetkeyboard', async(ctx) => { - const chatId = ctx.chat.id; - const userId = ctx.from.id; - const chatType = ctx.chat.type; - - // Log command usage - console.log(`Command received - Chat ID: ${chatId}, User ID: ${userId}, Chat Type: ${chatType}`); - - // Check if chat is a group or supergroup - if (chatType !== 'group' && chatType !== 'supergroup') { - await ctx.reply('This bot only works in groups.'); - return; - } - - try { - // Check if user is an administrator - const member = await ctx.getChatMember(userId); - const isAdmin = member.status === 'administrator' || member.status === 'creator'; - - if (!isAdmin) { - // Log authorization failure at debug level - console.log(`Authorization failed - Chat ID: ${chatId}, User ID: ${userId}`); - await ctx.reply('Only group admins can use this command.'); - return; - } - - // Send keyboard reset message - const sentMessage = await ctx.reply('Keyboard reset.', { - reply_markup: Markup.removeKeyboard() - }); - - // Log successful reset - console.log(`Keyboard reset successful - Chat ID: ${chatId}, User ID: ${userId}`); - - // Delete the confirmation message after 7 seconds - setTimeout(async() => { - try { - await ctx.deleteMessage(sentMessage.message_id); - } catch (error) { - // Silently continue if deletion fails (permissions, race condition, etc.) - // This is expected behavior - do not log or spam - } - }, 7000); - - } catch (error) { - // Log errors for debugging - console.error('Error processing command:', error); - console.error('Error details:', { - message: error.message, - code: error.code, - response: error.response - }); - // Try to reply with error (but don't spam if it fails) - try { - await ctx.reply('An error occurred while processing the command.'); - } catch (replyError) { - // Silently continue if reply also fails - } - } -}); - -// Handle errors -bot.catch((err, ctx) => { - console.error('Bot error:', err); -}); - -// Start polling -bot.launch().then(() => { - console.log('Bot is polling for updates...'); -}).catch((error) => { - console.error('Failed to start bot:', error); - process.exit(1); -}); - -// Enable graceful stop -process.once('SIGINT', () => bot.stop('SIGINT')); -process.once('SIGTERM', () => bot.stop('SIGTERM')); \ No newline at end of file diff --git a/.history/bot_20251216201956.js b/.history/bot_20251216201956.js deleted file mode 100644 index a43ec76..0000000 --- a/.history/bot_20251216201956.js +++ /dev/null @@ -1,107 +0,0 @@ -import { Telegraf, Markup } from 'telegraf'; -import dotenv from 'dotenv'; - -dotenv.config(); - -const BOT_TOKEN = process.env.BOT_TOKEN; - -if (!BOT_TOKEN) { - console.error('Error: BOT_TOKEN environment variable is not set'); - process.exit(1); -} - -const bot = new Telegraf(BOT_TOKEN); - -// Log startup success -console.log('Keyboard Reset Bot started successfully'); - -// Debug: Log all incoming updates to see if bot is receiving messages -bot.use(async (ctx, next) => { - console.log('Update received:', { - updateType: ctx.updateType, - chatType: ctx.chat?.type, - chatId: ctx.chat?.id, - fromId: ctx.from?.id, - text: ctx.message?.text || ctx.update.message?.text || 'N/A' - }); - return next(); -}); - -// Handle /resetkeyboard command -bot.command('resetkeyboard', async (ctx) => { - const chatId = ctx.chat.id; - const userId = ctx.from.id; - const chatType = ctx.chat.type; - - // Log command usage - console.log(`Command received - Chat ID: ${chatId}, User ID: ${userId}, Chat Type: ${chatType}`); - - // Check if chat is a group or supergroup - if (chatType !== 'group' && chatType !== 'supergroup') { - await ctx.reply('This bot only works in groups.'); - return; - } - - try { - // Check if user is an administrator - const member = await ctx.getChatMember(userId); - const isAdmin = member.status === 'administrator' || member.status === 'creator'; - - if (!isAdmin) { - // Log authorization failure at debug level - console.log(`Authorization failed - Chat ID: ${chatId}, User ID: ${userId}`); - await ctx.reply('Only group admins can use this command.'); - return; - } - - // Send keyboard reset message - const sentMessage = await ctx.reply('Keyboard reset.', { - reply_markup: Markup.removeKeyboard() - }); - - // Log successful reset - console.log(`Keyboard reset successful - Chat ID: ${chatId}, User ID: ${userId}`); - - // Delete the confirmation message after 7 seconds - setTimeout(async() => { - try { - await ctx.deleteMessage(sentMessage.message_id); - } catch (error) { - // Silently continue if deletion fails (permissions, race condition, etc.) - // This is expected behavior - do not log or spam - } - }, 7000); - - } catch (error) { - // Log errors for debugging - console.error('Error processing command:', error); - console.error('Error details:', { - message: error.message, - code: error.code, - response: error.response - }); - // Try to reply with error (but don't spam if it fails) - try { - await ctx.reply('An error occurred while processing the command.'); - } catch (replyError) { - // Silently continue if reply also fails - } - } -}); - -// Handle errors -bot.catch((err, ctx) => { - console.error('Bot error:', err); -}); - -// Start polling -bot.launch().then(() => { - console.log('Bot is polling for updates...'); -}).catch((error) => { - console.error('Failed to start bot:', error); - process.exit(1); -}); - -// Enable graceful stop -process.once('SIGINT', () => bot.stop('SIGINT')); -process.once('SIGTERM', () => bot.stop('SIGTERM')); \ No newline at end of file diff --git a/.history/bot_20251216202004.js b/.history/bot_20251216202004.js deleted file mode 100644 index 44a7da6..0000000 --- a/.history/bot_20251216202004.js +++ /dev/null @@ -1,107 +0,0 @@ -import { Telegraf, Markup } from 'telegraf'; -import dotenv from 'dotenv'; - -dotenv.config(); - -const BOT_TOKEN = process.env.BOT_TOKEN; - -if (!BOT_TOKEN) { - console.error('Error: BOT_TOKEN environment variable is not set'); - process.exit(1); -} - -const bot = new Telegraf(BOT_TOKEN); - -// Log startup success -console.log('Keyboard Reset Bot started successfully'); - -// Debug: Log all incoming updates to see if bot is receiving messages -bot.use(async(ctx, next) => { - console.log('Update received:', { - updateType: ctx.updateType, - chatType: ctx.chat ? .type, - chatId: ctx.chat ? .id, - fromId: ctx.from ? .id, - text: ctx.message ? .text || ctx.update.message ? .text || 'N/A' - }); - return next(); -}); - -// Handle /resetkeyboard command -bot.command('resetkeyboard', async(ctx) => { - const chatId = ctx.chat.id; - const userId = ctx.from.id; - const chatType = ctx.chat.type; - - // Log command usage - console.log(`Command received - Chat ID: ${chatId}, User ID: ${userId}, Chat Type: ${chatType}`); - - // Check if chat is a group or supergroup - if (chatType !== 'group' && chatType !== 'supergroup') { - await ctx.reply('This bot only works in groups.'); - return; - } - - try { - // Check if user is an administrator - const member = await ctx.getChatMember(userId); - const isAdmin = member.status === 'administrator' || member.status === 'creator'; - - if (!isAdmin) { - // Log authorization failure at debug level - console.log(`Authorization failed - Chat ID: ${chatId}, User ID: ${userId}`); - await ctx.reply('Only group admins can use this command.'); - return; - } - - // Send keyboard reset message - const sentMessage = await ctx.reply('Keyboard reset.', { - reply_markup: Markup.removeKeyboard() - }); - - // Log successful reset - console.log(`Keyboard reset successful - Chat ID: ${chatId}, User ID: ${userId}`); - - // Delete the confirmation message after 7 seconds - setTimeout(async() => { - try { - await ctx.deleteMessage(sentMessage.message_id); - } catch (error) { - // Silently continue if deletion fails (permissions, race condition, etc.) - // This is expected behavior - do not log or spam - } - }, 7000); - - } catch (error) { - // Log errors for debugging - console.error('Error processing command:', error); - console.error('Error details:', { - message: error.message, - code: error.code, - response: error.response - }); - // Try to reply with error (but don't spam if it fails) - try { - await ctx.reply('An error occurred while processing the command.'); - } catch (replyError) { - // Silently continue if reply also fails - } - } -}); - -// Handle errors -bot.catch((err, ctx) => { - console.error('Bot error:', err); -}); - -// Start polling -bot.launch().then(() => { - console.log('Bot is polling for updates...'); -}).catch((error) => { - console.error('Failed to start bot:', error); - process.exit(1); -}); - -// Enable graceful stop -process.once('SIGINT', () => bot.stop('SIGINT')); -process.once('SIGTERM', () => bot.stop('SIGTERM')); \ No newline at end of file diff --git a/.history/bot_20251216202006.js b/.history/bot_20251216202006.js deleted file mode 100644 index 44a7da6..0000000 --- a/.history/bot_20251216202006.js +++ /dev/null @@ -1,107 +0,0 @@ -import { Telegraf, Markup } from 'telegraf'; -import dotenv from 'dotenv'; - -dotenv.config(); - -const BOT_TOKEN = process.env.BOT_TOKEN; - -if (!BOT_TOKEN) { - console.error('Error: BOT_TOKEN environment variable is not set'); - process.exit(1); -} - -const bot = new Telegraf(BOT_TOKEN); - -// Log startup success -console.log('Keyboard Reset Bot started successfully'); - -// Debug: Log all incoming updates to see if bot is receiving messages -bot.use(async(ctx, next) => { - console.log('Update received:', { - updateType: ctx.updateType, - chatType: ctx.chat ? .type, - chatId: ctx.chat ? .id, - fromId: ctx.from ? .id, - text: ctx.message ? .text || ctx.update.message ? .text || 'N/A' - }); - return next(); -}); - -// Handle /resetkeyboard command -bot.command('resetkeyboard', async(ctx) => { - const chatId = ctx.chat.id; - const userId = ctx.from.id; - const chatType = ctx.chat.type; - - // Log command usage - console.log(`Command received - Chat ID: ${chatId}, User ID: ${userId}, Chat Type: ${chatType}`); - - // Check if chat is a group or supergroup - if (chatType !== 'group' && chatType !== 'supergroup') { - await ctx.reply('This bot only works in groups.'); - return; - } - - try { - // Check if user is an administrator - const member = await ctx.getChatMember(userId); - const isAdmin = member.status === 'administrator' || member.status === 'creator'; - - if (!isAdmin) { - // Log authorization failure at debug level - console.log(`Authorization failed - Chat ID: ${chatId}, User ID: ${userId}`); - await ctx.reply('Only group admins can use this command.'); - return; - } - - // Send keyboard reset message - const sentMessage = await ctx.reply('Keyboard reset.', { - reply_markup: Markup.removeKeyboard() - }); - - // Log successful reset - console.log(`Keyboard reset successful - Chat ID: ${chatId}, User ID: ${userId}`); - - // Delete the confirmation message after 7 seconds - setTimeout(async() => { - try { - await ctx.deleteMessage(sentMessage.message_id); - } catch (error) { - // Silently continue if deletion fails (permissions, race condition, etc.) - // This is expected behavior - do not log or spam - } - }, 7000); - - } catch (error) { - // Log errors for debugging - console.error('Error processing command:', error); - console.error('Error details:', { - message: error.message, - code: error.code, - response: error.response - }); - // Try to reply with error (but don't spam if it fails) - try { - await ctx.reply('An error occurred while processing the command.'); - } catch (replyError) { - // Silently continue if reply also fails - } - } -}); - -// Handle errors -bot.catch((err, ctx) => { - console.error('Bot error:', err); -}); - -// Start polling -bot.launch().then(() => { - console.log('Bot is polling for updates...'); -}).catch((error) => { - console.error('Failed to start bot:', error); - process.exit(1); -}); - -// Enable graceful stop -process.once('SIGINT', () => bot.stop('SIGINT')); -process.once('SIGTERM', () => bot.stop('SIGTERM')); \ No newline at end of file diff --git a/.history/bot_20251216202021.js b/.history/bot_20251216202021.js deleted file mode 100644 index 31bc902..0000000 --- a/.history/bot_20251216202021.js +++ /dev/null @@ -1,107 +0,0 @@ -import { Telegraf, Markup } from 'telegraf'; -import dotenv from 'dotenv'; - -dotenv.config(); - -const BOT_TOKEN = process.env.BOT_TOKEN; - -if (!BOT_TOKEN) { - console.error('Error: BOT_TOKEN environment variable is not set'); - process.exit(1); -} - -const bot = new Telegraf(BOT_TOKEN); - -// Log startup success -console.log('Keyboard Reset Bot started successfully'); - -// Debug: Log all incoming updates to see if bot is receiving messages -bot.use(async (ctx, next) => { - console.log('Update received:', { - updateType: ctx.updateType, - chatType: ctx.chat?.type, - chatId: ctx.chat?.id, - fromId: ctx.from?.id, - text: ctx.message?.text || ctx.update.message?.text || 'N/A' - }); - return next(); -}); - -// Handle /resetkeyboard command -bot.command('resetkeyboard', async(ctx) => { - const chatId = ctx.chat.id; - const userId = ctx.from.id; - const chatType = ctx.chat.type; - - // Log command usage - console.log(`Command received - Chat ID: ${chatId}, User ID: ${userId}, Chat Type: ${chatType}`); - - // Check if chat is a group or supergroup - if (chatType !== 'group' && chatType !== 'supergroup') { - await ctx.reply('This bot only works in groups.'); - return; - } - - try { - // Check if user is an administrator - const member = await ctx.getChatMember(userId); - const isAdmin = member.status === 'administrator' || member.status === 'creator'; - - if (!isAdmin) { - // Log authorization failure at debug level - console.log(`Authorization failed - Chat ID: ${chatId}, User ID: ${userId}`); - await ctx.reply('Only group admins can use this command.'); - return; - } - - // Send keyboard reset message - const sentMessage = await ctx.reply('Keyboard reset.', { - reply_markup: Markup.removeKeyboard() - }); - - // Log successful reset - console.log(`Keyboard reset successful - Chat ID: ${chatId}, User ID: ${userId}`); - - // Delete the confirmation message after 7 seconds - setTimeout(async() => { - try { - await ctx.deleteMessage(sentMessage.message_id); - } catch (error) { - // Silently continue if deletion fails (permissions, race condition, etc.) - // This is expected behavior - do not log or spam - } - }, 7000); - - } catch (error) { - // Log errors for debugging - console.error('Error processing command:', error); - console.error('Error details:', { - message: error.message, - code: error.code, - response: error.response - }); - // Try to reply with error (but don't spam if it fails) - try { - await ctx.reply('An error occurred while processing the command.'); - } catch (replyError) { - // Silently continue if reply also fails - } - } -}); - -// Handle errors -bot.catch((err, ctx) => { - console.error('Bot error:', err); -}); - -// Start polling -bot.launch().then(() => { - console.log('Bot is polling for updates...'); -}).catch((error) => { - console.error('Failed to start bot:', error); - process.exit(1); -}); - -// Enable graceful stop -process.once('SIGINT', () => bot.stop('SIGINT')); -process.once('SIGTERM', () => bot.stop('SIGTERM')); \ No newline at end of file diff --git a/.history/bot_20251216202022.js b/.history/bot_20251216202022.js deleted file mode 100644 index 473d8e8..0000000 --- a/.history/bot_20251216202022.js +++ /dev/null @@ -1,107 +0,0 @@ -import { Telegraf, Markup } from 'telegraf'; -import dotenv from 'dotenv'; - -dotenv.config(); - -const BOT_TOKEN = process.env.BOT_TOKEN; - -if (!BOT_TOKEN) { - console.error('Error: BOT_TOKEN environment variable is not set'); - process.exit(1); -} - -const bot = new Telegraf(BOT_TOKEN); - -// Log startup success -console.log('Keyboard Reset Bot started successfully'); - -// Debug: Log all incoming updates to see if bot is receiving messages -bot.use(async (ctx, next) => { - console.log('Update received:', { - updateType: ctx.updateType, - chatType: ctx.chat?.type, - chatId: ctx.chat?.id, - fromId: ctx.from?.id, - text: ctx.message?.text || ctx.update.message?.text || 'N/A' - }); - return next(); -}); - -// Handle /resetkeyboard command -bot.command('resetkeyboard', async (ctx) => { - const chatId = ctx.chat.id; - const userId = ctx.from.id; - const chatType = ctx.chat.type; - - // Log command usage - console.log(`Command received - Chat ID: ${chatId}, User ID: ${userId}, Chat Type: ${chatType}`); - - // Check if chat is a group or supergroup - if (chatType !== 'group' && chatType !== 'supergroup') { - await ctx.reply('This bot only works in groups.'); - return; - } - - try { - // Check if user is an administrator - const member = await ctx.getChatMember(userId); - const isAdmin = member.status === 'administrator' || member.status === 'creator'; - - if (!isAdmin) { - // Log authorization failure at debug level - console.log(`Authorization failed - Chat ID: ${chatId}, User ID: ${userId}`); - await ctx.reply('Only group admins can use this command.'); - return; - } - - // Send keyboard reset message - const sentMessage = await ctx.reply('Keyboard reset.', { - reply_markup: Markup.removeKeyboard() - }); - - // Log successful reset - console.log(`Keyboard reset successful - Chat ID: ${chatId}, User ID: ${userId}`); - - // Delete the confirmation message after 7 seconds - setTimeout(async () => { - try { - await ctx.deleteMessage(sentMessage.message_id); - } catch (error) { - // Silently continue if deletion fails (permissions, race condition, etc.) - // This is expected behavior - do not log or spam - } - }, 7000); - - } catch (error) { - // Log errors for debugging - console.error('Error processing command:', error); - console.error('Error details:', { - message: error.message, - code: error.code, - response: error.response - }); - // Try to reply with error (but don't spam if it fails) - try { - await ctx.reply('An error occurred while processing the command.'); - } catch (replyError) { - // Silently continue if reply also fails - } - } -}); - -// Handle errors -bot.catch((err, ctx) => { - console.error('Bot error:', err); -}); - -// Start polling -bot.launch().then(() => { - console.log('Bot is polling for updates...'); -}).catch((error) => { - console.error('Failed to start bot:', error); - process.exit(1); -}); - -// Enable graceful stop -process.once('SIGINT', () => bot.stop('SIGINT')); -process.once('SIGTERM', () => bot.stop('SIGTERM')); \ No newline at end of file diff --git a/.history/bot_20251216202030.js b/.history/bot_20251216202030.js deleted file mode 100644 index 44a7da6..0000000 --- a/.history/bot_20251216202030.js +++ /dev/null @@ -1,107 +0,0 @@ -import { Telegraf, Markup } from 'telegraf'; -import dotenv from 'dotenv'; - -dotenv.config(); - -const BOT_TOKEN = process.env.BOT_TOKEN; - -if (!BOT_TOKEN) { - console.error('Error: BOT_TOKEN environment variable is not set'); - process.exit(1); -} - -const bot = new Telegraf(BOT_TOKEN); - -// Log startup success -console.log('Keyboard Reset Bot started successfully'); - -// Debug: Log all incoming updates to see if bot is receiving messages -bot.use(async(ctx, next) => { - console.log('Update received:', { - updateType: ctx.updateType, - chatType: ctx.chat ? .type, - chatId: ctx.chat ? .id, - fromId: ctx.from ? .id, - text: ctx.message ? .text || ctx.update.message ? .text || 'N/A' - }); - return next(); -}); - -// Handle /resetkeyboard command -bot.command('resetkeyboard', async(ctx) => { - const chatId = ctx.chat.id; - const userId = ctx.from.id; - const chatType = ctx.chat.type; - - // Log command usage - console.log(`Command received - Chat ID: ${chatId}, User ID: ${userId}, Chat Type: ${chatType}`); - - // Check if chat is a group or supergroup - if (chatType !== 'group' && chatType !== 'supergroup') { - await ctx.reply('This bot only works in groups.'); - return; - } - - try { - // Check if user is an administrator - const member = await ctx.getChatMember(userId); - const isAdmin = member.status === 'administrator' || member.status === 'creator'; - - if (!isAdmin) { - // Log authorization failure at debug level - console.log(`Authorization failed - Chat ID: ${chatId}, User ID: ${userId}`); - await ctx.reply('Only group admins can use this command.'); - return; - } - - // Send keyboard reset message - const sentMessage = await ctx.reply('Keyboard reset.', { - reply_markup: Markup.removeKeyboard() - }); - - // Log successful reset - console.log(`Keyboard reset successful - Chat ID: ${chatId}, User ID: ${userId}`); - - // Delete the confirmation message after 7 seconds - setTimeout(async() => { - try { - await ctx.deleteMessage(sentMessage.message_id); - } catch (error) { - // Silently continue if deletion fails (permissions, race condition, etc.) - // This is expected behavior - do not log or spam - } - }, 7000); - - } catch (error) { - // Log errors for debugging - console.error('Error processing command:', error); - console.error('Error details:', { - message: error.message, - code: error.code, - response: error.response - }); - // Try to reply with error (but don't spam if it fails) - try { - await ctx.reply('An error occurred while processing the command.'); - } catch (replyError) { - // Silently continue if reply also fails - } - } -}); - -// Handle errors -bot.catch((err, ctx) => { - console.error('Bot error:', err); -}); - -// Start polling -bot.launch().then(() => { - console.log('Bot is polling for updates...'); -}).catch((error) => { - console.error('Failed to start bot:', error); - process.exit(1); -}); - -// Enable graceful stop -process.once('SIGINT', () => bot.stop('SIGINT')); -process.once('SIGTERM', () => bot.stop('SIGTERM')); \ No newline at end of file diff --git a/.history/bot_20251216202045.js b/.history/bot_20251216202045.js deleted file mode 100644 index 31bc902..0000000 --- a/.history/bot_20251216202045.js +++ /dev/null @@ -1,107 +0,0 @@ -import { Telegraf, Markup } from 'telegraf'; -import dotenv from 'dotenv'; - -dotenv.config(); - -const BOT_TOKEN = process.env.BOT_TOKEN; - -if (!BOT_TOKEN) { - console.error('Error: BOT_TOKEN environment variable is not set'); - process.exit(1); -} - -const bot = new Telegraf(BOT_TOKEN); - -// Log startup success -console.log('Keyboard Reset Bot started successfully'); - -// Debug: Log all incoming updates to see if bot is receiving messages -bot.use(async (ctx, next) => { - console.log('Update received:', { - updateType: ctx.updateType, - chatType: ctx.chat?.type, - chatId: ctx.chat?.id, - fromId: ctx.from?.id, - text: ctx.message?.text || ctx.update.message?.text || 'N/A' - }); - return next(); -}); - -// Handle /resetkeyboard command -bot.command('resetkeyboard', async(ctx) => { - const chatId = ctx.chat.id; - const userId = ctx.from.id; - const chatType = ctx.chat.type; - - // Log command usage - console.log(`Command received - Chat ID: ${chatId}, User ID: ${userId}, Chat Type: ${chatType}`); - - // Check if chat is a group or supergroup - if (chatType !== 'group' && chatType !== 'supergroup') { - await ctx.reply('This bot only works in groups.'); - return; - } - - try { - // Check if user is an administrator - const member = await ctx.getChatMember(userId); - const isAdmin = member.status === 'administrator' || member.status === 'creator'; - - if (!isAdmin) { - // Log authorization failure at debug level - console.log(`Authorization failed - Chat ID: ${chatId}, User ID: ${userId}`); - await ctx.reply('Only group admins can use this command.'); - return; - } - - // Send keyboard reset message - const sentMessage = await ctx.reply('Keyboard reset.', { - reply_markup: Markup.removeKeyboard() - }); - - // Log successful reset - console.log(`Keyboard reset successful - Chat ID: ${chatId}, User ID: ${userId}`); - - // Delete the confirmation message after 7 seconds - setTimeout(async() => { - try { - await ctx.deleteMessage(sentMessage.message_id); - } catch (error) { - // Silently continue if deletion fails (permissions, race condition, etc.) - // This is expected behavior - do not log or spam - } - }, 7000); - - } catch (error) { - // Log errors for debugging - console.error('Error processing command:', error); - console.error('Error details:', { - message: error.message, - code: error.code, - response: error.response - }); - // Try to reply with error (but don't spam if it fails) - try { - await ctx.reply('An error occurred while processing the command.'); - } catch (replyError) { - // Silently continue if reply also fails - } - } -}); - -// Handle errors -bot.catch((err, ctx) => { - console.error('Bot error:', err); -}); - -// Start polling -bot.launch().then(() => { - console.log('Bot is polling for updates...'); -}).catch((error) => { - console.error('Failed to start bot:', error); - process.exit(1); -}); - -// Enable graceful stop -process.once('SIGINT', () => bot.stop('SIGINT')); -process.once('SIGTERM', () => bot.stop('SIGTERM')); \ No newline at end of file diff --git a/.history/bot_20251216202046.js b/.history/bot_20251216202046.js deleted file mode 100644 index 1d2442b..0000000 --- a/.history/bot_20251216202046.js +++ /dev/null @@ -1,107 +0,0 @@ -import { Telegraf, Markup } from 'telegraf'; -import dotenv from 'dotenv'; - -dotenv.config(); - -const BOT_TOKEN = process.env.BOT_TOKEN; - -if (!BOT_TOKEN) { - console.error('Error: BOT_TOKEN environment variable is not set'); - process.exit(1); -} - -const bot = new Telegraf(BOT_TOKEN); - -// Log startup success -console.log('Keyboard Reset Bot started successfully'); - -// Debug: Log all incoming updates to see if bot is receiving messages -bot.use(async (ctx, next) => { - console.log('Update received:', { - updateType: ctx.updateType, - chatType: ctx.chat?.type, - chatId: ctx.chat?.id, - fromId: ctx.from?.id, - text: ctx.message?.text || ctx.update.message?.text || 'N/A' - }); - return next(); -}); - -// Handle /resetkeyboard command -bot.command('resetkeyboard', async (ctx) => { - const chatId = ctx.chat.id; - const userId = ctx.from.id; - const chatType = ctx.chat.type; - - // Log command usage - console.log(`Command received - Chat ID: ${chatId}, User ID: ${userId}, Chat Type: ${chatType}`); - - // Check if chat is a group or supergroup - if (chatType !== 'group' && chatType !== 'supergroup') { - await ctx.reply('This bot only works in groups.'); - return; - } - - try { - // Check if user is an administrator - const member = await ctx.getChatMember(userId); - const isAdmin = member.status === 'administrator' || member.status === 'creator'; - - if (!isAdmin) { - // Log authorization failure at debug level - console.log(`Authorization failed - Chat ID: ${chatId}, User ID: ${userId}`); - await ctx.reply('Only group admins can use this command.'); - return; - } - - // Send keyboard reset message - const sentMessage = await ctx.reply('Keyboard reset.', { - reply_markup: Markup.removeKeyboard() - }); - - // Log successful reset - console.log(`Keyboard reset successful - Chat ID: ${chatId}, User ID: ${userId}`); - - // Delete the confirmation message after 7 seconds - setTimeout(async() => { - try { - await ctx.deleteMessage(sentMessage.message_id); - } catch (error) { - // Silently continue if deletion fails (permissions, race condition, etc.) - // This is expected behavior - do not log or spam - } - }, 7000); - - } catch (error) { - // Log errors for debugging - console.error('Error processing command:', error); - console.error('Error details:', { - message: error.message, - code: error.code, - response: error.response - }); - // Try to reply with error (but don't spam if it fails) - try { - await ctx.reply('An error occurred while processing the command.'); - } catch (replyError) { - // Silently continue if reply also fails - } - } -}); - -// Handle errors -bot.catch((err, ctx) => { - console.error('Bot error:', err); -}); - -// Start polling -bot.launch().then(() => { - console.log('Bot is polling for updates...'); -}).catch((error) => { - console.error('Failed to start bot:', error); - process.exit(1); -}); - -// Enable graceful stop -process.once('SIGINT', () => bot.stop('SIGINT')); -process.once('SIGTERM', () => bot.stop('SIGTERM')); \ No newline at end of file diff --git a/.history/bot_20251216202047.js b/.history/bot_20251216202047.js deleted file mode 100644 index 473d8e8..0000000 --- a/.history/bot_20251216202047.js +++ /dev/null @@ -1,107 +0,0 @@ -import { Telegraf, Markup } from 'telegraf'; -import dotenv from 'dotenv'; - -dotenv.config(); - -const BOT_TOKEN = process.env.BOT_TOKEN; - -if (!BOT_TOKEN) { - console.error('Error: BOT_TOKEN environment variable is not set'); - process.exit(1); -} - -const bot = new Telegraf(BOT_TOKEN); - -// Log startup success -console.log('Keyboard Reset Bot started successfully'); - -// Debug: Log all incoming updates to see if bot is receiving messages -bot.use(async (ctx, next) => { - console.log('Update received:', { - updateType: ctx.updateType, - chatType: ctx.chat?.type, - chatId: ctx.chat?.id, - fromId: ctx.from?.id, - text: ctx.message?.text || ctx.update.message?.text || 'N/A' - }); - return next(); -}); - -// Handle /resetkeyboard command -bot.command('resetkeyboard', async (ctx) => { - const chatId = ctx.chat.id; - const userId = ctx.from.id; - const chatType = ctx.chat.type; - - // Log command usage - console.log(`Command received - Chat ID: ${chatId}, User ID: ${userId}, Chat Type: ${chatType}`); - - // Check if chat is a group or supergroup - if (chatType !== 'group' && chatType !== 'supergroup') { - await ctx.reply('This bot only works in groups.'); - return; - } - - try { - // Check if user is an administrator - const member = await ctx.getChatMember(userId); - const isAdmin = member.status === 'administrator' || member.status === 'creator'; - - if (!isAdmin) { - // Log authorization failure at debug level - console.log(`Authorization failed - Chat ID: ${chatId}, User ID: ${userId}`); - await ctx.reply('Only group admins can use this command.'); - return; - } - - // Send keyboard reset message - const sentMessage = await ctx.reply('Keyboard reset.', { - reply_markup: Markup.removeKeyboard() - }); - - // Log successful reset - console.log(`Keyboard reset successful - Chat ID: ${chatId}, User ID: ${userId}`); - - // Delete the confirmation message after 7 seconds - setTimeout(async () => { - try { - await ctx.deleteMessage(sentMessage.message_id); - } catch (error) { - // Silently continue if deletion fails (permissions, race condition, etc.) - // This is expected behavior - do not log or spam - } - }, 7000); - - } catch (error) { - // Log errors for debugging - console.error('Error processing command:', error); - console.error('Error details:', { - message: error.message, - code: error.code, - response: error.response - }); - // Try to reply with error (but don't spam if it fails) - try { - await ctx.reply('An error occurred while processing the command.'); - } catch (replyError) { - // Silently continue if reply also fails - } - } -}); - -// Handle errors -bot.catch((err, ctx) => { - console.error('Bot error:', err); -}); - -// Start polling -bot.launch().then(() => { - console.log('Bot is polling for updates...'); -}).catch((error) => { - console.error('Failed to start bot:', error); - process.exit(1); -}); - -// Enable graceful stop -process.once('SIGINT', () => bot.stop('SIGINT')); -process.once('SIGTERM', () => bot.stop('SIGTERM')); \ No newline at end of file diff --git a/.history/bot_20251216202053.js b/.history/bot_20251216202053.js deleted file mode 100644 index 44a7da6..0000000 --- a/.history/bot_20251216202053.js +++ /dev/null @@ -1,107 +0,0 @@ -import { Telegraf, Markup } from 'telegraf'; -import dotenv from 'dotenv'; - -dotenv.config(); - -const BOT_TOKEN = process.env.BOT_TOKEN; - -if (!BOT_TOKEN) { - console.error('Error: BOT_TOKEN environment variable is not set'); - process.exit(1); -} - -const bot = new Telegraf(BOT_TOKEN); - -// Log startup success -console.log('Keyboard Reset Bot started successfully'); - -// Debug: Log all incoming updates to see if bot is receiving messages -bot.use(async(ctx, next) => { - console.log('Update received:', { - updateType: ctx.updateType, - chatType: ctx.chat ? .type, - chatId: ctx.chat ? .id, - fromId: ctx.from ? .id, - text: ctx.message ? .text || ctx.update.message ? .text || 'N/A' - }); - return next(); -}); - -// Handle /resetkeyboard command -bot.command('resetkeyboard', async(ctx) => { - const chatId = ctx.chat.id; - const userId = ctx.from.id; - const chatType = ctx.chat.type; - - // Log command usage - console.log(`Command received - Chat ID: ${chatId}, User ID: ${userId}, Chat Type: ${chatType}`); - - // Check if chat is a group or supergroup - if (chatType !== 'group' && chatType !== 'supergroup') { - await ctx.reply('This bot only works in groups.'); - return; - } - - try { - // Check if user is an administrator - const member = await ctx.getChatMember(userId); - const isAdmin = member.status === 'administrator' || member.status === 'creator'; - - if (!isAdmin) { - // Log authorization failure at debug level - console.log(`Authorization failed - Chat ID: ${chatId}, User ID: ${userId}`); - await ctx.reply('Only group admins can use this command.'); - return; - } - - // Send keyboard reset message - const sentMessage = await ctx.reply('Keyboard reset.', { - reply_markup: Markup.removeKeyboard() - }); - - // Log successful reset - console.log(`Keyboard reset successful - Chat ID: ${chatId}, User ID: ${userId}`); - - // Delete the confirmation message after 7 seconds - setTimeout(async() => { - try { - await ctx.deleteMessage(sentMessage.message_id); - } catch (error) { - // Silently continue if deletion fails (permissions, race condition, etc.) - // This is expected behavior - do not log or spam - } - }, 7000); - - } catch (error) { - // Log errors for debugging - console.error('Error processing command:', error); - console.error('Error details:', { - message: error.message, - code: error.code, - response: error.response - }); - // Try to reply with error (but don't spam if it fails) - try { - await ctx.reply('An error occurred while processing the command.'); - } catch (replyError) { - // Silently continue if reply also fails - } - } -}); - -// Handle errors -bot.catch((err, ctx) => { - console.error('Bot error:', err); -}); - -// Start polling -bot.launch().then(() => { - console.log('Bot is polling for updates...'); -}).catch((error) => { - console.error('Failed to start bot:', error); - process.exit(1); -}); - -// Enable graceful stop -process.once('SIGINT', () => bot.stop('SIGINT')); -process.once('SIGTERM', () => bot.stop('SIGTERM')); \ No newline at end of file diff --git a/.history/bot_20251216202108.js b/.history/bot_20251216202108.js deleted file mode 100644 index 31bc902..0000000 --- a/.history/bot_20251216202108.js +++ /dev/null @@ -1,107 +0,0 @@ -import { Telegraf, Markup } from 'telegraf'; -import dotenv from 'dotenv'; - -dotenv.config(); - -const BOT_TOKEN = process.env.BOT_TOKEN; - -if (!BOT_TOKEN) { - console.error('Error: BOT_TOKEN environment variable is not set'); - process.exit(1); -} - -const bot = new Telegraf(BOT_TOKEN); - -// Log startup success -console.log('Keyboard Reset Bot started successfully'); - -// Debug: Log all incoming updates to see if bot is receiving messages -bot.use(async (ctx, next) => { - console.log('Update received:', { - updateType: ctx.updateType, - chatType: ctx.chat?.type, - chatId: ctx.chat?.id, - fromId: ctx.from?.id, - text: ctx.message?.text || ctx.update.message?.text || 'N/A' - }); - return next(); -}); - -// Handle /resetkeyboard command -bot.command('resetkeyboard', async(ctx) => { - const chatId = ctx.chat.id; - const userId = ctx.from.id; - const chatType = ctx.chat.type; - - // Log command usage - console.log(`Command received - Chat ID: ${chatId}, User ID: ${userId}, Chat Type: ${chatType}`); - - // Check if chat is a group or supergroup - if (chatType !== 'group' && chatType !== 'supergroup') { - await ctx.reply('This bot only works in groups.'); - return; - } - - try { - // Check if user is an administrator - const member = await ctx.getChatMember(userId); - const isAdmin = member.status === 'administrator' || member.status === 'creator'; - - if (!isAdmin) { - // Log authorization failure at debug level - console.log(`Authorization failed - Chat ID: ${chatId}, User ID: ${userId}`); - await ctx.reply('Only group admins can use this command.'); - return; - } - - // Send keyboard reset message - const sentMessage = await ctx.reply('Keyboard reset.', { - reply_markup: Markup.removeKeyboard() - }); - - // Log successful reset - console.log(`Keyboard reset successful - Chat ID: ${chatId}, User ID: ${userId}`); - - // Delete the confirmation message after 7 seconds - setTimeout(async() => { - try { - await ctx.deleteMessage(sentMessage.message_id); - } catch (error) { - // Silently continue if deletion fails (permissions, race condition, etc.) - // This is expected behavior - do not log or spam - } - }, 7000); - - } catch (error) { - // Log errors for debugging - console.error('Error processing command:', error); - console.error('Error details:', { - message: error.message, - code: error.code, - response: error.response - }); - // Try to reply with error (but don't spam if it fails) - try { - await ctx.reply('An error occurred while processing the command.'); - } catch (replyError) { - // Silently continue if reply also fails - } - } -}); - -// Handle errors -bot.catch((err, ctx) => { - console.error('Bot error:', err); -}); - -// Start polling -bot.launch().then(() => { - console.log('Bot is polling for updates...'); -}).catch((error) => { - console.error('Failed to start bot:', error); - process.exit(1); -}); - -// Enable graceful stop -process.once('SIGINT', () => bot.stop('SIGINT')); -process.once('SIGTERM', () => bot.stop('SIGTERM')); \ No newline at end of file diff --git a/.history/bot_20251216202110.js b/.history/bot_20251216202110.js deleted file mode 100644 index 1d2442b..0000000 --- a/.history/bot_20251216202110.js +++ /dev/null @@ -1,107 +0,0 @@ -import { Telegraf, Markup } from 'telegraf'; -import dotenv from 'dotenv'; - -dotenv.config(); - -const BOT_TOKEN = process.env.BOT_TOKEN; - -if (!BOT_TOKEN) { - console.error('Error: BOT_TOKEN environment variable is not set'); - process.exit(1); -} - -const bot = new Telegraf(BOT_TOKEN); - -// Log startup success -console.log('Keyboard Reset Bot started successfully'); - -// Debug: Log all incoming updates to see if bot is receiving messages -bot.use(async (ctx, next) => { - console.log('Update received:', { - updateType: ctx.updateType, - chatType: ctx.chat?.type, - chatId: ctx.chat?.id, - fromId: ctx.from?.id, - text: ctx.message?.text || ctx.update.message?.text || 'N/A' - }); - return next(); -}); - -// Handle /resetkeyboard command -bot.command('resetkeyboard', async (ctx) => { - const chatId = ctx.chat.id; - const userId = ctx.from.id; - const chatType = ctx.chat.type; - - // Log command usage - console.log(`Command received - Chat ID: ${chatId}, User ID: ${userId}, Chat Type: ${chatType}`); - - // Check if chat is a group or supergroup - if (chatType !== 'group' && chatType !== 'supergroup') { - await ctx.reply('This bot only works in groups.'); - return; - } - - try { - // Check if user is an administrator - const member = await ctx.getChatMember(userId); - const isAdmin = member.status === 'administrator' || member.status === 'creator'; - - if (!isAdmin) { - // Log authorization failure at debug level - console.log(`Authorization failed - Chat ID: ${chatId}, User ID: ${userId}`); - await ctx.reply('Only group admins can use this command.'); - return; - } - - // Send keyboard reset message - const sentMessage = await ctx.reply('Keyboard reset.', { - reply_markup: Markup.removeKeyboard() - }); - - // Log successful reset - console.log(`Keyboard reset successful - Chat ID: ${chatId}, User ID: ${userId}`); - - // Delete the confirmation message after 7 seconds - setTimeout(async() => { - try { - await ctx.deleteMessage(sentMessage.message_id); - } catch (error) { - // Silently continue if deletion fails (permissions, race condition, etc.) - // This is expected behavior - do not log or spam - } - }, 7000); - - } catch (error) { - // Log errors for debugging - console.error('Error processing command:', error); - console.error('Error details:', { - message: error.message, - code: error.code, - response: error.response - }); - // Try to reply with error (but don't spam if it fails) - try { - await ctx.reply('An error occurred while processing the command.'); - } catch (replyError) { - // Silently continue if reply also fails - } - } -}); - -// Handle errors -bot.catch((err, ctx) => { - console.error('Bot error:', err); -}); - -// Start polling -bot.launch().then(() => { - console.log('Bot is polling for updates...'); -}).catch((error) => { - console.error('Failed to start bot:', error); - process.exit(1); -}); - -// Enable graceful stop -process.once('SIGINT', () => bot.stop('SIGINT')); -process.once('SIGTERM', () => bot.stop('SIGTERM')); \ No newline at end of file diff --git a/.history/bot_20251216202111.js b/.history/bot_20251216202111.js deleted file mode 100644 index 473d8e8..0000000 --- a/.history/bot_20251216202111.js +++ /dev/null @@ -1,107 +0,0 @@ -import { Telegraf, Markup } from 'telegraf'; -import dotenv from 'dotenv'; - -dotenv.config(); - -const BOT_TOKEN = process.env.BOT_TOKEN; - -if (!BOT_TOKEN) { - console.error('Error: BOT_TOKEN environment variable is not set'); - process.exit(1); -} - -const bot = new Telegraf(BOT_TOKEN); - -// Log startup success -console.log('Keyboard Reset Bot started successfully'); - -// Debug: Log all incoming updates to see if bot is receiving messages -bot.use(async (ctx, next) => { - console.log('Update received:', { - updateType: ctx.updateType, - chatType: ctx.chat?.type, - chatId: ctx.chat?.id, - fromId: ctx.from?.id, - text: ctx.message?.text || ctx.update.message?.text || 'N/A' - }); - return next(); -}); - -// Handle /resetkeyboard command -bot.command('resetkeyboard', async (ctx) => { - const chatId = ctx.chat.id; - const userId = ctx.from.id; - const chatType = ctx.chat.type; - - // Log command usage - console.log(`Command received - Chat ID: ${chatId}, User ID: ${userId}, Chat Type: ${chatType}`); - - // Check if chat is a group or supergroup - if (chatType !== 'group' && chatType !== 'supergroup') { - await ctx.reply('This bot only works in groups.'); - return; - } - - try { - // Check if user is an administrator - const member = await ctx.getChatMember(userId); - const isAdmin = member.status === 'administrator' || member.status === 'creator'; - - if (!isAdmin) { - // Log authorization failure at debug level - console.log(`Authorization failed - Chat ID: ${chatId}, User ID: ${userId}`); - await ctx.reply('Only group admins can use this command.'); - return; - } - - // Send keyboard reset message - const sentMessage = await ctx.reply('Keyboard reset.', { - reply_markup: Markup.removeKeyboard() - }); - - // Log successful reset - console.log(`Keyboard reset successful - Chat ID: ${chatId}, User ID: ${userId}`); - - // Delete the confirmation message after 7 seconds - setTimeout(async () => { - try { - await ctx.deleteMessage(sentMessage.message_id); - } catch (error) { - // Silently continue if deletion fails (permissions, race condition, etc.) - // This is expected behavior - do not log or spam - } - }, 7000); - - } catch (error) { - // Log errors for debugging - console.error('Error processing command:', error); - console.error('Error details:', { - message: error.message, - code: error.code, - response: error.response - }); - // Try to reply with error (but don't spam if it fails) - try { - await ctx.reply('An error occurred while processing the command.'); - } catch (replyError) { - // Silently continue if reply also fails - } - } -}); - -// Handle errors -bot.catch((err, ctx) => { - console.error('Bot error:', err); -}); - -// Start polling -bot.launch().then(() => { - console.log('Bot is polling for updates...'); -}).catch((error) => { - console.error('Failed to start bot:', error); - process.exit(1); -}); - -// Enable graceful stop -process.once('SIGINT', () => bot.stop('SIGINT')); -process.once('SIGTERM', () => bot.stop('SIGTERM')); \ No newline at end of file diff --git a/.history/bot_20251216202116.js b/.history/bot_20251216202116.js deleted file mode 100644 index 44a7da6..0000000 --- a/.history/bot_20251216202116.js +++ /dev/null @@ -1,107 +0,0 @@ -import { Telegraf, Markup } from 'telegraf'; -import dotenv from 'dotenv'; - -dotenv.config(); - -const BOT_TOKEN = process.env.BOT_TOKEN; - -if (!BOT_TOKEN) { - console.error('Error: BOT_TOKEN environment variable is not set'); - process.exit(1); -} - -const bot = new Telegraf(BOT_TOKEN); - -// Log startup success -console.log('Keyboard Reset Bot started successfully'); - -// Debug: Log all incoming updates to see if bot is receiving messages -bot.use(async(ctx, next) => { - console.log('Update received:', { - updateType: ctx.updateType, - chatType: ctx.chat ? .type, - chatId: ctx.chat ? .id, - fromId: ctx.from ? .id, - text: ctx.message ? .text || ctx.update.message ? .text || 'N/A' - }); - return next(); -}); - -// Handle /resetkeyboard command -bot.command('resetkeyboard', async(ctx) => { - const chatId = ctx.chat.id; - const userId = ctx.from.id; - const chatType = ctx.chat.type; - - // Log command usage - console.log(`Command received - Chat ID: ${chatId}, User ID: ${userId}, Chat Type: ${chatType}`); - - // Check if chat is a group or supergroup - if (chatType !== 'group' && chatType !== 'supergroup') { - await ctx.reply('This bot only works in groups.'); - return; - } - - try { - // Check if user is an administrator - const member = await ctx.getChatMember(userId); - const isAdmin = member.status === 'administrator' || member.status === 'creator'; - - if (!isAdmin) { - // Log authorization failure at debug level - console.log(`Authorization failed - Chat ID: ${chatId}, User ID: ${userId}`); - await ctx.reply('Only group admins can use this command.'); - return; - } - - // Send keyboard reset message - const sentMessage = await ctx.reply('Keyboard reset.', { - reply_markup: Markup.removeKeyboard() - }); - - // Log successful reset - console.log(`Keyboard reset successful - Chat ID: ${chatId}, User ID: ${userId}`); - - // Delete the confirmation message after 7 seconds - setTimeout(async() => { - try { - await ctx.deleteMessage(sentMessage.message_id); - } catch (error) { - // Silently continue if deletion fails (permissions, race condition, etc.) - // This is expected behavior - do not log or spam - } - }, 7000); - - } catch (error) { - // Log errors for debugging - console.error('Error processing command:', error); - console.error('Error details:', { - message: error.message, - code: error.code, - response: error.response - }); - // Try to reply with error (but don't spam if it fails) - try { - await ctx.reply('An error occurred while processing the command.'); - } catch (replyError) { - // Silently continue if reply also fails - } - } -}); - -// Handle errors -bot.catch((err, ctx) => { - console.error('Bot error:', err); -}); - -// Start polling -bot.launch().then(() => { - console.log('Bot is polling for updates...'); -}).catch((error) => { - console.error('Failed to start bot:', error); - process.exit(1); -}); - -// Enable graceful stop -process.once('SIGINT', () => bot.stop('SIGINT')); -process.once('SIGTERM', () => bot.stop('SIGTERM')); \ No newline at end of file diff --git a/.history/bot_20251216204344.js b/.history/bot_20251216204344.js deleted file mode 100644 index 3ca3ca7..0000000 --- a/.history/bot_20251216204344.js +++ /dev/null @@ -1,89 +0,0 @@ -import { Telegraf } from 'telegraf'; -import dotenv from 'dotenv'; - -dotenv.config(); - -const BOT_TOKEN = process.env.BOT_TOKEN; - -if (!BOT_TOKEN) { - console.error('Error: BOT_TOKEN environment variable is not set'); - process.exit(1); -} - -const bot = new Telegraf(BOT_TOKEN); - -// Log startup success -console.log('Keyboard Reset Bot starting...'); - -// Handle /resetkeyboard command -bot.command('resetkeyboard', async (ctx) => { - const chatId = ctx.chat.id; - const userId = ctx.from.id; - const chatType = ctx.chat.type; - - // Log command usage - console.log(`Command /resetkeyboard - Chat ID: ${chatId}, User ID: ${userId}, Chat Type: ${chatType}`); - - // Check if chat is a group or supergroup - if (chatType !== 'group' && chatType !== 'supergroup') { - await ctx.reply('This bot only works in groups.'); - return; - } - - try { - // Check if user is an administrator - const member = await ctx.getChatMember(userId); - const isAdmin = member.status === 'administrator' || member.status === 'creator'; - - if (!isAdmin) { - // Log authorization failure at debug level - console.debug(`Authorization failed - Chat ID: ${chatId}, User ID: ${userId}`); - await ctx.reply('Only group admins can use this command.'); - return; - } - - // Send keyboard reset message with ReplyKeyboardRemove - // selective: false ensures it removes keyboard for ALL users - const sentMessage = await ctx.reply('Keyboard reset.', { - reply_markup: { - remove_keyboard: true, - selective: false - } - }); - - // Log successful reset - console.log(`Keyboard reset successful - Chat ID: ${chatId}, User ID: ${userId}`); - - // Delete the confirmation message after 7 seconds - // This gives clients time to process the keyboard reset - setTimeout(async () => { - try { - await ctx.deleteMessage(sentMessage.message_id); - } catch (error) { - // Silently continue if deletion fails (permissions, race condition, etc.) - } - }, 7000); - - } catch (error) { - // Fail silently on Telegram API errors (do not spam the group) - console.error(`Error processing command - Chat ID: ${chatId}, User ID: ${userId}:`, error.message); - } -}); - -// Handle errors globally -bot.catch((err, ctx) => { - console.error('Bot error:', err.message); -}); - -// Start polling -bot.launch().then(() => { - console.log('Keyboard Reset Bot started successfully'); - console.log('Bot is polling for updates...'); -}).catch((error) => { - console.error('Failed to start bot:', error.message); - process.exit(1); -}); - -// Enable graceful stop -process.once('SIGINT', () => bot.stop('SIGINT')); -process.once('SIGTERM', () => bot.stop('SIGTERM')); diff --git a/.history/bot_20251216204356.js b/.history/bot_20251216204356.js deleted file mode 100644 index 251a5e4..0000000 --- a/.history/bot_20251216204356.js +++ /dev/null @@ -1,89 +0,0 @@ -import { Telegraf } from 'telegraf'; -import dotenv from 'dotenv'; - -dotenv.config(); - -const BOT_TOKEN = process.env.BOT_TOKEN; - -if (!BOT_TOKEN) { - console.error('Error: BOT_TOKEN environment variable is not set'); - process.exit(1); -} - -const bot = new Telegraf(BOT_TOKEN); - -// Log startup success -console.log('Keyboard Reset Bot starting...'); - -// Handle /resetkeyboard command -bot.command('resetkeyboard', async(ctx) => { - const chatId = ctx.chat.id; - const userId = ctx.from.id; - const chatType = ctx.chat.type; - - // Log command usage - console.log(`Command /resetkeyboard - Chat ID: ${chatId}, User ID: ${userId}, Chat Type: ${chatType}`); - - // Check if chat is a group or supergroup - if (chatType !== 'group' && chatType !== 'supergroup') { - await ctx.reply('This bot only works in groups.'); - return; - } - - try { - // Check if user is an administrator - const member = await ctx.getChatMember(userId); - const isAdmin = member.status === 'administrator' || member.status === 'creator'; - - if (!isAdmin) { - // Log authorization failure at debug level - console.debug(`Authorization failed - Chat ID: ${chatId}, User ID: ${userId}`); - await ctx.reply('Only group admins can use this command.'); - return; - } - - // Send keyboard reset message with ReplyKeyboardRemove - // selective: false ensures it removes keyboard for ALL users - const sentMessage = await ctx.reply('Keyboard reset.', { - reply_markup: { - remove_keyboard: true, - selective: false - } - }); - - // Log successful reset - console.log(`Keyboard reset successful - Chat ID: ${chatId}, User ID: ${userId}`); - - // Delete the confirmation message after 7 seconds - // This gives clients time to process the keyboard reset - setTimeout(async() => { - try { - await ctx.deleteMessage(sentMessage.message_id); - } catch (error) { - // Silently continue if deletion fails (permissions, race condition, etc.) - } - }, 7000); - - } catch (error) { - // Fail silently on Telegram API errors (do not spam the group) - console.error(`Error processing command - Chat ID: ${chatId}, User ID: ${userId}:`, error.message); - } -}); - -// Handle errors globally -bot.catch((err, ctx) => { - console.error('Bot error:', err.message); -}); - -// Start polling -bot.launch().then(() => { - console.log('Keyboard Reset Bot started successfully'); - console.log('Bot is polling for updates...'); -}).catch((error) => { - console.error('Failed to start bot:', error.message); - process.exit(1); -}); - -// Enable graceful stop -process.once('SIGINT', () => bot.stop('SIGINT')); -process.once('SIGTERM', () => bot.stop('SIGTERM')); \ No newline at end of file diff --git a/.history/bot_20251216204358.js b/.history/bot_20251216204358.js deleted file mode 100644 index 251a5e4..0000000 --- a/.history/bot_20251216204358.js +++ /dev/null @@ -1,89 +0,0 @@ -import { Telegraf } from 'telegraf'; -import dotenv from 'dotenv'; - -dotenv.config(); - -const BOT_TOKEN = process.env.BOT_TOKEN; - -if (!BOT_TOKEN) { - console.error('Error: BOT_TOKEN environment variable is not set'); - process.exit(1); -} - -const bot = new Telegraf(BOT_TOKEN); - -// Log startup success -console.log('Keyboard Reset Bot starting...'); - -// Handle /resetkeyboard command -bot.command('resetkeyboard', async(ctx) => { - const chatId = ctx.chat.id; - const userId = ctx.from.id; - const chatType = ctx.chat.type; - - // Log command usage - console.log(`Command /resetkeyboard - Chat ID: ${chatId}, User ID: ${userId}, Chat Type: ${chatType}`); - - // Check if chat is a group or supergroup - if (chatType !== 'group' && chatType !== 'supergroup') { - await ctx.reply('This bot only works in groups.'); - return; - } - - try { - // Check if user is an administrator - const member = await ctx.getChatMember(userId); - const isAdmin = member.status === 'administrator' || member.status === 'creator'; - - if (!isAdmin) { - // Log authorization failure at debug level - console.debug(`Authorization failed - Chat ID: ${chatId}, User ID: ${userId}`); - await ctx.reply('Only group admins can use this command.'); - return; - } - - // Send keyboard reset message with ReplyKeyboardRemove - // selective: false ensures it removes keyboard for ALL users - const sentMessage = await ctx.reply('Keyboard reset.', { - reply_markup: { - remove_keyboard: true, - selective: false - } - }); - - // Log successful reset - console.log(`Keyboard reset successful - Chat ID: ${chatId}, User ID: ${userId}`); - - // Delete the confirmation message after 7 seconds - // This gives clients time to process the keyboard reset - setTimeout(async() => { - try { - await ctx.deleteMessage(sentMessage.message_id); - } catch (error) { - // Silently continue if deletion fails (permissions, race condition, etc.) - } - }, 7000); - - } catch (error) { - // Fail silently on Telegram API errors (do not spam the group) - console.error(`Error processing command - Chat ID: ${chatId}, User ID: ${userId}:`, error.message); - } -}); - -// Handle errors globally -bot.catch((err, ctx) => { - console.error('Bot error:', err.message); -}); - -// Start polling -bot.launch().then(() => { - console.log('Keyboard Reset Bot started successfully'); - console.log('Bot is polling for updates...'); -}).catch((error) => { - console.error('Failed to start bot:', error.message); - process.exit(1); -}); - -// Enable graceful stop -process.once('SIGINT', () => bot.stop('SIGINT')); -process.once('SIGTERM', () => bot.stop('SIGTERM')); \ No newline at end of file diff --git a/.history/bot_20251216204824.js b/.history/bot_20251216204824.js deleted file mode 100644 index d696f22..0000000 --- a/.history/bot_20251216204824.js +++ /dev/null @@ -1,120 +0,0 @@ -import { Telegraf } from 'telegraf'; -import dotenv from 'dotenv'; - -dotenv.config(); - -const BOT_TOKEN = process.env.BOT_TOKEN; - -if (!BOT_TOKEN) { - console.error('Error: BOT_TOKEN environment variable is not set'); - process.exit(1); -} - -console.log('Keyboard Reset Bot initializing...'); - -const bot = new Telegraf(BOT_TOKEN); - -// Debug middleware - log all incoming updates -bot.use(async (ctx, next) => { - console.log('Update received:', { - type: ctx.updateType, - chat: ctx.chat?.type, - text: ctx.message?.text - }); - return next(); -}); - -// Handle /start command (for private DM) -bot.command('start', async (ctx) => { - const chatType = ctx.chat.type; - - if (chatType === 'private') { - await ctx.reply( - 'Keyboard Reset Bot\n\n' + - 'This bot removes reply keyboard buttons in group chats.\n\n' + - 'How to use:\n' + - '1. Add this bot to a group\n' + - '2. Use /resetkeyboard in the group (admins only)\n\n' + - 'The bot will send a message that clears all reply keyboards for users in the group.' - ); - } else { - // In groups, just acknowledge briefly - await ctx.reply('Use /resetkeyboard to clear reply keyboards (admins only).'); - } -}); - -// Handle /resetkeyboard command -bot.command('resetkeyboard', async (ctx) => { - const chatId = ctx.chat.id; - const userId = ctx.from.id; - const chatType = ctx.chat.type; - - // Log command usage - console.log(`Command /resetkeyboard - Chat ID: ${chatId}, User ID: ${userId}, Chat Type: ${chatType}`); - - // Check if chat is a group or supergroup - if (chatType !== 'group' && chatType !== 'supergroup') { - await ctx.reply('This bot only works in groups.'); - return; - } - - try { - // Check if user is an administrator - const member = await ctx.getChatMember(userId); - const isAdmin = member.status === 'administrator' || member.status === 'creator'; - - if (!isAdmin) { - // Log authorization failure at debug level - console.debug(`Authorization failed - Chat ID: ${chatId}, User ID: ${userId}`); - await ctx.reply('Only group admins can use this command.'); - return; - } - - // Send keyboard reset message with ReplyKeyboardRemove - // selective: false ensures it removes keyboard for ALL users - const sentMessage = await ctx.reply('Keyboard reset.', { - reply_markup: { - remove_keyboard: true, - selective: false - } - }); - - // Log successful reset - console.log(`Keyboard reset successful - Chat ID: ${chatId}, User ID: ${userId}`); - - // Delete the confirmation message after 7 seconds - // This gives clients time to process the keyboard reset - setTimeout(async () => { - try { - await ctx.deleteMessage(sentMessage.message_id); - } catch (error) { - // Silently continue if deletion fails (permissions, race condition, etc.) - } - }, 7000); - - } catch (error) { - // Fail silently on Telegram API errors (do not spam the group) - console.error(`Error processing command - Chat ID: ${chatId}, User ID: ${userId}:`, error.message); - } -}); - -// Handle errors globally -bot.catch((err, ctx) => { - console.error('Bot error:', err.message); -}); - -// Start polling -console.log('Starting bot polling...'); -bot.launch() - .then(() => { - console.log('Keyboard Reset Bot started successfully!'); - console.log('Bot is now polling for updates...'); - }) - .catch((error) => { - console.error('Failed to start bot:', error.message); - process.exit(1); - }); - -// Enable graceful stop -process.once('SIGINT', () => bot.stop('SIGINT')); -process.once('SIGTERM', () => bot.stop('SIGTERM')); diff --git a/.history/bot_20251216204836.js b/.history/bot_20251216204836.js deleted file mode 100644 index a33cebf..0000000 --- a/.history/bot_20251216204836.js +++ /dev/null @@ -1,120 +0,0 @@ -import { Telegraf } from 'telegraf'; -import dotenv from 'dotenv'; - -dotenv.config(); - -const BOT_TOKEN = process.env.BOT_TOKEN; - -if (!BOT_TOKEN) { - console.error('Error: BOT_TOKEN environment variable is not set'); - process.exit(1); -} - -console.log('Keyboard Reset Bot initializing...'); - -const bot = new Telegraf(BOT_TOKEN); - -// Debug middleware - log all incoming updates -bot.use(async(ctx, next) => { - console.log('Update received:', { - type: ctx.updateType, - chat: ctx.chat ? .type, - text: ctx.message ? .text - }); - return next(); -}); - -// Handle /start command (for private DM) -bot.command('start', async(ctx) => { - const chatType = ctx.chat.type; - - if (chatType === 'private') { - await ctx.reply( - 'Keyboard Reset Bot\n\n' + - 'This bot removes reply keyboard buttons in group chats.\n\n' + - 'How to use:\n' + - '1. Add this bot to a group\n' + - '2. Use /resetkeyboard in the group (admins only)\n\n' + - 'The bot will send a message that clears all reply keyboards for users in the group.' - ); - } else { - // In groups, just acknowledge briefly - await ctx.reply('Use /resetkeyboard to clear reply keyboards (admins only).'); - } -}); - -// Handle /resetkeyboard command -bot.command('resetkeyboard', async(ctx) => { - const chatId = ctx.chat.id; - const userId = ctx.from.id; - const chatType = ctx.chat.type; - - // Log command usage - console.log(`Command /resetkeyboard - Chat ID: ${chatId}, User ID: ${userId}, Chat Type: ${chatType}`); - - // Check if chat is a group or supergroup - if (chatType !== 'group' && chatType !== 'supergroup') { - await ctx.reply('This bot only works in groups.'); - return; - } - - try { - // Check if user is an administrator - const member = await ctx.getChatMember(userId); - const isAdmin = member.status === 'administrator' || member.status === 'creator'; - - if (!isAdmin) { - // Log authorization failure at debug level - console.debug(`Authorization failed - Chat ID: ${chatId}, User ID: ${userId}`); - await ctx.reply('Only group admins can use this command.'); - return; - } - - // Send keyboard reset message with ReplyKeyboardRemove - // selective: false ensures it removes keyboard for ALL users - const sentMessage = await ctx.reply('Keyboard reset.', { - reply_markup: { - remove_keyboard: true, - selective: false - } - }); - - // Log successful reset - console.log(`Keyboard reset successful - Chat ID: ${chatId}, User ID: ${userId}`); - - // Delete the confirmation message after 7 seconds - // This gives clients time to process the keyboard reset - setTimeout(async() => { - try { - await ctx.deleteMessage(sentMessage.message_id); - } catch (error) { - // Silently continue if deletion fails (permissions, race condition, etc.) - } - }, 7000); - - } catch (error) { - // Fail silently on Telegram API errors (do not spam the group) - console.error(`Error processing command - Chat ID: ${chatId}, User ID: ${userId}:`, error.message); - } -}); - -// Handle errors globally -bot.catch((err, ctx) => { - console.error('Bot error:', err.message); -}); - -// Start polling -console.log('Starting bot polling...'); -bot.launch() - .then(() => { - console.log('Keyboard Reset Bot started successfully!'); - console.log('Bot is now polling for updates...'); - }) - .catch((error) => { - console.error('Failed to start bot:', error.message); - process.exit(1); - }); - -// Enable graceful stop -process.once('SIGINT', () => bot.stop('SIGINT')); -process.once('SIGTERM', () => bot.stop('SIGTERM')); \ No newline at end of file diff --git a/.history/bot_20251216204928.js b/.history/bot_20251216204928.js deleted file mode 100644 index a33cebf..0000000 --- a/.history/bot_20251216204928.js +++ /dev/null @@ -1,120 +0,0 @@ -import { Telegraf } from 'telegraf'; -import dotenv from 'dotenv'; - -dotenv.config(); - -const BOT_TOKEN = process.env.BOT_TOKEN; - -if (!BOT_TOKEN) { - console.error('Error: BOT_TOKEN environment variable is not set'); - process.exit(1); -} - -console.log('Keyboard Reset Bot initializing...'); - -const bot = new Telegraf(BOT_TOKEN); - -// Debug middleware - log all incoming updates -bot.use(async(ctx, next) => { - console.log('Update received:', { - type: ctx.updateType, - chat: ctx.chat ? .type, - text: ctx.message ? .text - }); - return next(); -}); - -// Handle /start command (for private DM) -bot.command('start', async(ctx) => { - const chatType = ctx.chat.type; - - if (chatType === 'private') { - await ctx.reply( - 'Keyboard Reset Bot\n\n' + - 'This bot removes reply keyboard buttons in group chats.\n\n' + - 'How to use:\n' + - '1. Add this bot to a group\n' + - '2. Use /resetkeyboard in the group (admins only)\n\n' + - 'The bot will send a message that clears all reply keyboards for users in the group.' - ); - } else { - // In groups, just acknowledge briefly - await ctx.reply('Use /resetkeyboard to clear reply keyboards (admins only).'); - } -}); - -// Handle /resetkeyboard command -bot.command('resetkeyboard', async(ctx) => { - const chatId = ctx.chat.id; - const userId = ctx.from.id; - const chatType = ctx.chat.type; - - // Log command usage - console.log(`Command /resetkeyboard - Chat ID: ${chatId}, User ID: ${userId}, Chat Type: ${chatType}`); - - // Check if chat is a group or supergroup - if (chatType !== 'group' && chatType !== 'supergroup') { - await ctx.reply('This bot only works in groups.'); - return; - } - - try { - // Check if user is an administrator - const member = await ctx.getChatMember(userId); - const isAdmin = member.status === 'administrator' || member.status === 'creator'; - - if (!isAdmin) { - // Log authorization failure at debug level - console.debug(`Authorization failed - Chat ID: ${chatId}, User ID: ${userId}`); - await ctx.reply('Only group admins can use this command.'); - return; - } - - // Send keyboard reset message with ReplyKeyboardRemove - // selective: false ensures it removes keyboard for ALL users - const sentMessage = await ctx.reply('Keyboard reset.', { - reply_markup: { - remove_keyboard: true, - selective: false - } - }); - - // Log successful reset - console.log(`Keyboard reset successful - Chat ID: ${chatId}, User ID: ${userId}`); - - // Delete the confirmation message after 7 seconds - // This gives clients time to process the keyboard reset - setTimeout(async() => { - try { - await ctx.deleteMessage(sentMessage.message_id); - } catch (error) { - // Silently continue if deletion fails (permissions, race condition, etc.) - } - }, 7000); - - } catch (error) { - // Fail silently on Telegram API errors (do not spam the group) - console.error(`Error processing command - Chat ID: ${chatId}, User ID: ${userId}:`, error.message); - } -}); - -// Handle errors globally -bot.catch((err, ctx) => { - console.error('Bot error:', err.message); -}); - -// Start polling -console.log('Starting bot polling...'); -bot.launch() - .then(() => { - console.log('Keyboard Reset Bot started successfully!'); - console.log('Bot is now polling for updates...'); - }) - .catch((error) => { - console.error('Failed to start bot:', error.message); - process.exit(1); - }); - -// Enable graceful stop -process.once('SIGINT', () => bot.stop('SIGINT')); -process.once('SIGTERM', () => bot.stop('SIGTERM')); \ No newline at end of file diff --git a/.history/bot_20251216204946.js b/.history/bot_20251216204946.js deleted file mode 100644 index 1e41b89..0000000 --- a/.history/bot_20251216204946.js +++ /dev/null @@ -1,120 +0,0 @@ -import { Telegraf } from 'telegraf'; -import dotenv from 'dotenv'; - -dotenv.config(); - -const BOT_TOKEN = process.env.BOT_TOKEN; - -if (!BOT_TOKEN) { - console.error('Error: BOT_TOKEN environment variable is not set'); - process.exit(1); -} - -console.log('Keyboard Reset Bot initializing...'); - -const bot = new Telegraf(BOT_TOKEN); - -// Debug middleware - log all incoming updates -bot.use(async(ctx, next) => { - console.log('Update received:', { - type: ctx.updateType, - chat: ctx.chat?.type, - text: ctx.message?.text - }); - return next(); -}); - -// Handle /start command (for private DM) -bot.command('start', async(ctx) => { - const chatType = ctx.chat.type; - - if (chatType === 'private') { - await ctx.reply( - 'Keyboard Reset Bot\n\n' + - 'This bot removes reply keyboard buttons in group chats.\n\n' + - 'How to use:\n' + - '1. Add this bot to a group\n' + - '2. Use /resetkeyboard in the group (admins only)\n\n' + - 'The bot will send a message that clears all reply keyboards for users in the group.' - ); - } else { - // In groups, just acknowledge briefly - await ctx.reply('Use /resetkeyboard to clear reply keyboards (admins only).'); - } -}); - -// Handle /resetkeyboard command -bot.command('resetkeyboard', async(ctx) => { - const chatId = ctx.chat.id; - const userId = ctx.from.id; - const chatType = ctx.chat.type; - - // Log command usage - console.log(`Command /resetkeyboard - Chat ID: ${chatId}, User ID: ${userId}, Chat Type: ${chatType}`); - - // Check if chat is a group or supergroup - if (chatType !== 'group' && chatType !== 'supergroup') { - await ctx.reply('This bot only works in groups.'); - return; - } - - try { - // Check if user is an administrator - const member = await ctx.getChatMember(userId); - const isAdmin = member.status === 'administrator' || member.status === 'creator'; - - if (!isAdmin) { - // Log authorization failure at debug level - console.debug(`Authorization failed - Chat ID: ${chatId}, User ID: ${userId}`); - await ctx.reply('Only group admins can use this command.'); - return; - } - - // Send keyboard reset message with ReplyKeyboardRemove - // selective: false ensures it removes keyboard for ALL users - const sentMessage = await ctx.reply('Keyboard reset.', { - reply_markup: { - remove_keyboard: true, - selective: false - } - }); - - // Log successful reset - console.log(`Keyboard reset successful - Chat ID: ${chatId}, User ID: ${userId}`); - - // Delete the confirmation message after 7 seconds - // This gives clients time to process the keyboard reset - setTimeout(async() => { - try { - await ctx.deleteMessage(sentMessage.message_id); - } catch (error) { - // Silently continue if deletion fails (permissions, race condition, etc.) - } - }, 7000); - - } catch (error) { - // Fail silently on Telegram API errors (do not spam the group) - console.error(`Error processing command - Chat ID: ${chatId}, User ID: ${userId}:`, error.message); - } -}); - -// Handle errors globally -bot.catch((err, ctx) => { - console.error('Bot error:', err.message); -}); - -// Start polling -console.log('Starting bot polling...'); -bot.launch() - .then(() => { - console.log('Keyboard Reset Bot started successfully!'); - console.log('Bot is now polling for updates...'); - }) - .catch((error) => { - console.error('Failed to start bot:', error.message); - process.exit(1); - }); - -// Enable graceful stop -process.once('SIGINT', () => bot.stop('SIGINT')); -process.once('SIGTERM', () => bot.stop('SIGTERM')); \ No newline at end of file diff --git a/.history/bot_20251216204950.js b/.history/bot_20251216204950.js deleted file mode 100644 index a33cebf..0000000 --- a/.history/bot_20251216204950.js +++ /dev/null @@ -1,120 +0,0 @@ -import { Telegraf } from 'telegraf'; -import dotenv from 'dotenv'; - -dotenv.config(); - -const BOT_TOKEN = process.env.BOT_TOKEN; - -if (!BOT_TOKEN) { - console.error('Error: BOT_TOKEN environment variable is not set'); - process.exit(1); -} - -console.log('Keyboard Reset Bot initializing...'); - -const bot = new Telegraf(BOT_TOKEN); - -// Debug middleware - log all incoming updates -bot.use(async(ctx, next) => { - console.log('Update received:', { - type: ctx.updateType, - chat: ctx.chat ? .type, - text: ctx.message ? .text - }); - return next(); -}); - -// Handle /start command (for private DM) -bot.command('start', async(ctx) => { - const chatType = ctx.chat.type; - - if (chatType === 'private') { - await ctx.reply( - 'Keyboard Reset Bot\n\n' + - 'This bot removes reply keyboard buttons in group chats.\n\n' + - 'How to use:\n' + - '1. Add this bot to a group\n' + - '2. Use /resetkeyboard in the group (admins only)\n\n' + - 'The bot will send a message that clears all reply keyboards for users in the group.' - ); - } else { - // In groups, just acknowledge briefly - await ctx.reply('Use /resetkeyboard to clear reply keyboards (admins only).'); - } -}); - -// Handle /resetkeyboard command -bot.command('resetkeyboard', async(ctx) => { - const chatId = ctx.chat.id; - const userId = ctx.from.id; - const chatType = ctx.chat.type; - - // Log command usage - console.log(`Command /resetkeyboard - Chat ID: ${chatId}, User ID: ${userId}, Chat Type: ${chatType}`); - - // Check if chat is a group or supergroup - if (chatType !== 'group' && chatType !== 'supergroup') { - await ctx.reply('This bot only works in groups.'); - return; - } - - try { - // Check if user is an administrator - const member = await ctx.getChatMember(userId); - const isAdmin = member.status === 'administrator' || member.status === 'creator'; - - if (!isAdmin) { - // Log authorization failure at debug level - console.debug(`Authorization failed - Chat ID: ${chatId}, User ID: ${userId}`); - await ctx.reply('Only group admins can use this command.'); - return; - } - - // Send keyboard reset message with ReplyKeyboardRemove - // selective: false ensures it removes keyboard for ALL users - const sentMessage = await ctx.reply('Keyboard reset.', { - reply_markup: { - remove_keyboard: true, - selective: false - } - }); - - // Log successful reset - console.log(`Keyboard reset successful - Chat ID: ${chatId}, User ID: ${userId}`); - - // Delete the confirmation message after 7 seconds - // This gives clients time to process the keyboard reset - setTimeout(async() => { - try { - await ctx.deleteMessage(sentMessage.message_id); - } catch (error) { - // Silently continue if deletion fails (permissions, race condition, etc.) - } - }, 7000); - - } catch (error) { - // Fail silently on Telegram API errors (do not spam the group) - console.error(`Error processing command - Chat ID: ${chatId}, User ID: ${userId}:`, error.message); - } -}); - -// Handle errors globally -bot.catch((err, ctx) => { - console.error('Bot error:', err.message); -}); - -// Start polling -console.log('Starting bot polling...'); -bot.launch() - .then(() => { - console.log('Keyboard Reset Bot started successfully!'); - console.log('Bot is now polling for updates...'); - }) - .catch((error) => { - console.error('Failed to start bot:', error.message); - process.exit(1); - }); - -// Enable graceful stop -process.once('SIGINT', () => bot.stop('SIGINT')); -process.once('SIGTERM', () => bot.stop('SIGTERM')); \ No newline at end of file diff --git a/.history/bot_20251216205010.js b/.history/bot_20251216205010.js deleted file mode 100644 index 1e41b89..0000000 --- a/.history/bot_20251216205010.js +++ /dev/null @@ -1,120 +0,0 @@ -import { Telegraf } from 'telegraf'; -import dotenv from 'dotenv'; - -dotenv.config(); - -const BOT_TOKEN = process.env.BOT_TOKEN; - -if (!BOT_TOKEN) { - console.error('Error: BOT_TOKEN environment variable is not set'); - process.exit(1); -} - -console.log('Keyboard Reset Bot initializing...'); - -const bot = new Telegraf(BOT_TOKEN); - -// Debug middleware - log all incoming updates -bot.use(async(ctx, next) => { - console.log('Update received:', { - type: ctx.updateType, - chat: ctx.chat?.type, - text: ctx.message?.text - }); - return next(); -}); - -// Handle /start command (for private DM) -bot.command('start', async(ctx) => { - const chatType = ctx.chat.type; - - if (chatType === 'private') { - await ctx.reply( - 'Keyboard Reset Bot\n\n' + - 'This bot removes reply keyboard buttons in group chats.\n\n' + - 'How to use:\n' + - '1. Add this bot to a group\n' + - '2. Use /resetkeyboard in the group (admins only)\n\n' + - 'The bot will send a message that clears all reply keyboards for users in the group.' - ); - } else { - // In groups, just acknowledge briefly - await ctx.reply('Use /resetkeyboard to clear reply keyboards (admins only).'); - } -}); - -// Handle /resetkeyboard command -bot.command('resetkeyboard', async(ctx) => { - const chatId = ctx.chat.id; - const userId = ctx.from.id; - const chatType = ctx.chat.type; - - // Log command usage - console.log(`Command /resetkeyboard - Chat ID: ${chatId}, User ID: ${userId}, Chat Type: ${chatType}`); - - // Check if chat is a group or supergroup - if (chatType !== 'group' && chatType !== 'supergroup') { - await ctx.reply('This bot only works in groups.'); - return; - } - - try { - // Check if user is an administrator - const member = await ctx.getChatMember(userId); - const isAdmin = member.status === 'administrator' || member.status === 'creator'; - - if (!isAdmin) { - // Log authorization failure at debug level - console.debug(`Authorization failed - Chat ID: ${chatId}, User ID: ${userId}`); - await ctx.reply('Only group admins can use this command.'); - return; - } - - // Send keyboard reset message with ReplyKeyboardRemove - // selective: false ensures it removes keyboard for ALL users - const sentMessage = await ctx.reply('Keyboard reset.', { - reply_markup: { - remove_keyboard: true, - selective: false - } - }); - - // Log successful reset - console.log(`Keyboard reset successful - Chat ID: ${chatId}, User ID: ${userId}`); - - // Delete the confirmation message after 7 seconds - // This gives clients time to process the keyboard reset - setTimeout(async() => { - try { - await ctx.deleteMessage(sentMessage.message_id); - } catch (error) { - // Silently continue if deletion fails (permissions, race condition, etc.) - } - }, 7000); - - } catch (error) { - // Fail silently on Telegram API errors (do not spam the group) - console.error(`Error processing command - Chat ID: ${chatId}, User ID: ${userId}:`, error.message); - } -}); - -// Handle errors globally -bot.catch((err, ctx) => { - console.error('Bot error:', err.message); -}); - -// Start polling -console.log('Starting bot polling...'); -bot.launch() - .then(() => { - console.log('Keyboard Reset Bot started successfully!'); - console.log('Bot is now polling for updates...'); - }) - .catch((error) => { - console.error('Failed to start bot:', error.message); - process.exit(1); - }); - -// Enable graceful stop -process.once('SIGINT', () => bot.stop('SIGINT')); -process.once('SIGTERM', () => bot.stop('SIGTERM')); \ No newline at end of file diff --git a/.history/bot_20251216205016.js b/.history/bot_20251216205016.js deleted file mode 100644 index a33cebf..0000000 --- a/.history/bot_20251216205016.js +++ /dev/null @@ -1,120 +0,0 @@ -import { Telegraf } from 'telegraf'; -import dotenv from 'dotenv'; - -dotenv.config(); - -const BOT_TOKEN = process.env.BOT_TOKEN; - -if (!BOT_TOKEN) { - console.error('Error: BOT_TOKEN environment variable is not set'); - process.exit(1); -} - -console.log('Keyboard Reset Bot initializing...'); - -const bot = new Telegraf(BOT_TOKEN); - -// Debug middleware - log all incoming updates -bot.use(async(ctx, next) => { - console.log('Update received:', { - type: ctx.updateType, - chat: ctx.chat ? .type, - text: ctx.message ? .text - }); - return next(); -}); - -// Handle /start command (for private DM) -bot.command('start', async(ctx) => { - const chatType = ctx.chat.type; - - if (chatType === 'private') { - await ctx.reply( - 'Keyboard Reset Bot\n\n' + - 'This bot removes reply keyboard buttons in group chats.\n\n' + - 'How to use:\n' + - '1. Add this bot to a group\n' + - '2. Use /resetkeyboard in the group (admins only)\n\n' + - 'The bot will send a message that clears all reply keyboards for users in the group.' - ); - } else { - // In groups, just acknowledge briefly - await ctx.reply('Use /resetkeyboard to clear reply keyboards (admins only).'); - } -}); - -// Handle /resetkeyboard command -bot.command('resetkeyboard', async(ctx) => { - const chatId = ctx.chat.id; - const userId = ctx.from.id; - const chatType = ctx.chat.type; - - // Log command usage - console.log(`Command /resetkeyboard - Chat ID: ${chatId}, User ID: ${userId}, Chat Type: ${chatType}`); - - // Check if chat is a group or supergroup - if (chatType !== 'group' && chatType !== 'supergroup') { - await ctx.reply('This bot only works in groups.'); - return; - } - - try { - // Check if user is an administrator - const member = await ctx.getChatMember(userId); - const isAdmin = member.status === 'administrator' || member.status === 'creator'; - - if (!isAdmin) { - // Log authorization failure at debug level - console.debug(`Authorization failed - Chat ID: ${chatId}, User ID: ${userId}`); - await ctx.reply('Only group admins can use this command.'); - return; - } - - // Send keyboard reset message with ReplyKeyboardRemove - // selective: false ensures it removes keyboard for ALL users - const sentMessage = await ctx.reply('Keyboard reset.', { - reply_markup: { - remove_keyboard: true, - selective: false - } - }); - - // Log successful reset - console.log(`Keyboard reset successful - Chat ID: ${chatId}, User ID: ${userId}`); - - // Delete the confirmation message after 7 seconds - // This gives clients time to process the keyboard reset - setTimeout(async() => { - try { - await ctx.deleteMessage(sentMessage.message_id); - } catch (error) { - // Silently continue if deletion fails (permissions, race condition, etc.) - } - }, 7000); - - } catch (error) { - // Fail silently on Telegram API errors (do not spam the group) - console.error(`Error processing command - Chat ID: ${chatId}, User ID: ${userId}:`, error.message); - } -}); - -// Handle errors globally -bot.catch((err, ctx) => { - console.error('Bot error:', err.message); -}); - -// Start polling -console.log('Starting bot polling...'); -bot.launch() - .then(() => { - console.log('Keyboard Reset Bot started successfully!'); - console.log('Bot is now polling for updates...'); - }) - .catch((error) => { - console.error('Failed to start bot:', error.message); - process.exit(1); - }); - -// Enable graceful stop -process.once('SIGINT', () => bot.stop('SIGINT')); -process.once('SIGTERM', () => bot.stop('SIGTERM')); \ No newline at end of file diff --git a/.history/bot_20251216205023.js b/.history/bot_20251216205023.js deleted file mode 100644 index a33cebf..0000000 --- a/.history/bot_20251216205023.js +++ /dev/null @@ -1,120 +0,0 @@ -import { Telegraf } from 'telegraf'; -import dotenv from 'dotenv'; - -dotenv.config(); - -const BOT_TOKEN = process.env.BOT_TOKEN; - -if (!BOT_TOKEN) { - console.error('Error: BOT_TOKEN environment variable is not set'); - process.exit(1); -} - -console.log('Keyboard Reset Bot initializing...'); - -const bot = new Telegraf(BOT_TOKEN); - -// Debug middleware - log all incoming updates -bot.use(async(ctx, next) => { - console.log('Update received:', { - type: ctx.updateType, - chat: ctx.chat ? .type, - text: ctx.message ? .text - }); - return next(); -}); - -// Handle /start command (for private DM) -bot.command('start', async(ctx) => { - const chatType = ctx.chat.type; - - if (chatType === 'private') { - await ctx.reply( - 'Keyboard Reset Bot\n\n' + - 'This bot removes reply keyboard buttons in group chats.\n\n' + - 'How to use:\n' + - '1. Add this bot to a group\n' + - '2. Use /resetkeyboard in the group (admins only)\n\n' + - 'The bot will send a message that clears all reply keyboards for users in the group.' - ); - } else { - // In groups, just acknowledge briefly - await ctx.reply('Use /resetkeyboard to clear reply keyboards (admins only).'); - } -}); - -// Handle /resetkeyboard command -bot.command('resetkeyboard', async(ctx) => { - const chatId = ctx.chat.id; - const userId = ctx.from.id; - const chatType = ctx.chat.type; - - // Log command usage - console.log(`Command /resetkeyboard - Chat ID: ${chatId}, User ID: ${userId}, Chat Type: ${chatType}`); - - // Check if chat is a group or supergroup - if (chatType !== 'group' && chatType !== 'supergroup') { - await ctx.reply('This bot only works in groups.'); - return; - } - - try { - // Check if user is an administrator - const member = await ctx.getChatMember(userId); - const isAdmin = member.status === 'administrator' || member.status === 'creator'; - - if (!isAdmin) { - // Log authorization failure at debug level - console.debug(`Authorization failed - Chat ID: ${chatId}, User ID: ${userId}`); - await ctx.reply('Only group admins can use this command.'); - return; - } - - // Send keyboard reset message with ReplyKeyboardRemove - // selective: false ensures it removes keyboard for ALL users - const sentMessage = await ctx.reply('Keyboard reset.', { - reply_markup: { - remove_keyboard: true, - selective: false - } - }); - - // Log successful reset - console.log(`Keyboard reset successful - Chat ID: ${chatId}, User ID: ${userId}`); - - // Delete the confirmation message after 7 seconds - // This gives clients time to process the keyboard reset - setTimeout(async() => { - try { - await ctx.deleteMessage(sentMessage.message_id); - } catch (error) { - // Silently continue if deletion fails (permissions, race condition, etc.) - } - }, 7000); - - } catch (error) { - // Fail silently on Telegram API errors (do not spam the group) - console.error(`Error processing command - Chat ID: ${chatId}, User ID: ${userId}:`, error.message); - } -}); - -// Handle errors globally -bot.catch((err, ctx) => { - console.error('Bot error:', err.message); -}); - -// Start polling -console.log('Starting bot polling...'); -bot.launch() - .then(() => { - console.log('Keyboard Reset Bot started successfully!'); - console.log('Bot is now polling for updates...'); - }) - .catch((error) => { - console.error('Failed to start bot:', error.message); - process.exit(1); - }); - -// Enable graceful stop -process.once('SIGINT', () => bot.stop('SIGINT')); -process.once('SIGTERM', () => bot.stop('SIGTERM')); \ No newline at end of file diff --git a/.history/bot_20251216205028.js b/.history/bot_20251216205028.js deleted file mode 100644 index a33cebf..0000000 --- a/.history/bot_20251216205028.js +++ /dev/null @@ -1,120 +0,0 @@ -import { Telegraf } from 'telegraf'; -import dotenv from 'dotenv'; - -dotenv.config(); - -const BOT_TOKEN = process.env.BOT_TOKEN; - -if (!BOT_TOKEN) { - console.error('Error: BOT_TOKEN environment variable is not set'); - process.exit(1); -} - -console.log('Keyboard Reset Bot initializing...'); - -const bot = new Telegraf(BOT_TOKEN); - -// Debug middleware - log all incoming updates -bot.use(async(ctx, next) => { - console.log('Update received:', { - type: ctx.updateType, - chat: ctx.chat ? .type, - text: ctx.message ? .text - }); - return next(); -}); - -// Handle /start command (for private DM) -bot.command('start', async(ctx) => { - const chatType = ctx.chat.type; - - if (chatType === 'private') { - await ctx.reply( - 'Keyboard Reset Bot\n\n' + - 'This bot removes reply keyboard buttons in group chats.\n\n' + - 'How to use:\n' + - '1. Add this bot to a group\n' + - '2. Use /resetkeyboard in the group (admins only)\n\n' + - 'The bot will send a message that clears all reply keyboards for users in the group.' - ); - } else { - // In groups, just acknowledge briefly - await ctx.reply('Use /resetkeyboard to clear reply keyboards (admins only).'); - } -}); - -// Handle /resetkeyboard command -bot.command('resetkeyboard', async(ctx) => { - const chatId = ctx.chat.id; - const userId = ctx.from.id; - const chatType = ctx.chat.type; - - // Log command usage - console.log(`Command /resetkeyboard - Chat ID: ${chatId}, User ID: ${userId}, Chat Type: ${chatType}`); - - // Check if chat is a group or supergroup - if (chatType !== 'group' && chatType !== 'supergroup') { - await ctx.reply('This bot only works in groups.'); - return; - } - - try { - // Check if user is an administrator - const member = await ctx.getChatMember(userId); - const isAdmin = member.status === 'administrator' || member.status === 'creator'; - - if (!isAdmin) { - // Log authorization failure at debug level - console.debug(`Authorization failed - Chat ID: ${chatId}, User ID: ${userId}`); - await ctx.reply('Only group admins can use this command.'); - return; - } - - // Send keyboard reset message with ReplyKeyboardRemove - // selective: false ensures it removes keyboard for ALL users - const sentMessage = await ctx.reply('Keyboard reset.', { - reply_markup: { - remove_keyboard: true, - selective: false - } - }); - - // Log successful reset - console.log(`Keyboard reset successful - Chat ID: ${chatId}, User ID: ${userId}`); - - // Delete the confirmation message after 7 seconds - // This gives clients time to process the keyboard reset - setTimeout(async() => { - try { - await ctx.deleteMessage(sentMessage.message_id); - } catch (error) { - // Silently continue if deletion fails (permissions, race condition, etc.) - } - }, 7000); - - } catch (error) { - // Fail silently on Telegram API errors (do not spam the group) - console.error(`Error processing command - Chat ID: ${chatId}, User ID: ${userId}:`, error.message); - } -}); - -// Handle errors globally -bot.catch((err, ctx) => { - console.error('Bot error:', err.message); -}); - -// Start polling -console.log('Starting bot polling...'); -bot.launch() - .then(() => { - console.log('Keyboard Reset Bot started successfully!'); - console.log('Bot is now polling for updates...'); - }) - .catch((error) => { - console.error('Failed to start bot:', error.message); - process.exit(1); - }); - -// Enable graceful stop -process.once('SIGINT', () => bot.stop('SIGINT')); -process.once('SIGTERM', () => bot.stop('SIGTERM')); \ No newline at end of file diff --git a/.history/bot_20251216205056.js b/.history/bot_20251216205056.js deleted file mode 100644 index 8969236..0000000 --- a/.history/bot_20251216205056.js +++ /dev/null @@ -1,122 +0,0 @@ -import { Telegraf } from 'telegraf'; -import dotenv from 'dotenv'; - -dotenv.config(); - -const BOT_TOKEN = process.env.BOT_TOKEN; - -if (!BOT_TOKEN) { - console.error('Error: BOT_TOKEN environment variable is not set'); - process.exit(1); -} - -console.log('Keyboard Reset Bot initializing...'); - -const bot = new Telegraf(BOT_TOKEN); - -// Debug middleware - log all incoming updates -bot.use(async (ctx, next) => { - const chatType = ctx.chat ? ctx.chat.type : undefined; - const messageText = ctx.message ? ctx.message.text : undefined; - console.log('Update received:', { - type: ctx.updateType, - chat: chatType, - text: messageText - }); - return next(); -}); - -// Handle /start command (for private DM) -bot.command('start', async(ctx) => { - const chatType = ctx.chat.type; - - if (chatType === 'private') { - await ctx.reply( - 'Keyboard Reset Bot\n\n' + - 'This bot removes reply keyboard buttons in group chats.\n\n' + - 'How to use:\n' + - '1. Add this bot to a group\n' + - '2. Use /resetkeyboard in the group (admins only)\n\n' + - 'The bot will send a message that clears all reply keyboards for users in the group.' - ); - } else { - // In groups, just acknowledge briefly - await ctx.reply('Use /resetkeyboard to clear reply keyboards (admins only).'); - } -}); - -// Handle /resetkeyboard command -bot.command('resetkeyboard', async(ctx) => { - const chatId = ctx.chat.id; - const userId = ctx.from.id; - const chatType = ctx.chat.type; - - // Log command usage - console.log(`Command /resetkeyboard - Chat ID: ${chatId}, User ID: ${userId}, Chat Type: ${chatType}`); - - // Check if chat is a group or supergroup - if (chatType !== 'group' && chatType !== 'supergroup') { - await ctx.reply('This bot only works in groups.'); - return; - } - - try { - // Check if user is an administrator - const member = await ctx.getChatMember(userId); - const isAdmin = member.status === 'administrator' || member.status === 'creator'; - - if (!isAdmin) { - // Log authorization failure at debug level - console.debug(`Authorization failed - Chat ID: ${chatId}, User ID: ${userId}`); - await ctx.reply('Only group admins can use this command.'); - return; - } - - // Send keyboard reset message with ReplyKeyboardRemove - // selective: false ensures it removes keyboard for ALL users - const sentMessage = await ctx.reply('Keyboard reset.', { - reply_markup: { - remove_keyboard: true, - selective: false - } - }); - - // Log successful reset - console.log(`Keyboard reset successful - Chat ID: ${chatId}, User ID: ${userId}`); - - // Delete the confirmation message after 7 seconds - // This gives clients time to process the keyboard reset - setTimeout(async() => { - try { - await ctx.deleteMessage(sentMessage.message_id); - } catch (error) { - // Silently continue if deletion fails (permissions, race condition, etc.) - } - }, 7000); - - } catch (error) { - // Fail silently on Telegram API errors (do not spam the group) - console.error(`Error processing command - Chat ID: ${chatId}, User ID: ${userId}:`, error.message); - } -}); - -// Handle errors globally -bot.catch((err, ctx) => { - console.error('Bot error:', err.message); -}); - -// Start polling -console.log('Starting bot polling...'); -bot.launch() - .then(() => { - console.log('Keyboard Reset Bot started successfully!'); - console.log('Bot is now polling for updates...'); - }) - .catch((error) => { - console.error('Failed to start bot:', error.message); - process.exit(1); - }); - -// Enable graceful stop -process.once('SIGINT', () => bot.stop('SIGINT')); -process.once('SIGTERM', () => bot.stop('SIGTERM')); \ No newline at end of file diff --git a/.history/bot_20251216205100.js b/.history/bot_20251216205100.js deleted file mode 100644 index ed570b7..0000000 --- a/.history/bot_20251216205100.js +++ /dev/null @@ -1,122 +0,0 @@ -import { Telegraf } from 'telegraf'; -import dotenv from 'dotenv'; - -dotenv.config(); - -const BOT_TOKEN = process.env.BOT_TOKEN; - -if (!BOT_TOKEN) { - console.error('Error: BOT_TOKEN environment variable is not set'); - process.exit(1); -} - -console.log('Keyboard Reset Bot initializing...'); - -const bot = new Telegraf(BOT_TOKEN); - -// Debug middleware - log all incoming updates -bot.use(async(ctx, next) => { - const chatType = ctx.chat ? ctx.chat.type : undefined; - const messageText = ctx.message ? ctx.message.text : undefined; - console.log('Update received:', { - type: ctx.updateType, - chat: chatType, - text: messageText - }); - return next(); -}); - -// Handle /start command (for private DM) -bot.command('start', async(ctx) => { - const chatType = ctx.chat.type; - - if (chatType === 'private') { - await ctx.reply( - 'Keyboard Reset Bot\n\n' + - 'This bot removes reply keyboard buttons in group chats.\n\n' + - 'How to use:\n' + - '1. Add this bot to a group\n' + - '2. Use /resetkeyboard in the group (admins only)\n\n' + - 'The bot will send a message that clears all reply keyboards for users in the group.' - ); - } else { - // In groups, just acknowledge briefly - await ctx.reply('Use /resetkeyboard to clear reply keyboards (admins only).'); - } -}); - -// Handle /resetkeyboard command -bot.command('resetkeyboard', async(ctx) => { - const chatId = ctx.chat.id; - const userId = ctx.from.id; - const chatType = ctx.chat.type; - - // Log command usage - console.log(`Command /resetkeyboard - Chat ID: ${chatId}, User ID: ${userId}, Chat Type: ${chatType}`); - - // Check if chat is a group or supergroup - if (chatType !== 'group' && chatType !== 'supergroup') { - await ctx.reply('This bot only works in groups.'); - return; - } - - try { - // Check if user is an administrator - const member = await ctx.getChatMember(userId); - const isAdmin = member.status === 'administrator' || member.status === 'creator'; - - if (!isAdmin) { - // Log authorization failure at debug level - console.debug(`Authorization failed - Chat ID: ${chatId}, User ID: ${userId}`); - await ctx.reply('Only group admins can use this command.'); - return; - } - - // Send keyboard reset message with ReplyKeyboardRemove - // selective: false ensures it removes keyboard for ALL users - const sentMessage = await ctx.reply('Keyboard reset.', { - reply_markup: { - remove_keyboard: true, - selective: false - } - }); - - // Log successful reset - console.log(`Keyboard reset successful - Chat ID: ${chatId}, User ID: ${userId}`); - - // Delete the confirmation message after 7 seconds - // This gives clients time to process the keyboard reset - setTimeout(async() => { - try { - await ctx.deleteMessage(sentMessage.message_id); - } catch (error) { - // Silently continue if deletion fails (permissions, race condition, etc.) - } - }, 7000); - - } catch (error) { - // Fail silently on Telegram API errors (do not spam the group) - console.error(`Error processing command - Chat ID: ${chatId}, User ID: ${userId}:`, error.message); - } -}); - -// Handle errors globally -bot.catch((err, ctx) => { - console.error('Bot error:', err.message); -}); - -// Start polling -console.log('Starting bot polling...'); -bot.launch() - .then(() => { - console.log('Keyboard Reset Bot started successfully!'); - console.log('Bot is now polling for updates...'); - }) - .catch((error) => { - console.error('Failed to start bot:', error.message); - process.exit(1); - }); - -// Enable graceful stop -process.once('SIGINT', () => bot.stop('SIGINT')); -process.once('SIGTERM', () => bot.stop('SIGTERM')); \ No newline at end of file diff --git a/.history/bot_20251216205103.js b/.history/bot_20251216205103.js deleted file mode 100644 index ed570b7..0000000 --- a/.history/bot_20251216205103.js +++ /dev/null @@ -1,122 +0,0 @@ -import { Telegraf } from 'telegraf'; -import dotenv from 'dotenv'; - -dotenv.config(); - -const BOT_TOKEN = process.env.BOT_TOKEN; - -if (!BOT_TOKEN) { - console.error('Error: BOT_TOKEN environment variable is not set'); - process.exit(1); -} - -console.log('Keyboard Reset Bot initializing...'); - -const bot = new Telegraf(BOT_TOKEN); - -// Debug middleware - log all incoming updates -bot.use(async(ctx, next) => { - const chatType = ctx.chat ? ctx.chat.type : undefined; - const messageText = ctx.message ? ctx.message.text : undefined; - console.log('Update received:', { - type: ctx.updateType, - chat: chatType, - text: messageText - }); - return next(); -}); - -// Handle /start command (for private DM) -bot.command('start', async(ctx) => { - const chatType = ctx.chat.type; - - if (chatType === 'private') { - await ctx.reply( - 'Keyboard Reset Bot\n\n' + - 'This bot removes reply keyboard buttons in group chats.\n\n' + - 'How to use:\n' + - '1. Add this bot to a group\n' + - '2. Use /resetkeyboard in the group (admins only)\n\n' + - 'The bot will send a message that clears all reply keyboards for users in the group.' - ); - } else { - // In groups, just acknowledge briefly - await ctx.reply('Use /resetkeyboard to clear reply keyboards (admins only).'); - } -}); - -// Handle /resetkeyboard command -bot.command('resetkeyboard', async(ctx) => { - const chatId = ctx.chat.id; - const userId = ctx.from.id; - const chatType = ctx.chat.type; - - // Log command usage - console.log(`Command /resetkeyboard - Chat ID: ${chatId}, User ID: ${userId}, Chat Type: ${chatType}`); - - // Check if chat is a group or supergroup - if (chatType !== 'group' && chatType !== 'supergroup') { - await ctx.reply('This bot only works in groups.'); - return; - } - - try { - // Check if user is an administrator - const member = await ctx.getChatMember(userId); - const isAdmin = member.status === 'administrator' || member.status === 'creator'; - - if (!isAdmin) { - // Log authorization failure at debug level - console.debug(`Authorization failed - Chat ID: ${chatId}, User ID: ${userId}`); - await ctx.reply('Only group admins can use this command.'); - return; - } - - // Send keyboard reset message with ReplyKeyboardRemove - // selective: false ensures it removes keyboard for ALL users - const sentMessage = await ctx.reply('Keyboard reset.', { - reply_markup: { - remove_keyboard: true, - selective: false - } - }); - - // Log successful reset - console.log(`Keyboard reset successful - Chat ID: ${chatId}, User ID: ${userId}`); - - // Delete the confirmation message after 7 seconds - // This gives clients time to process the keyboard reset - setTimeout(async() => { - try { - await ctx.deleteMessage(sentMessage.message_id); - } catch (error) { - // Silently continue if deletion fails (permissions, race condition, etc.) - } - }, 7000); - - } catch (error) { - // Fail silently on Telegram API errors (do not spam the group) - console.error(`Error processing command - Chat ID: ${chatId}, User ID: ${userId}:`, error.message); - } -}); - -// Handle errors globally -bot.catch((err, ctx) => { - console.error('Bot error:', err.message); -}); - -// Start polling -console.log('Starting bot polling...'); -bot.launch() - .then(() => { - console.log('Keyboard Reset Bot started successfully!'); - console.log('Bot is now polling for updates...'); - }) - .catch((error) => { - console.error('Failed to start bot:', error.message); - process.exit(1); - }); - -// Enable graceful stop -process.once('SIGINT', () => bot.stop('SIGINT')); -process.once('SIGTERM', () => bot.stop('SIGTERM')); \ No newline at end of file diff --git a/.history/package_20251216201322.json b/.history/package_20251216201322.json deleted file mode 100644 index f72481a..0000000 --- a/.history/package_20251216201322.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "keyboard-reset-bot", - "version": "1.0.0", - "description": "A minimal Telegram bot that removes reply keyboard buttons in group chats", - "main": "bot.js", - "type": "module", - "scripts": { - "start": "node bot.js" - }, - "keywords": [ - "telegram", - "bot", - "keyboard", - "reset" - ], - "author": "", - "license": "MIT", - "dependencies": { - "telegraf": "^4.15.0", - "dotenv": "^16.3.1" - } -} - diff --git a/.history/package_20251216201351.json b/.history/package_20251216201351.json deleted file mode 100644 index 33614cc..0000000 --- a/.history/package_20251216201351.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "keyboard-reset-bot", - "version": "1.0.0", - "description": "A minimal Telegram bot that removes reply keyboard buttons in group chats", - "main": "bot.js", - "type": "module", - "scripts": { - "start": "node bot.js" - }, - "keywords": [ - "telegram", - "bot", - "keyboard", - "reset" - ], - "author": "", - "license": "MIT", - "dependencies": { - "telegraf": "^4.15.0", - "dotenv": "^16.3.1" - } -} \ No newline at end of file diff --git a/.history/package_20251216202006.json b/.history/package_20251216202006.json deleted file mode 100644 index 33614cc..0000000 --- a/.history/package_20251216202006.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "keyboard-reset-bot", - "version": "1.0.0", - "description": "A minimal Telegram bot that removes reply keyboard buttons in group chats", - "main": "bot.js", - "type": "module", - "scripts": { - "start": "node bot.js" - }, - "keywords": [ - "telegram", - "bot", - "keyboard", - "reset" - ], - "author": "", - "license": "MIT", - "dependencies": { - "telegraf": "^4.15.0", - "dotenv": "^16.3.1" - } -} \ No newline at end of file