-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
138 lines (121 loc) · 5.56 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import asyncio
import discord
from discord.ext import commands, tasks
from discord.ext.commands import has_permissions, MissingPermissions, Context
from Ranknir.modules.data_management import ServerIDs, load_clan_v2, load_server_v2
from Ranknir.commands.ping import ping
from Ranknir.commands.spit_fire import spit_fire
from Ranknir.modules.elo_list import clan_console_mix_1v1_elo_list, clan_console_mix_1v1_and_2v2_elo_list, clan_console_mix_1v1_and_2v2_and_rotating_elo_list, server_1v1_and_2v2_and_rotating_elo_list, server_1v1_and_2v2_elo_list
# from Ranknir.data.clan_data import test_clan, Pandation, Tews, Frost, KryptX, Empire_United, Grant, aura
from Ranknir.modules.data_management import PlayerIDs
from Ranknir.modules.turn import next_turn, get_turn, reset_turn, prev_turn
from Ranknir.modules.all_legends_elo import send_all_legends_elo
from Ranknir.modules.get_current_order import print_current_order
from Ranknir.commands.test_clan import test_clan_console_mix_1v1_elo_list
from Ranknir.commands.test_server import test_server
from Ranknir.modules.env import env_variable
import json
import logging
from Ranknir.modules.env import env_variable
RANKNIR_ACTIVE = env_variable("RANKNIR_ACTIVE")
RANKNIR_TESTING = env_variable("RANKNIR_TESTING")
logging.basicConfig(level=logging.INFO)
intents = discord.Intents().all()
bot = commands.Bot(command_prefix=['r!', 'R!'], intents=intents)
@tasks.loop(seconds=30)
async def leaderboards_loop():
try:
# get turn
turn = get_turn()
print("current turn: " + str(turn))
# Clans / Servers
if turn == 0:
await clan_console_mix_1v1_and_2v2_and_rotating_elo_list(await load_clan_v2(ServerIDs.PANDATION), bot)
elif turn == 1:
await clan_console_mix_1v1_and_2v2_elo_list(await load_clan_v2(ServerIDs.VCNTY), bot)
elif turn == 2:
await clan_console_mix_1v1_and_2v2_elo_list(await load_clan_v2(ServerIDs.FROST), bot)
elif turn == 3:
await server_1v1_and_2v2_and_rotating_elo_list(await load_server_v2(ServerIDs.M30W), bot)
elif turn == 4:
await clan_console_mix_1v1_and_2v2_and_rotating_elo_list(await load_clan_v2(ServerIDs.TEWS), bot)
elif turn == 5:
await clan_console_mix_1v1_elo_list(await load_clan_v2(ServerIDs.EMPIRE_UNITED), bot)
elif turn == 6:
await server_1v1_and_2v2_and_rotating_elo_list(await load_server_v2(ServerIDs.BHNL), bot)
elif turn == 8:
await server_1v1_and_2v2_elo_list(await load_server_v2(ServerIDs.BRAWL_HUNGARY), bot)
elif turn == 9:
await clan_console_mix_1v1_and_2v2_elo_list(await load_clan_v2(ServerIDs.DIVISION_9), bot)
elif turn == 10:
await clan_console_mix_1v1_and_2v2_elo_list(await load_clan_v2(ServerIDs.AURA), bot)
elif turn == 11:
await clan_console_mix_1v1_and_2v2_elo_list(await load_clan_v2(ServerIDs.EISEN), bot)
# Test Clan
elif turn == 69:
await clan_console_mix_1v1_and_2v2_and_rotating_elo_list(await load_clan_v2(ServerIDs.TEST_SERVER), bot, x=1)
prev_turn
elif turn == 420:
await server_1v1_and_2v2_and_rotating_elo_list(await load_server_v2(ServerIDs.TEST_SERVER), bot)
prev_turn
# Debugging
elif turn == 101:
print("Entered Debugging")
prev_turn()
leaderboards_loop.stop()
# Reset Q
else:
reset_turn()
await send_all_legends_elo(PlayerIDs.CROSSYCHAINSAW, 1165233774305493012, bot)
next_turn()
except Exception as e:
print(e)
next_turn()
await asyncio.sleep(3)
# ┌───────────────────┐
# │ EVENTS │
# └───────────────────┘
@bot.event
async def on_ready():
print(f"Bot reconnected as {bot.user}")
if not leaderboards_loop.is_running():
leaderboards_loop.start()
@bot.event
async def on_disconnect():
print("Bot disconnected. Attempting to reconnect...")
@bot.event
async def on_resumed():
print("Bot reconnected successfully!")
if not leaderboards_loop.is_running():
leaderboards_loop.start()
# ┌───────────────────┐
# │ COMMANDS │
# └───────────────────┘
@bot.command(name='ping')
async def ping_command(ctx):
await ping(ctx)
@bot.command(name='spit')
@has_permissions(manage_roles=True, ban_members=True)
async def spit_fire_command(ctx, server_id):
await spit_fire(bot, ctx, server_id)
@bot.command(name='tc')
@has_permissions(manage_roles=True, ban_members=True)
async def test_clan_command(ctx):
await test_clan_console_mix_1v1_elo_list(bot)
@bot.command(name='ts')
@has_permissions(manage_roles=True, ban_members=True)
async def test_server_command(ctx):
await test_server(bot)
@bot.command(name='tc2')
@has_permissions(manage_roles=True, ban_members=True)
async def test_clan_console_mix_1v1_elo_list_command(ctx):
await clan_console_mix_1v1_and_2v2_and_rotating_elo_list(await load_clan_v2(ServerIDs.TEST_SERVER), bot, x=1)
@bot.command(name='ts2')
@has_permissions(manage_roles=True, ban_members=True)
async def test_server_1v1_and_2v2_and_rotating_elo_list_command(ctx):
await server_1v1_and_2v2_elo_list(await load_server_v2(ServerIDs.TEST_SERVER), bot, x=2)
def run_ranknir():
if RANKNIR_ACTIVE:
bot.run(env_variable("RANKNIR_BOT_TOKEN"))
if RANKNIR_TESTING:
bot.run(env_variable("RANKNIR_TESTING_BOT_TOKEN"))