This file contains hidden or 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
| //index.js: | |
| ... | |
| bot.action('longer', (ctx) => { | |
| ctx.editMessageReplyMarkup({inline_keyboard: data.editedInlineKeys.longer}) | |
| }) | |
| ... |
This file contains hidden or 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
| bot.action('order', (ctx) => { | |
| db.collection('basket').find({id: ctx.from.id}).toArray((err, res) => { | |
| if(err) { | |
| let t = 'Ошибка при заказе у юзера ' + ctx.from.id | |
| bot.telegram.sendMessage(config.myid, t) | |
| } | |
| let ans = 'Новый заказ:\n\n' + res | |
| bot.telegram.sendMessage(config.myid, ans) | |
| }) | |
| }) |
This file contains hidden or 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
| bot.start((ctx) => { | |
| if (ctx.chat.id == config.adminID) { | |
| } else | |
| ctx.reply('Привет! Проголодался? У нас есть чем накормить тебя!', makeKeyboard(['📖 Меню', '🛒 Корзина', '📍 Все рестораны'])) | |
| }) | |
| function makeKeyboard(src) { | |
| let even | |
| (src.length % 2 == 0) ? even = true : even = false | |
| let res = [] |
This file contains hidden or 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
| bot.start((ctx) => { | |
| if (ctx.chat.id == config.adminID) { | |
| } else | |
| ctx.reply('Привет! Проголодался? У нас есть чем накормить тебя!', makeKeyboard(['📖 Меню', '🛒 Корзина', '📍 Все рестораны'])) | |
| }) | |
| function makeKeyboard(src) { | |
| let even | |
| (src.length % 2 == 0) ? even = true : even = false | |
| let res = [] |
This file contains hidden or 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
| <--- Last few GCs ---> | |
| [10946:0x2bd8d10] 53382 ms: Mark-sweep 1313.5 (1365.9) -> 1313.4 (1367.4) MB, 1587.4 / 0.0 ms allocation failure GC in old space requested | |
| [10946:0x2bd8d10] 54881 ms: Mark-sweep 1313.4 (1367.4) -> 1313.4 (1335.9) MB, 1499.0 / 0.0 ms last resort GC in old space requested | |
| [10946:0x2bd8d10] 56448 ms: Mark-sweep 1313.4 (1335.9) -> 1313.4 (1335.9) MB, 1566.4 / 0.0 ms last resort GC in old space requested | |
| <--- JS stacktrace ---> | |
| ==== JS stack trace ========================================= |
This file contains hidden or 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
| bot.start((ctx) => { | |
| if (ctx.chat.id == config.adminID) { | |
| } else | |
| ctx.reply('Привет! Проголодался? У нас есть чем накормить тебя!', makeKeyboard(['📖 Меню', '🛒 Корзина', '📍 Все рестораны'])) | |
| }) | |
| function makeKeyboard(src) { | |
| const even = src.length % 2 == 0 | |
| let res = [] |
This file contains hidden or 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
| function makeKeyboard(src) { | |
| const even = src.length % 2 == 0 | |
| let res = [] | |
| let i = 0 | |
| for (i; i < even ? src.length : src.length - 1; i++) { | |
| res.push(i === 0) ? [src[i], src[++i]] : ',' + [src[i], src[++i]] | |
| } | |
| if(!even) res.push([src[++i]]) | |
| return {reply_markup: {keyboard: res, resize_keyboard: true}} | |
| } |
This file contains hidden or 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
| function createKeyboard(...keys) { | |
| if(keys[0].length == 0) return false | |
| let obj = {keyboard: [], resize_keyboard: true} | |
| let arr = [] | |
| for(let i of keys) { | |
| if(i[0].length > 1) { | |
| arr.push(...i) | |
| } else { | |
| arr.push(i) | |
| } |
This file contains hidden or 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
| function makeKeyboard(src) { | |
| const even = src.length % 2 == 0 | |
| let res = [] | |
| let i = 0 | |
| for (i; i < even ? src.length : src.length - 1; i++) { | |
| res.push(i === 0) ? [src[i], src[++i]] : ',' + [src[i], src[++i]] | |
| } | |
| if(!even) res.push([src[++i]]) | |
| return {reply_markup: {keyboard: res, resize_keyboard: true}} | |
| } |
This file contains hidden or 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
| db.collection('store').find({id: ctx.from.id}).toArray() | |
| .then((res) => { | |
| if(res.length == 0) return ctx.reply('Ваша корзина пуста. Нажмите *Меню* для въбора продукта', {reply_markup: createKeyboard('Меню', 'Кoрзина', 'Рестораны'), parse_mode: 'markdown'}) | |
| … }) | |
| .catch((err) => console.log(err)) | |
| })db.collection(‘basket’).find({id: userID}).toArray() | |
| .then() | |
| db.collection(‘basket’).find({}).toArray((err, res) => { | |
| if(res.length == 0) { |