Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
c71a7555f9
|
|||
cb755faa9a
|
|||
1859d0532c
|
|||
ebce8e0141
|
@@ -1,5 +1,5 @@
|
|||||||
__name__ = "libbot"
|
__name__ = "libbot"
|
||||||
__version__ = "1.3"
|
__version__ = "1.5"
|
||||||
__license__ = "GPL3"
|
__license__ = "GPL3"
|
||||||
__author__ = "Profitroll"
|
__author__ = "Profitroll"
|
||||||
|
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import logging
|
import logging
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from os import getpid
|
from os import cpu_count, getpid
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from time import time
|
from time import time
|
||||||
from typing import List, Union
|
from typing import Dict, List, Union
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import pyrogram
|
import pyrogram
|
||||||
@@ -54,12 +54,16 @@ class PyroClient(Client):
|
|||||||
bot_token=self.config["bot"]["bot_token"],
|
bot_token=self.config["bot"]["bot_token"],
|
||||||
# Workers should be commented when using convopyro, otherwise
|
# Workers should be commented when using convopyro, otherwise
|
||||||
# handlers land in another event loop and you won't see them
|
# handlers land in another event loop and you won't see them
|
||||||
workers=self.config["bot"]["workers"],
|
workers=self.config["bot"]["workers"]
|
||||||
|
if "workers" in self.config["bot"]
|
||||||
|
else min(32, cpu_count() + 4),
|
||||||
plugins=dict(root="plugins", exclude=self.config["disabled_plugins"]),
|
plugins=dict(root="plugins", exclude=self.config["disabled_plugins"]),
|
||||||
sleep_threshold=120,
|
sleep_threshold=120,
|
||||||
max_concurrent_transmissions=self.config["bot"][
|
max_concurrent_transmissions=self.config["bot"][
|
||||||
"max_concurrent_transmissions"
|
"max_concurrent_transmissions"
|
||||||
],
|
]
|
||||||
|
if "max_concurrent_transmissions" in self.config["bot"]
|
||||||
|
else 1,
|
||||||
)
|
)
|
||||||
self.owner: int = self.config["bot"]["owner"]
|
self.owner: int = self.config["bot"]["owner"]
|
||||||
self.commands: List[PyroCommand] = []
|
self.commands: List[PyroCommand] = []
|
||||||
@@ -76,6 +80,8 @@ class PyroClient(Client):
|
|||||||
|
|
||||||
self.scheduler: Union[AsyncIOScheduler, BackgroundScheduler, None] = scheduler
|
self.scheduler: Union[AsyncIOScheduler, BackgroundScheduler, None] = scheduler
|
||||||
|
|
||||||
|
self.scopes_placeholders: Dict[str, int] = {"owner": self.owner}
|
||||||
|
|
||||||
async def start(self):
|
async def start(self):
|
||||||
await super().start()
|
await super().start()
|
||||||
|
|
||||||
@@ -160,8 +166,9 @@ class PyroClient(Client):
|
|||||||
scope_dict = loads(scope)
|
scope_dict = loads(scope)
|
||||||
|
|
||||||
# Replace "owner" in the bot scope with owner's id
|
# Replace "owner" in the bot scope with owner's id
|
||||||
if "chat_id" in scope_dict and scope_dict["chat_id"] == "owner":
|
for placeholder, chat_id in self.scopes_placeholders.items():
|
||||||
scope_dict["chat_id"] = self.owner
|
if "chat_id" in scope_dict and scope_dict["chat_id"] == placeholder:
|
||||||
|
scope_dict["chat_id"] = chat_id
|
||||||
|
|
||||||
# Create object with the same name and args from the dict
|
# Create object with the same name and args from the dict
|
||||||
try:
|
try:
|
||||||
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "libbot"
|
name = "libbot"
|
||||||
version = "1.3"
|
version = "1.5"
|
||||||
authors = [{ name = "Profitroll" }]
|
authors = [{ name = "Profitroll" }]
|
||||||
description = "Universal bot library with functions needed for basic Discord/Telegram bot development."
|
description = "Universal bot library with functions needed for basic Discord/Telegram bot development."
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
Reference in New Issue
Block a user