-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
206 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,47 @@ | ||
import { Menu } from "https://deno.land/x/grammy_menu@v1.1.2/mod.ts"; | ||
import { Context } from "../types/index.ts"; | ||
import { cancel,subscriptionMenu,BeginParse } from "../keyboards/index.ts"; | ||
import { cancel, subscriptionMenu, BeginParse } from "../keyboards/index.ts"; | ||
import { UserModel } from "../../server/models.ts"; | ||
|
||
export const marketsMenu = new Menu("marketsMenu").text( | ||
"🇨🇿 sbazar.cz", | ||
|
||
export const marketsMenu = new Menu("marketsMenu") | ||
.text( | ||
"🇨🇿 sbazar.cz", | ||
|
||
async (ctx: Context) => { | ||
const countMaxAds = ctx.session?.countMaxAds; | ||
const registrationDate = ctx.session?.registrationDate; | ||
const publishDate = ctx.session?.publishDate; | ||
const urls = ctx.session?.urls; | ||
if (ctx.session.subActive ===false){ | ||
ctx.session.sbazarStep = 'sub' | ||
await ctx.reply('Подписка не активна',{reply_markup:subscriptionMenu}); | ||
return; | ||
}; | ||
|
||
async (ctx: Context) => { | ||
const chatId = ctx.chat.id.toString(); | ||
const user = await UserModel.findOne({ where: { chatId: chatId } }); | ||
const countMaxAds = ctx.session?.countMaxAds; | ||
const registrationDate = ctx.session?.registrationDate; | ||
const publishDate = ctx.session?.publishDate; | ||
const urls = ctx.session?.urls; | ||
if ( | ||
(user.subEndDateTime = 0 || user.subEndDateTime < Math.floor(Date.now() / 1000)) | ||
) { | ||
ctx.session.sbazarStep = "sub"; | ||
await ctx.reply("Подписка не активна", { | ||
reply_markup: subscriptionMenu, | ||
}); | ||
return; | ||
} | ||
|
||
if ( | ||
countMaxAds !== undefined && | ||
registrationDate !== undefined && | ||
publishDate !== undefined&& urls !== undefined | ||
) { | ||
await ctx.reply( | ||
`*🔎 Фильтры:*\n\n\n📃Количество объявлений: ${ctx.session.countMaxAds}\n📅 Дата регистрации: ${ctx.session.registrationDate}\n🕜 Дата публикации: ${ctx.session.publishDate}\nКатегории : ${ctx.session.urls}`, | ||
{ reply_markup: BeginParse } | ||
); | ||
ctx.session.sbazarStep = "startingSbazar"; | ||
} else { | ||
ctx.session.sbazarStep = "countMaxAds"; | ||
await ctx.reply( | ||
"*🔎 Запуск поиска объявлений*\n\n📃 *Введите максимально допустимое количество активных объявлений у продавца*\n\n Пример : 10", | ||
{ reply_markup: cancel} | ||
); | ||
await ctx.reply({reply_markup: marketsMenu}) | ||
ctx.session.sbazarStep = "countMaxAds"; | ||
} | ||
|
||
if ( | ||
countMaxAds !== undefined && | ||
registrationDate !== undefined && | ||
publishDate !== undefined && | ||
urls !== undefined | ||
) { | ||
await ctx.reply( | ||
`*🔎 Фильтры:*\n\n\n📃Количество объявлений: ${ctx.session.countMaxAds}\n📅 Дата регистрации: ${ctx.session.registrationDate}\n🕜 Дата публикации: ${ctx.session.publishDate}\nКатегории : ${ctx.session.urls}`, | ||
{ reply_markup: BeginParse } | ||
); | ||
ctx.session.sbazarStep = "startingSbazar"; | ||
} else { | ||
ctx.session.sbazarStep = "countMaxAds"; | ||
await ctx.reply( | ||
"*🔎 Запуск поиска объявлений*\n\n📃 *Введите максимально допустимое количество активных объявлений у продавца*\n\n Пример : 10", | ||
{ reply_markup: cancel } | ||
); | ||
await ctx.reply({ reply_markup: marketsMenu }); | ||
ctx.session.sbazarStep = "countMaxAds"; | ||
} | ||
) | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.