File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ export const startCommandHandler = async (ctx) => {
88 `• 📁 Files & Study Materials\n` +
99 `• 📚 Syllabuses & PDFs\n` +
1010 `• 📝 Notes & Resources\n\n` +
11- `Use /search to find and download files!\n` +
11+ `Use /search to find links to files!\n` +
1212 `Use /help to see all available commands.` ;
1313
1414 await ctx . reply ( welcomeMessage , { parse_mode : "Markdown" } ) ;
@@ -23,7 +23,7 @@ export const helpCommandHandler = async (ctx) => {
2323 `🤖 *Learnverse Bot Help*\n\n` +
2424 `I am here to help you access study materials, notes, and syllabuses easily.\n\n` +
2525 `*Available Commands:*\n` +
26- `/search - 🔍 Find file, syllabus & notes\n` +
26+ `/search - 🔍 Find file, syllabus & notes links \n` +
2727 `/help - ℹ️ Show this help message\n` +
2828 `/start - 🔄 Restart the bot session\n\n` +
2929 `_Select /search to browse materials by Branch > Year > Subject_` ;
Original file line number Diff line number Diff line change 11export const isBot = ( ctx ) => {
2- return ctx . update ?. message ?. from ?. is_bot ;
2+ return ctx . from ?. is_bot ;
33} ;
44
55export const isPrivateChat = ( ctx ) => {
6- return ctx . update ?. message ?. chat ?. type === "private" ;
6+ return ctx . chat ?. type === "private" ;
77} ;
88
99export const checkIfNewUser = ( ctx ) => {
10- return ctx . update ?. message ?. new_chat_participant ;
10+ return ctx . message ?. new_chat_participant ;
1111} ;
1212
1313export const checkGroupChat = ( ctx ) => {
14- return ctx . update ?. message ? .chat ?. type === "group " ;
14+ return ctx . chat ?. type === "group" || ctx . chat ?. type === "supergroup " ;
1515} ;
Original file line number Diff line number Diff line change @@ -15,11 +15,11 @@ export const createUserIfNotExists = async (ctx) => {
1515 }
1616
1717 const user = {
18- chatId : ctx . update . message . chat . id ,
19- firstName : ctx . update . message . from . first_name ,
20- lastName : ctx . update . message . from . last_name ,
21- username : ctx . update . message . from . username ,
22- language_code : ctx . update . message . from . language_code ,
18+ chatId : ctx . chat ? .id ,
19+ firstName : ctx . from ? .first_name ,
20+ lastName : ctx . from ? .last_name ,
21+ username : ctx . from ? .username ,
22+ language_code : ctx . from ? .language_code ,
2323 } ;
2424
2525 const newUser = await createUser ( user ) ;
Original file line number Diff line number Diff line change @@ -10,22 +10,11 @@ import logger from "../helpers/logger.js";
1010import fs from "fs" ;
1111
1212export const userAuthAndSetupMiddleware = async ( ctx , next ) => {
13- // Skip middleware for callback queries (inline button clicks)
14- // Callback queries don't have message context and are already authenticated
15- if ( ctx . updateType === "callback_query" ) {
16- logger . debug ( "Skipping middleware for callback query" ) ;
17- return next ( ) ;
18- }
19-
20- // Only validate for messages and commands
21- if ( ! ctx . update . message ) {
22- // Skip for other update types (edited messages, etc.)
23- return next ( ) ;
24- }
25-
2613 // reject if the user is a bot
2714 if ( isBot ( ctx ) ) {
28- ctx . reply ( "You are a bot, bots are not allowed" ) ;
15+ if ( isPrivateChat ( ctx ) ) {
16+ await ctx . reply ( "You are a bot, bots are not allowed" ) ;
17+ }
2918 return ;
3019 }
3120
You can’t perform that action at this time.
0 commit comments