-
Notifications
You must be signed in to change notification settings - Fork 12
/
main.py
105 lines (82 loc) · 3.71 KB
/
main.py
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import argparse
import asyncio
import random
from discord.ext import commands
from src import config, message_handler
from src.messages import messages
from src.pokecord import pokecord
from src.sidney import sidney
from src.sushii import sushii
from src.tatsumaki import tatsumaki
from src.kohaipp import kohaipp
class DAB(commands.bot.Bot):
def __init__(self, _onfig_directory, command_prefix):
super().__init__(command_prefix=command_prefix, self_bot=True, fetch_offline_members=False)
self.config_directory = config_directory
self.rand = random.SystemRandom()
self.messages = messages.Messages(self)
self.tatsumaki = tatsumaki.Tatsumaki(self)
self.sushii = sushii.Sushii(self)
self.pokecord = pokecord.Pokecord(self)
self.sidney = sidney.Sidney(self)
self.kohaipp = kohaipp.Kohaipp(self)
self.shared = shared_yaml
self.MessageHandler = message_handler.MessageHandler(self)
async def start_background_tasks(self):
# Check if message farming is enabled and channels are configured
if self.messages.config["enabled"]:
if len(self.messages.config["channels"]) > 0:
self.loop.create_task(self.messages.farm())
# Check if rep farming is enabled
if self.tatsumaki.config["repfarming"]:
await asyncio.sleep(self.rand.randint(6, 7))
self.loop.create_task(self.tatsumaki.rep())
# Check if rep farming is enabled
if self.sushii.config["repfarming"]:
await asyncio.sleep(self.rand.randint(6, 7))
self.loop.create_task(self.sushii.rep())
# Check if fishy farming is enabled
if self.sushii.config["fishyfarming"]:
await asyncio.sleep(self.rand.randint(6, 7))
self.loop.create_task(self.sushii.fishy())
# Check if work farming is enabled
if self.sidney.config["workfarming"]:
await asyncio.sleep(self.rand.randint(6, 7))
self.loop.create_task(self.sidney.work())
if self.kohaipp.config["enabled"]:
# Check if begging automation is enabled
if self.kohaipp.config["begging"]:
await asyncio.sleep(self.rand.randint(6, 7))
self.loop.create_task(self.kohaipp.beg())
# Check if raiding automation is enabled
if self.kohaipp.config["raiding"]:
await asyncio.sleep(self.rand.randint(6, 7))
self.loop.create_task(self.kohaipp.raid())
# Check if mining automation is enabled
if self.kohaipp.config["mining"]:
await asyncio.sleep(self.rand.randint(6, 7))
self.loop.create_task(self.kohaipp.mine())
# Check if bonding automation is enabled
if self.kohaipp.config["bonding"]:
await asyncio.sleep(self.rand.randint(6, 7))
self.loop.create_task(self.kohaipp.bond())
async def on_ready(self):
print("\nLogged in as")
print(self.user.name)
print(self.user.id)
print("------")
await self.start_background_tasks()
async def on_message(self, message):
await self.wait_until_ready()
await self.MessageHandler.handle_message(message)
parser = argparse.ArgumentParser()
parser.add_argument("-c", "--config", required=False, help="Optional directory to read YAML configs from")
args = parser.parse_args()
config_directory = "Configs"
if args.config:
config_directory = args.config
shared = config.Config(f"{config_directory}/Shared.yaml")
shared_yaml = shared.load_config()
client = DAB(config_directory, shared_yaml["prefix"])
client.load_extension("src.COMMANDS")
client.run(shared_yaml["token"], bot=False)