forked from Jaammerr/MintChain-Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
50 lines (39 loc) · 1.2 KB
/
run.py
File metadata and controls
50 lines (39 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import asyncio
import sys
import urllib3
from loguru import logger
from loader import config, semaphore
from src.bot import Bot
from utils import show_dev_info
from models import Account
def setup():
urllib3.disable_warnings()
logger.remove()
logger.add(
sys.stdout,
colorize=True,
format="<light-cyan>{time:HH:mm:ss}</light-cyan> | <level> {level: <8}</level> | - <white>{"
"message}</white>",
)
logger.add("logs.log", rotation="1 day", retention="7 days")
async def run_safe(account: Account):
async with semaphore:
await Bot(account).start()
async def run():
show_dev_info()
logger.info(
f"MintChain Bot started | Version: 1.0 | Total accounts: {len(config.accounts)}\n\n"
)
while True:
logger.info(f"Starting new iteration")
tasks = [
asyncio.create_task(run_safe(account)) for account in config.accounts
]
await asyncio.gather(*tasks)
logger.debug(
f"\n\nIteration finished | Sleeping for {config.iteration_delay} hours\n\n"
)
await asyncio.sleep(config.iteration_delay * 60 * 60)
if __name__ == "__main__":
setup()
asyncio.run(run())