Compare commits

...

4 Commits

Author SHA1 Message Date
Profitroll
1dd8b13297 Improved logging 2023-01-14 13:25:18 +01:00
Profitroll
200f25e130 Updated dependencies 2023-01-14 13:25:09 +01:00
Profitroll
a09c3fb0d4 New error message added 2023-01-14 13:25:02 +01:00
Profitroll
affb54155c User agent randomized 2023-01-14 13:24:44 +01:00
6 changed files with 14 additions and 5 deletions

View File

@@ -1,5 +1,6 @@
{
"dependencies": {
"puppeteer": "^14.4.0"
"puppeteer": "~19.5.2",
"user-agents": "~1.0.1260"
}
}

View File

@@ -1,13 +1,15 @@
// npm install https://github.com/GoogleChrome/puppeteer/
const puppeteer = require('puppeteer');
const userAgent = require('user-agents');
(async () => {
const url = process.argv[2];
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setUserAgent(userAgent.random().toString());
await page.goto(url, {waitUntil: 'load'});
const html = await page.content();

View File

@@ -58,7 +58,8 @@ async def balance(_: Client, msg: Message):
await app.send_chat_action(chat_id=msg.chat.id, action=ChatAction.TYPING)
water_left = await getWaterLeft(userGet(msg.from_user.id, "card"), msg.from_user.id, app)
if water_left == "":
raise EmptyCardException("Card information is empty")
await msg.reply_text(string("error_new").format(f'https://bwtaqua.com.ua/card-topup/?id={userGet(msg.from_user.id, "card")}'))
# raise EmptyCardException("Card information is empty")
elif water_left == "Failure":
await msg.reply_text(string("error_occured").format(string("get_number")))
appendLog(f"User {str(msg.from_user.id)} could not get left water amount")

View File

@@ -20,6 +20,8 @@ async def getWaterLeft(cardid, filename, app=None):
# if path.exists(f"data/pages/{str(filename)}.html") is False:
# run(["touch", f"data/pages/{str(filename)}.html"])
appendLog(f"Trying to get liters for url '{url}'")
if config["use_compiled_page_saver"] is True:
proc = check_output(["PageSaver/pageSaver", f"https://bwtaqua.com.ua/card-topup/?id={cardid}"]) #, ">", f"data/pages/{str(filename)}.html"])

View File

@@ -1,4 +1,5 @@
beautifulsoup4~=4.11.1
pyrogram~=2.0.80
pyrogram~=2.0.97
pathlib~=1.0.1
ujson~=5.6.0
tgcrypto~=1.2.5
ujson~=5.7.0

View File

@@ -6,6 +6,7 @@
"card_unlinked": "Card was unlinked from your Telegram",
"card_not_linked": "You don't have any linked card.\n\nВы можете задать её с помощью команды /setcard\n\n{0}",
"error_occured": "An error occurred while getting the amount of remaining water on the card.\n\nPlease make sure the linked card number is correct. If you are sure that the bot is broken, please contact @profitroll.\n\nLink your card: /setcard\n\n{0}",
"error_new": "An error occurred while getting the amount of remaining water on the card.\n\nLast a few weeks BWT seems to return empty string to balance request from our server. We assume that our server has been blacklisted.\n\nTo check your balance you can use official [BWT App](https://bwtaqua.com.ua/en/#app) or simply bookmark this page: {0}.",
"card_balance": "Card's balance is {0} l. of water",
"top_up": "[Click here to top up](https://bwtaqua.com.ua/card-topup/?id={0})",
"cancel": "Operation cancelled",
@@ -21,6 +22,7 @@
"card_unlinked": "Картку відв'язано від вашого Telegram",
"card_not_linked": "У вас немає прив'язаної картки.\n\nВи можете зробити це за допомогою команди /setcard\n\n{0}",
"error_occured": "При отриманні води на карточці виникла помилка.\n\nБудь ласка, упевніться що номер карти правильний. Якщо ви впевнені, що номер картки правильний та бот зламався зв'яжіться з @profitroll.\n\nПрив'язати карту: /setcard\n\n{0}",
"error_new": "При отриманні води на карточці виникла помилка.\n\nОстанні тижні BWT повертає нашому серверу порожні строки замість балансу. Є підозри, що сервер потрапив у блеклист.\n\nДля перевірки балансу рекомендуємо користуватись офіційним [додатком BWT](https://bwtaqua.com.ua/#app) або просто додати цю сторінку у закладки: {0}.",
"card_balance": "На карточці {0} л. води",
"top_up": "[Натисніть для поповнення](https://bwtaqua.com.ua/card-topup/?id={0})",
"cancel": "Операція відмінена",