Compare commits
39 Commits
v1.1
...
e1734376fe
Author | SHA1 | Date | |
---|---|---|---|
e1734376fe | |||
18391544f2 | |||
d97f2fa591 | |||
f17440a6b8 | |||
91f701491e | |||
e412d09cec | |||
3da8e9c074
|
|||
0fea30ccfd
|
|||
ff82e19a4f
|
|||
01f8a73dae
|
|||
d9b72e5ad8
|
|||
9d33ca744a
|
|||
93096eb52b | |||
1ef0976e34 | |||
0ff4ac2cb5 | |||
a78b471785 | |||
a44d059b5d | |||
7ac5252429 | |||
79b8ebf7d0 | |||
209cc60226 | |||
5391ccfb75 | |||
6db861d54b | |||
3170274a13 | |||
32d9f76e38 | |||
0b82d39aab | |||
cf522ab254 | |||
7be86f04c2 | |||
4bc5ffb867 | |||
1be04dbea0 | |||
b4b102421f | |||
852c7d962a | |||
d7c393b5cd | |||
c2828f1baf | |||
de3ecc22be | |||
d98afc53ca | |||
997da7bd2f | |||
4a90544b52 | |||
45d8c830d6 | |||
8ca5916be5 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -159,6 +159,10 @@ config.json
|
||||
*.session
|
||||
*.session-journal
|
||||
|
||||
.venv
|
||||
venv
|
||||
venv_linux
|
||||
venv_windows
|
||||
|
||||
PageSaver/node_modules
|
||||
bin/
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"puppeteer": "~20.2.0",
|
||||
"puppeteer": "~21.0.0",
|
||||
"user-agents": "~1.0.1260"
|
||||
}
|
||||
}
|
||||
|
@@ -6,11 +6,12 @@ const userAgent = require('user-agents');
|
||||
(async () => {
|
||||
|
||||
const url = process.argv[2];
|
||||
const browser = await puppeteer.launch();
|
||||
const binary = process.argv[3];
|
||||
const browser = await puppeteer.launch({ executablePath: binary });
|
||||
const page = await browser.newPage();
|
||||
await page.setUserAgent(userAgent.random().toString());
|
||||
|
||||
await page.goto(url, {waitUntil: 'load'});
|
||||
await page.goto(url, { waitUntil: 'load' });
|
||||
|
||||
const html = await page.content();
|
||||
|
||||
|
@@ -2,8 +2,7 @@ import logging
|
||||
from os import getpid
|
||||
|
||||
from convopyro import Conversation
|
||||
|
||||
from modules.app import PyroClient
|
||||
from libbot.pyrogram.classes import PyroClient
|
||||
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
|
10
config.json
10
config.json
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"owner_id": 0,
|
||||
"bot": {
|
||||
"api_id": 0,
|
||||
"api_hash": "",
|
||||
"bot_token": "",
|
||||
"workers": 1
|
||||
},
|
||||
"use_compiled_page_saver": false
|
||||
}
|
80
config_example.json
Normal file
80
config_example.json
Normal file
@@ -0,0 +1,80 @@
|
||||
{
|
||||
"locale": "en",
|
||||
"bot": {
|
||||
"owner": 0,
|
||||
"api_id": 0,
|
||||
"api_hash": "",
|
||||
"bot_token": "",
|
||||
"scoped_commands": true
|
||||
},
|
||||
"use_compiled_page_saver": false,
|
||||
"reports": {
|
||||
"chat_id": "owner"
|
||||
},
|
||||
"disabled_plugins": [],
|
||||
"commands": {
|
||||
"help": {
|
||||
"scopes": [
|
||||
{
|
||||
"name": "BotCommandScopeDefault"
|
||||
},
|
||||
{
|
||||
"name": "BotCommandScopeChat",
|
||||
"chat_id": "owner"
|
||||
}
|
||||
]
|
||||
},
|
||||
"balance": {
|
||||
"scopes": [
|
||||
{
|
||||
"name": "BotCommandScopeDefault"
|
||||
},
|
||||
{
|
||||
"name": "BotCommandScopeChat",
|
||||
"chat_id": "owner"
|
||||
}
|
||||
]
|
||||
},
|
||||
"topup": {
|
||||
"scopes": [
|
||||
{
|
||||
"name": "BotCommandScopeDefault"
|
||||
},
|
||||
{
|
||||
"name": "BotCommandScopeChat",
|
||||
"chat_id": "owner"
|
||||
}
|
||||
]
|
||||
},
|
||||
"setcard": {
|
||||
"scopes": [
|
||||
{
|
||||
"name": "BotCommandScopeDefault"
|
||||
},
|
||||
{
|
||||
"name": "BotCommandScopeChat",
|
||||
"chat_id": "owner"
|
||||
}
|
||||
]
|
||||
},
|
||||
"resetcard": {
|
||||
"scopes": [
|
||||
{
|
||||
"name": "BotCommandScopeDefault"
|
||||
},
|
||||
{
|
||||
"name": "BotCommandScopeChat",
|
||||
"chat_id": "owner"
|
||||
}
|
||||
]
|
||||
},
|
||||
"shutdown": {
|
||||
"scopes": [
|
||||
{
|
||||
"name": "BotCommandScopeChat",
|
||||
"chat_id": "owner"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
10
locale/en.json
Normal file
10
locale/en.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"commands": {
|
||||
"help": "Help menu",
|
||||
"balance": "Card's balance",
|
||||
"topup": "Refill the card",
|
||||
"setcard": "Link the card",
|
||||
"resetcard": "Unlink the card",
|
||||
"shutdown": "Turn the bot off"
|
||||
}
|
||||
}
|
10
locale/uk.json
Normal file
10
locale/uk.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"commands": {
|
||||
"help": "Меню допомоги",
|
||||
"balance": "Баланс картки",
|
||||
"topup": "Поповнити картку",
|
||||
"setcard": "Прив'язати картку",
|
||||
"resetcard": "Відв'язати картку",
|
||||
"shutdown": "Вимкнути бота"
|
||||
}
|
||||
}
|
104
modules/app.py
104
modules/app.py
@@ -1,104 +0,0 @@
|
||||
import logging
|
||||
from os import getpid
|
||||
from time import time
|
||||
|
||||
import pyrogram
|
||||
from libbot import config_get
|
||||
from pyrogram.client import Client
|
||||
from pyrogram.errors import BadRequest
|
||||
from pyrogram.raw.all import layer
|
||||
from pyrogram.types import BotCommand, BotCommandScopeChat
|
||||
from ujson import loads
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class PyroClient(Client):
|
||||
def __init__(self):
|
||||
with open("config.json", "r", encoding="utf-8") as f:
|
||||
config = loads(f.read())
|
||||
super().__init__(
|
||||
name="bwtbot",
|
||||
api_id=config["bot"]["api_id"],
|
||||
api_hash=config["bot"]["api_hash"],
|
||||
bot_token=config["bot"]["bot_token"],
|
||||
workers=config["bot"]["workers"],
|
||||
plugins=dict(root="plugins", exclude=config["disabled_plugins"]),
|
||||
sleep_threshold=120,
|
||||
)
|
||||
|
||||
async def start(self):
|
||||
await super().start()
|
||||
|
||||
self.start_time = time()
|
||||
|
||||
logger.info(
|
||||
"Bot is running with Pyrogram v%s (Layer %s) and has started as @%s on PID %s.",
|
||||
pyrogram.__version__,
|
||||
layer,
|
||||
self.me.username,
|
||||
getpid(),
|
||||
)
|
||||
|
||||
try:
|
||||
await self.send_message(
|
||||
chat_id=await config_get("chat_id", "reports"),
|
||||
text=f"Bot started PID `{getpid()}`",
|
||||
)
|
||||
except BadRequest:
|
||||
logger.warning("Unable to send message to report chat.")
|
||||
|
||||
await self.set_bot_commands(
|
||||
[
|
||||
BotCommand("help", "Меню допомоги"),
|
||||
BotCommand("balance", "Баланс картки"),
|
||||
BotCommand("topup", "Поповнити картку"),
|
||||
BotCommand("setcard", "Прив'язати картку"),
|
||||
BotCommand("resetcard", "Відв'язати картку"),
|
||||
],
|
||||
language_code="uk",
|
||||
)
|
||||
|
||||
await self.set_bot_commands(
|
||||
[
|
||||
BotCommand("help", "Меню допомоги"),
|
||||
BotCommand("balance", "Баланс картки"),
|
||||
BotCommand("topup", "Поповнити картку"),
|
||||
BotCommand("setcard", "Прив'язати картку"),
|
||||
BotCommand("resetcard", "Відв'язати картку"),
|
||||
],
|
||||
language_code="ru",
|
||||
)
|
||||
|
||||
await self.set_bot_commands(
|
||||
[
|
||||
BotCommand("help", "Help menu"),
|
||||
BotCommand("balance", "Card's balance"),
|
||||
BotCommand("topup", "Refill card"),
|
||||
BotCommand("setcard", "Link card"),
|
||||
BotCommand("resetcard", "Unlink card"),
|
||||
]
|
||||
)
|
||||
|
||||
await self.set_bot_commands(
|
||||
[
|
||||
BotCommand("help", "Help menu"),
|
||||
BotCommand("balance", "Card's balance"),
|
||||
BotCommand("topup", "Refill card"),
|
||||
BotCommand("setcard", "Link card"),
|
||||
BotCommand("resetcard", "Unlink card"),
|
||||
BotCommand("shutdown", "Turn off the bot"),
|
||||
],
|
||||
scope=BotCommandScopeChat(chat_id=await config_get("owner_id")),
|
||||
)
|
||||
|
||||
async def stop(self):
|
||||
try:
|
||||
await self.send_message(
|
||||
chat_id=await config_get("chat_id", "reports"),
|
||||
text=f"Bot stopped with PID `{getpid()}`",
|
||||
)
|
||||
except BadRequest:
|
||||
logger.warning("Unable to send message to report chat.")
|
||||
await super().stop()
|
||||
logger.warning(f"Bot stopped with PID {getpid()}.")
|
@@ -32,6 +32,7 @@ async def getWaterLeft(cardid, filename, app=None):
|
||||
[
|
||||
"PageSaver/pageSaver",
|
||||
f"https://bwtaqua.com.ua/card-topup/?id={cardid}",
|
||||
"./bin/chrome",
|
||||
]
|
||||
) # , ">", f"data/pages/{str(filename)}.html"])
|
||||
html_file = proc.decode("utf-8")
|
||||
@@ -41,6 +42,7 @@ async def getWaterLeft(cardid, filename, app=None):
|
||||
"node",
|
||||
"./PageSaver/pageSaver.js",
|
||||
f"https://bwtaqua.com.ua/card-topup/?id={cardid}",
|
||||
"./bin/chrome",
|
||||
]
|
||||
) # , ">", f"data/pages/{str(filename)}.html"])
|
||||
html_file = proc.decode("utf-8")
|
||||
@@ -82,7 +84,7 @@ async def getWaterLeft(cardid, filename, app=None):
|
||||
|
||||
if app != None:
|
||||
await app.send_message(
|
||||
await config_get("owner_id"),
|
||||
app.owner,
|
||||
f"**Exception occured:**\n • User: `{str(filename)}`\n • Card: [{cardid}]({url})\n • Exception: `{exp}`\n • TMP UUID: `{tmp_name}`\n • Traceback: `{format_exc()}`",
|
||||
disable_web_page_preview=True,
|
||||
)
|
||||
|
@@ -29,7 +29,5 @@ def userReset(userid, key: str):
|
||||
def userGet(userid, key: str):
|
||||
try:
|
||||
return sync.json_read("data/database.json")[str(userid)][key]
|
||||
except KeyError:
|
||||
return None
|
||||
except FileNotFoundError:
|
||||
except (KeyError, FileNotFoundError):
|
||||
return None
|
||||
|
@@ -52,12 +52,12 @@ async def command_balance(app: Client, msg: Message):
|
||||
f"User {str(msg.from_user.id)} tried to get balance without card set"
|
||||
)
|
||||
except Exception as exp:
|
||||
if msg.from_user.id != await config_get("owner_id"):
|
||||
if msg.from_user.id != app.owner:
|
||||
await msg.reply_text(
|
||||
(await string("error_occured")).format(await string("get_number"))
|
||||
)
|
||||
await app.send_message(
|
||||
await config_get("owner_id"),
|
||||
app.owner,
|
||||
f"Error occured by {str(msg.from_user.id)}:\nException: `{exp}`\nTraceback: `{format_exc()}`",
|
||||
)
|
||||
logger.warning(f"User {str(msg.from_user.id)} could not get left water amount")
|
||||
|
@@ -15,7 +15,7 @@ logger = logging.getLogger(__name__)
|
||||
~filters.scheduled & filters.command(["kill", "die", "shutdown"], prefixes="/") # type: ignore
|
||||
)
|
||||
async def command_shutdown(app: Client, msg: Message):
|
||||
if msg.from_user.id == await config_get("owner_id"):
|
||||
if msg.from_user.id == app.owner:
|
||||
await msg.reply_text(f"Shutting down bot with pid **{getpid()}**")
|
||||
logger.info(f"Shutting down as requested by {msg.from_user.id}")
|
||||
exit()
|
||||
|
@@ -3,7 +3,7 @@ convopyro==0.5
|
||||
pathlib~=1.0.1
|
||||
pyrogram==2.0.106
|
||||
tgcrypto==1.2.5
|
||||
ujson==5.7.0
|
||||
ujson==5.8.0
|
||||
uvloop==0.17.0
|
||||
--extra-index-url https://git.end-play.xyz/api/packages/profitroll/pypi/simple
|
||||
libbot[speed,pyrogram]==0.4
|
||||
libbot[speed,pyrogram]==1.9
|
Reference in New Issue
Block a user