Mohammed Foud
commited on
Commit
·
6929493
1
Parent(s):
1d55f2a
all
Browse files- src/bots/handlers/mainMenuHandlers.ts +3 -25
- src/index.ts +1 -1
src/bots/handlers/mainMenuHandlers.ts
CHANGED
|
@@ -38,31 +38,6 @@ export const handleLoginAction = async (ctx: BotContext) => {
|
|
| 38 |
options: getBackToMainMenuButton()
|
| 39 |
};
|
| 40 |
}
|
| 41 |
-
|
| 42 |
-
// Check group membership if required
|
| 43 |
-
const botData = ctx.botData;
|
| 44 |
-
if (botData?.join_group_required && botData?.group_channel_username) {
|
| 45 |
-
try {
|
| 46 |
-
const chatMember = await ctx.telegram.getChatMember(
|
| 47 |
-
botData.group_channel_username,
|
| 48 |
-
telegramId
|
| 49 |
-
);
|
| 50 |
-
|
| 51 |
-
if (!['member', 'administrator', 'creator'].includes(chatMember.status)) {
|
| 52 |
-
return {
|
| 53 |
-
message: messageManager.getMessage('join_group_required')
|
| 54 |
-
.replace('{group}', botData.group_channel_username),
|
| 55 |
-
options: getBackToMainMenuButton()
|
| 56 |
-
};
|
| 57 |
-
}
|
| 58 |
-
} catch (error: any) {
|
| 59 |
-
logger.error(`Error checking group membership: ${error.message}`);
|
| 60 |
-
return {
|
| 61 |
-
message: messageManager.getMessage('login_error_system'),
|
| 62 |
-
options: getBackToMainMenuButton()
|
| 63 |
-
};
|
| 64 |
-
}
|
| 65 |
-
}
|
| 66 |
|
| 67 |
if (authService.isUserLoggedIn(telegramId,ctx)) {
|
| 68 |
return {
|
|
@@ -96,9 +71,12 @@ export const handleLoginAction = async (ctx: BotContext) => {
|
|
| 96 |
};
|
| 97 |
} else {
|
| 98 |
try {
|
|
|
|
|
|
|
| 99 |
const { user: newUser, password } = await authService.createUser(telegramId, firstName, ctx);
|
| 100 |
authService.setUserLoggedIn(telegramId,ctx, true);
|
| 101 |
|
|
|
|
| 102 |
return {
|
| 103 |
message: messageManager.getMessage('account_created_success')
|
| 104 |
.replace('{firstName}', firstName)
|
|
|
|
| 38 |
options: getBackToMainMenuButton()
|
| 39 |
};
|
| 40 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
if (authService.isUserLoggedIn(telegramId,ctx)) {
|
| 43 |
return {
|
|
|
|
| 71 |
};
|
| 72 |
} else {
|
| 73 |
try {
|
| 74 |
+
|
| 75 |
+
|
| 76 |
const { user: newUser, password } = await authService.createUser(telegramId, firstName, ctx);
|
| 77 |
authService.setUserLoggedIn(telegramId,ctx, true);
|
| 78 |
|
| 79 |
+
|
| 80 |
return {
|
| 81 |
message: messageManager.getMessage('account_created_success')
|
| 82 |
.replace('{firstName}', firstName)
|
src/index.ts
CHANGED
|
@@ -33,4 +33,4 @@ async function startServer() {
|
|
| 33 |
startServer();
|
| 34 |
|
| 35 |
|
| 36 |
-
handleAddTelegrafBot("049a92c4-7654-43f6-8e6f-7ff5cce78995")
|
|
|
|
| 33 |
startServer();
|
| 34 |
|
| 35 |
|
| 36 |
+
// handleAddTelegrafBot("049a92c4-7654-43f6-8e6f-7ff5cce78995")
|