Skip to content

Commit

Permalink
📴 v0.4.1 Fixed crash on too long telegram message
Browse files Browse the repository at this point in the history
  • Loading branch information
NightStrang6r committed Sep 13, 2022
1 parent 1c323f2 commit de3489a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "funpayserver",
"version": "0.4.0",
"version": "0.4.1",
"description": "CLI app for auto-managing your FunPay account",
"main": "src/index.js",
"dependencies": {
Expand Down
1 change: 0 additions & 1 deletion src/raise.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ async function raiseLotsIfTime(categories) {
let res = await raiseLot(cat.game_id, cat.node_id);

if(!res.success) {
error = true;
log(`Не удалось поднять предложение ${cat.name}: ${res.msg}`);
cat.time = getNewTiming();
continue;
Expand Down
28 changes: 20 additions & 8 deletions src/telegram.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,28 @@ class TelegramBot {
}

async editAutoIssue(ctx) {
const goods = await load('data/autoIssueGoods.json');
if(!goods) return;
let goodsStr = '';
try {
const goods = await load('data/autoIssueGoods.json');
let goodsStr = '';

for(let i = 0; i < goods.length; i++) {
goodsStr += `[${i + 1}] ${goods[i].name}\n`;
let msg = `📄 <b>Список товаров</b> 📄`;
await ctx.replyWithHTML(msg, this.editGoodsKeyboard.reply());

for(let i = 0; i < goods.length; i++) {
goodsStr += `[${i + 1}] ${goods[i].name}\n`;

if(goodsStr.length > 3000) {
await ctx.replyWithHTML(goodsStr, this.editGoodsKeyboard.reply());
goodsStr = '';
}

if(i == (goods.length - 1)) {
await ctx.replyWithHTML(goodsStr, this.editGoodsKeyboard.reply());
}
}
} catch (err) {
log(`Ошибка при выдаче списка товаров: ${err}`, 'r');
}

let msg = `📄 <b>Список товаров</b> 📄\n\n${goodsStr}`;
ctx.replyWithHTML(msg, this.editGoodsKeyboard.reply());
}

getInfo(ctx) {
Expand Down

0 comments on commit de3489a

Please sign in to comment.