Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
159 commits
Select commit Hold shift + click to select a range
bbc7bf6
added mkwii branch
itoi06 Mar 7, 2024
f3241d6
updated config file
itoi06 Apr 9, 2024
c0a1ac5
changed method of fetching player mmr
itoi06 Apr 9, 2024
264cfcd
separated list and history channels
itoi06 Apr 9, 2024
142b2f5
Changed Sub Command
parappurame Apr 11, 2024
8afe115
Removed @here ping from new queues
parappurame Apr 11, 2024
0810ab1
Essential Changes for MKW Lounge
emilp-595 Apr 26, 2024
12948c9
Thread Messages
emilp-595 May 8, 2024
144dea3
Lounge Test 1 Fixes
emilp-595 May 16, 2024
9b598a1
Add roles to queue channels
emilp-595 May 16, 2024
f55f3c1
Added Table Bot to Queue Rooms
emilp-595 May 16, 2024
af572b7
Fixed "c" command
emilp-595 May 16, 2024
cdc2231
Added Changes since previous test
emilp-595 Jun 15, 2024
ccc3d48
Canning + Sub Issues Fix
emilp-595 Jun 15, 2024
5beafcc
Added Track Type to config
emilp-595 Jun 20, 2024
4caf62b
Update .gitignore
BadWolf1023 Jun 22, 2024
513a484
Type hints for reading clarity and IDE help
BadWolf1023 Jun 22, 2024
ac33a09
Refactor for reading clarity
BadWolf1023 Jun 22, 2024
d751a6b
Refactor count_registered for readability/conciseness
BadWolf1023 Jun 22, 2024
d305d4a
Refactor confirmed_list for readability/conciseness
BadWolf1023 Jun 22, 2024
f0de7d1
Refactor is_registered for readability/conciseness
BadWolf1023 Jun 22, 2024
f4e60ef
Refactor has_player for readability/conciseness
BadWolf1023 Jun 22, 2024
2ab5a07
Refactor num_confirmed for readability/conciseness
BadWolf1023 Jun 22, 2024
784d463
Refactor get_unconfirmed for readability/conciseness
BadWolf1023 Jun 22, 2024
aac7c2a
Refactor __lt__ for readability/conciseness
BadWolf1023 Jun 22, 2024
5adeec5
Refactor __gt__ for readability/conciseness
BadWolf1023 Jun 22, 2024
c64066d
Minor code formatting
BadWolf1023 Jun 22, 2024
ecf4ab4
Bad practice to shadow global functions
BadWolf1023 Jun 22, 2024
8f5a5ef
Combine 2 lines of text into 1
BadWolf1023 Jun 22, 2024
86ed776
Clean up messy code, make more concise
BadWolf1023 Jun 22, 2024
3121bce
Overhaul of voting code
BadWolf1023 Jun 22, 2024
3ebb381
New penalty/open rooms time variable
BadWolf1023 Jun 22, 2024
5aadbee
New configuration
BadWolf1023 Jun 22, 2024
eb329e6
Don't print exception, print traceback
BadWolf1023 Jun 22, 2024
68038ea
Add imports
BadWolf1023 Jun 22, 2024
5635b4b
Minor refactor of is_staff
BadWolf1023 Jun 22, 2024
602e244
Adjustable amount for debug_many_players
BadWolf1023 Jun 22, 2024
a912711
Move queue scheduler into sqscheduler
BadWolf1023 Jun 22, 2024
9936118
Minor items
BadWolf1023 Jun 22, 2024
f70151e
Main overhaul
BadWolf1023 Jun 22, 2024
d72518b
Minor refactor
BadWolf1023 Jun 22, 2024
e625337
Add comments
BadWolf1023 Jun 22, 2024
e8c1fa5
Remove irrelevant code
BadWolf1023 Jun 23, 2024
fde29d3
Merge pull request #2 from BadWolf1023/main
BadWolf1023 Jun 23, 2024
428af11
Mogi.size -> Mogi.players_per_team +
BadWolf1023 Jun 23, 2024
31ea091
See last commit
BadWolf1023 Jun 23, 2024
919d5f1
See last commit
BadWolf1023 Jun 23, 2024
2c704d3
Minor refactor for readability
BadWolf1023 Jun 23, 2024
64b204b
Minor refactor for readability
BadWolf1023 Jun 23, 2024
cd3499e
Type hint minor refactor
BadWolf1023 Jun 23, 2024
78551e3
Added common properties to Mogi
BadWolf1023 Jun 23, 2024
b0bce80
Added avg_mmr property to Team
BadWolf1023 Jun 23, 2024
bdc430d
int * int results in int - no need to cast
BadWolf1023 Jun 23, 2024
32d3e9d
Addresses race condition
BadWolf1023 Jun 23, 2024
20a60be
Modification of last commit to make lockdown run before message
BadWolf1023 Jun 23, 2024
b7ef278
Merge pull request #2 from BadWolf1023/main
emilp-595 Jun 24, 2024
6322421
Merge pull request #3 from BadWolf1023/scheduler-refactor
emilp-595 Jun 24, 2024
9badb9d
Reformatted List Message
emilp-595 Jun 25, 2024
a5e423f
Added missing argument in sub command
emilp-595 Jun 25, 2024
925e1ae
Add saving mmr threshold
BadWolf1023 Jun 26, 2024
1eaafc8
Bug fix
BadWolf1023 Jun 26, 2024
65db6d8
Update configs with pingable help roles
BadWolf1023 Jun 26, 2024
64d045c
Add muted and restricted roles to configs
BadWolf1023 Jun 26, 2024
084095a
Added type hints
BadWolf1023 Jun 26, 2024
e552a1f
Added cooldown handler for slash commands
BadWolf1023 Jun 26, 2024
8f8d202
More type hints
BadWolf1023 Jun 26, 2024
4ef91a1
Changed restricted/muted role check for subs
BadWolf1023 Jun 26, 2024
92ee1e6
Added /ping_staff command and role refresher
BadWolf1023 Jun 26, 2024
362a8f6
Removed annoying print
BadWolf1023 Jun 26, 2024
86f22cb
Merge pull request #4 from BadWolf1023/main
emilp-595 Jun 27, 2024
f78a87d
Merge branch 'unacceptable-range-algorithm' into main-to-unacceptable…
BadWolf1023 Jul 1, 2024
052af6b
Merge pull request #3 from BadWolf1023/main-to-unacceptable-range
BadWolf1023 Jul 1, 2024
640d494
Added server flag to configs
BadWolf1023 Jul 6, 2024
515997e
Add helper functions
BadWolf1023 Jul 6, 2024
6039bc9
Load config into common file
BadWolf1023 Jul 6, 2024
9afe16b
Server enumeration
BadWolf1023 Jul 6, 2024
3b7861d
Use config from common
BadWolf1023 Jul 6, 2024
eaeea1c
Avoid using bare exception
BadWolf1023 Jul 6, 2024
4bc8e87
Unnecessary code
BadWolf1023 Jul 6, 2024
e246465
Avoid using bare exceptions
BadWolf1023 Jul 6, 2024
d9fc9ec
Avoid using bare exceptions
BadWolf1023 Jul 6, 2024
21028c7
Import cleanup
BadWolf1023 Jul 6, 2024
425ec55
Helper function to compute averages
BadWolf1023 Jul 6, 2024
27d3339
Remove num_rooms property
BadWolf1023 Jul 6, 2024
fd53843
Team.is_registered -> Team.all_registered
BadWolf1023 Jul 6, 2024
660f224
Refactor of mmr_high, mmr_low
BadWolf1023 Jul 6, 2024
cfffc75
Add players property
BadWolf1023 Jul 6, 2024
90acc6b
Use average function
BadWolf1023 Jul 6, 2024
97ed0a4
Refactor: simplify comparison chain
BadWolf1023 Jul 6, 2024
6e25969
Refactor of Player initialization
BadWolf1023 Jul 6, 2024
00bf0b8
Add mention property for Plater
BadWolf1023 Jul 6, 2024
445c77d
Add __repr__ for Player
BadWolf1023 Jul 6, 2024
2167799
Remove unused function
BadWolf1023 Jul 6, 2024
e34c2c0
Refactor: Add type hinting
BadWolf1023 Jul 6, 2024
f91df62
Remove unused function
BadWolf1023 Jul 6, 2024
bfe1f91
Refactor: Type hint
BadWolf1023 Jul 6, 2024
68ffca1
Remove unused function
BadWolf1023 Jul 6, 2024
b7cbaa8
Change how num_players is computed
BadWolf1023 Jul 6, 2024
a61eb7d
Main one room algorithm
BadWolf1023 Jul 6, 2024
a62007a
Unit Testing for algorithm
BadWolf1023 Jul 6, 2024
11a7794
Bug fix
BadWolf1023 Jul 6, 2024
33b9793
Added function for testing player ratings
BadWolf1023 Jul 6, 2024
7dbd37a
Bug fixed for testing function
BadWolf1023 Jul 6, 2024
74237ad
Bug fix
BadWolf1023 Jul 6, 2024
ea59dd3
Bug fix on display list
BadWolf1023 Jul 6, 2024
712c3c6
Display modification
BadWolf1023 Jul 6, 2024
a4d0cde
Bug fix
BadWolf1023 Jul 6, 2024
a969b16
Addresses #9
BadWolf1023 Jul 6, 2024
563bc6e
Addresses optional part on #9
BadWolf1023 Jul 6, 2024
3093cc4
Bug fix on algorithm
BadWolf1023 Jul 7, 2024
ba44c76
Make players comparable based on mmr
BadWolf1023 Jul 7, 2024
60d74a1
Bug fix
BadWolf1023 Jul 7, 2024
341ec83
Modify display of test function
BadWolf1023 Jul 7, 2024
c76df70
More bug fixes
BadWolf1023 Jul 7, 2024
819f182
Another bug fix
BadWolf1023 Jul 7, 2024
63d9a11
Fixes #13 + Clean refactor
BadWolf1023 Jul 7, 2024
42c9cbb
Minor text adjustment
BadWolf1023 Jul 7, 2024
7bf68dd
Forgot to upload part of refactor
BadWolf1023 Jul 7, 2024
e7f2554
Reverse part of commit, add error message back
BadWolf1023 Jul 7, 2024
07aacde
Merge pull request #4 from BadWolf1023/unacceptable-range-algorithm
BadWolf1023 Jul 8, 2024
e876296
Extend discord command
BadWolf1023 Jul 8, 2024
65639d2
Add additional extension time to Mogi object
BadWolf1023 Jul 8, 2024
c8eae07
Change the extension functionality to...
BadWolf1023 Jul 8, 2024
591f8f9
Finish extend functionality
BadWolf1023 Jul 8, 2024
1ff1908
Bug fixes: extension int should be timedelta
BadWolf1023 Jul 8, 2024
1f37c2c
Bug fix, did not rename class variable in all places
BadWolf1023 Jul 8, 2024
e0931fb
Merge pull request #5 from BadWolf1023/extend-command
BadWolf1023 Jul 8, 2024
9f516ff
Fix bug with mmr check when subbing
BadWolf1023 Jul 8, 2024
c634d63
See last commit
BadWolf1023 Jul 8, 2024
1a2efda
Prevent someone from subbing into room twice
BadWolf1023 Jul 8, 2024
df93b4a
Merge pull request #6 from BadWolf1023/bug-can-sub-multiple-times
BadWolf1023 Jul 8, 2024
b196cff
Structure to Player object to support hosts
BadWolf1023 Jul 8, 2024
2201bcc
Can host command interface support
BadWolf1023 Jul 8, 2024
8fb53c7
Create host_fcs.py
BadWolf1023 Jul 8, 2024
a0ecb52
Mogi.populate_host_fcs
BadWolf1023 Jul 8, 2024
36a73dd
Room.host_list to keep track of the room's host order
BadWolf1023 Jul 8, 2024
1902da7
Room.create_host_list
BadWolf1023 Jul 8, 2024
a487769
Room.get_host_str
BadWolf1023 Jul 8, 2024
85d5cb3
Add mogi_objects.Room to VoteView
BadWolf1023 Jul 8, 2024
6ec8faf
Populate host fcs and create the host list
BadWolf1023 Jul 8, 2024
037f700
When room begins, display the hosts appropriately
BadWolf1023 Jul 8, 2024
735ed34
Textual bug fix
BadWolf1023 Jul 8, 2024
eef4247
Change back to guild id for production
BadWolf1023 Jul 8, 2024
d34837a
Add extra line
BadWolf1023 Jul 8, 2024
45d6828
Merge branch 'unacceptable-range-algorithm' into can_host_command
BadWolf1023 Jul 8, 2024
c82a80f
Merge pull request #7 from BadWolf1023/can_host_command
BadWolf1023 Jul 8, 2024
07ade2d
Thread name will update with tier in title
BadWolf1023 Jul 8, 2024
64a75a0
Change mmr sub range to 700
BadWolf1023 Jul 8, 2024
6e01bce
Update sub range text from 500 to 700
BadWolf1023 Jul 8, 2024
7e6c2cd
Merge pull request #11 from BadWolf1023/unacceptable-range-algorithm
emilp-595 Jul 9, 2024
5dc72ac
Start the first event of the day 1 hour sooner
emilp-595 Jul 9, 2024
1caaf27
Revert "Start the first event of the day 1 hour sooner"
emilp-595 Jul 9, 2024
723e37c
reimplemented all old mk8 queuebot features
itoi06 Jul 14, 2024
f39be8d
Pushed check for specific game mmr fetch into mmr.py file
itoi06 Jul 16, 2024
4ff0680
reverted unnecessary check for game
itoi06 Jul 16, 2024
2f65c81
changed method of checking late player for mk8dx
itoi06 Jul 16, 2024
573ad61
Added an explicit display_time variable for mogis to control how star…
itoi06 Jul 16, 2024
1584e4c
fixed way tier is calculated for rooms
itoi06 Jul 17, 2024
4a3e079
fixed bug with display of names for names with underscores in them
itoi06 Jul 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
/.venv*
/config.json
/credentials.json
.idea/*
/example_configs/test/*
1,211 changes: 794 additions & 417 deletions cogs/SquadQueue.py

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import json
from enum import Enum, auto
from typing import TypeVar, Type, List

_T = TypeVar('T')

with open('./config.json', 'r') as cjson:
CONFIG = json.load(cjson)


class Server(Enum):
MKW = auto()
MK8DX = auto()


if CONFIG["lounge"] == "MKW":
SERVER = Server.MKW
elif CONFIG["lounge"] == "MK8DX":
SERVER = Server.MK8DX
else:
raise ValueError(f"{CONFIG['lounge']} is not a valid option for the 'lounge' attribute in the config.")


def divide_chunks(list_: list, chunk_size: int):
# looping till length l
for i in range(0, len(list_), chunk_size):
yield list_[i:i + chunk_size]


def flatten(matrix: List[List[_T]]) -> List[_T]:
flat_list = []
for row in matrix:
flat_list.extend(row)
return flat_list
47 changes: 47 additions & 0 deletions example_configs/prod/mk8dx_prod_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"token": "",
"is_production": true,
"lounge": "MK8DX",
"lounge_description": "Valid options are MKW or MK8DX",
"guild_id": 445404006177570829,
"queue_join_channel": 1186158671525318719,
"queue_sub_channel": 1186158767029620766,
"queue_list_channel": 1221665101904478340,
"queue_history_channel": 1194440106266865684,
"queue_general_channel": 1186158671525318719,
"admin_roles": [
464610815299944448,
910528103225389107
],
"helper_staff_roles": [
910528103225389107
],
"members_for_channels": [
934740707934081035,
743532508343304242,
735910635082219570
],
"roles_for_channels": [],
"PLACEMENT_PLAYER_MMR": 1500,
"placement_role_id": 730980761322389504,
"frequently_tagged_role_id": 682445864400453739,
"restricted_role_id": 600495108999086090,
"muted_role_id": 600495108999086090,
"queue_messages": true,
"sec_between_queue_msgs": 2,
"username": "username",
"password": "password",
"url": "https://www.mk8dx-lounge.com",
"track_type": "rt",
"FIRST_EVENT_TIME": 0,
"FIRST_EVENT_TIME_DESCRIPTION": "First event time is the number of minutes from 0:00 UTC that the bot would run the first event of the day. As an example, if this were set to 5, and the QUEUE_OPEN_TIME were set to 70, and the bot were to reboot at 2:00 UTC, the next event would immediately start and create rooms at 2:25 UTC.",
"QUEUE_OPEN_TIME": 60,
"JOINING_TIME": 55,
"DISPLAY_OFFSET_MINUTES": 5,
"EXTENSION_TIME": 3,
"ROOM_JOIN_PENALTY_TIME": 5,
"MOGI_LIFETIME": 180,
"SUB_RANGE_MMR_ALLOWANCE": 500,
"SUB_MESSAGE_LIFETIME_SECONDS": 1200,
"ROOM_MMR_THRESHOLD": 9999999
}
58 changes: 58 additions & 0 deletions example_configs/prod/mkw_ct_prod_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"token": "",
"is_production": true,
"lounge": "MKW",
"lounge_description": "Valid options are MKW or MK8DX",
"guild_id": 387347467332485122,
"queue_join_channel": 1253109700107567155,
"queue_sub_channel": 1253109752418930779,
"queue_list_channel": 1253109466027655338,
"queue_history_channel": 1253109800196243618,
"queue_general_channel": 1253109398193045534,
"admin_roles": [
387347888935534593,
877629421811540016
],
"helper_staff_roles": [
520808674411937792,
792891432301625364,
521149807994208295
],
"members_for_channels": [
235148962103951360,
155149108183695360,
815483289515196416,
892420397570592768,
775415990238314518,
774812906830299136,
745443073202323586,
774866940950872095,
1019051989734273054
],
"roles_for_channels": [
520808645252874240,
520808674411937792
],
"PLACEMENT_PLAYER_MMR": 750,
"placement_role_id": 723753340063842345,
"frequently_tagged_role_id": 1167985222533533817,
"restricted_role_id": 797208908153618452,
"muted_role_id": 434887701662007296,
"queue_messages": true,
"sec_between_queue_msgs": 2,
"username": "username",
"password": "password",
"url": "https://www.mkwlounge.gg",
"track_type": "ct",
"FIRST_EVENT_TIME": 0,
"FIRST_EVENT_TIME_DESCRIPTION": "First event time is the number of minutes from 0:00 UTC that the bot would run the first event of the day. As an example, if this were set to 5, and the QUEUE_OPEN_TIME were set to 70, and the bot were to reboot at 2:00 UTC, the next event would immediately start and create rooms at 2:25 UTC.",
"QUEUE_OPEN_TIME": 90,
"JOINING_TIME": 85,
"DISPLAY_OFFSET_MINUTES": 0,
"EXTENSION_TIME": 5,
"ROOM_JOIN_PENALTY_TIME": 8,
"MOGI_LIFETIME": 180,
"SUB_RANGE_MMR_ALLOWANCE": 700,
"SUB_MESSAGE_LIFETIME_SECONDS": 1200,
"ROOM_MMR_THRESHOLD": 9000
}
58 changes: 58 additions & 0 deletions example_configs/prod/mkw_rt_prod_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"token": "",
"is_production": true,
"lounge": "MKW",
"lounge_description": "Valid options are MKW or MK8DX",
"guild_id": 387347467332485122,
"queue_join_channel": 1215174119767932979,
"queue_sub_channel": 1215174160234315806,
"queue_list_channel": 1215174057453162496,
"queue_history_channel": 1225709377747685477,
"queue_general_channel": 1241842559429513361,
"admin_roles": [
387347888935534593,
877629421811540016
],
"helper_staff_roles": [
389252697284542465,
399384750923579392,
399382503825211393
],
"members_for_channels": [
235148962103951360,
155149108183695360,
815483289515196416,
892420397570592768,
775415990238314518,
774812906830299136,
745443073202323586,
774866940950872095,
1019051989734273054
],
"roles_for_channels": [
393600567781621761,
389252697284542465
],
"PLACEMENT_PLAYER_MMR": 750,
"placement_role_id": 723753340063842345,
"frequently_tagged_role_id": 1167985222533533817,
"restricted_role_id": 797208908153618452,
"muted_role_id": 434887701662007296,
"queue_messages": true,
"sec_between_queue_msgs": 2,
"username": "username",
"password": "password",
"url": "https://www.mkwlounge.gg",
"track_type": "rt",
"FIRST_EVENT_TIME": 0,
"FIRST_EVENT_TIME_DESCRIPTION": "First event time is the number of minutes from 0:00 UTC that the bot would run the first event of the day. As an example, if this were set to 5, and the QUEUE_OPEN_TIME were set to 70, and the bot were to reboot at 2:00 UTC, the next event would immediately start and create rooms at 2:25 UTC.",
"QUEUE_OPEN_TIME": 72,
"JOINING_TIME": 67,
"DISPLAY_OFFSET_MINUTES": 0,
"EXTENSION_TIME": 5,
"ROOM_JOIN_PENALTY_TIME": 8,
"MOGI_LIFETIME": 180,
"SUB_RANGE_MMR_ALLOWANCE": 700,
"SUB_MESSAGE_LIFETIME_SECONDS": 1200,
"ROOM_MMR_THRESHOLD": 8000
}
43 changes: 43 additions & 0 deletions host_fcs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import common
from typing import Dict
from collections.abc import Iterable
import aiohttp

MKW_HOST_API_URL = f"https://mkwlounge.gg/api/hostfc.php?discord_guild_id={common.CONFIG['guild_id']}&discord_user_id="

SESSION = None


def create_new_session():
global SESSION
SESSION = aiohttp.ClientSession()


async def _get_mk8dx_hosts(discord_ids: Iterable[str]) -> Dict[str, str]:
return {}


async def _get_mkw_hosts(discord_ids: Iterable[str]) -> Dict[str, str]:
request_url = MKW_HOST_API_URL + ",".join(discord_ids)
async with aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=5)) as session:
async with session.get(request_url) as r:
if r.status != 200:
print(f"hostfc endpoint returned status {r.status}")
return {}
results = await r.json()
if "status" not in results or results["status"] != "success":
print(f"hostfc endpoint returned unsuccessful results {results}")
return {}
host_mapping = {}
for item in results["results"]:
host_mapping[item["discord_user_id"]] = item["fc"]
return host_mapping


async def get_hosts(discord_ids: Iterable[str]) -> Dict[str, str]:
if common.SERVER is common.Server.MKW:
return await _get_mkw_hosts(discord_ids)
elif common.SERVER is common.Server.MK8DX:
return await _get_mk8dx_hosts(discord_ids)
else:
raise ValueError("Bad config settings for server.")
12 changes: 9 additions & 3 deletions lounge.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import common
import discord
from discord.ext import commands
import json
Expand All @@ -10,9 +11,7 @@
case_insensitive=True, intents=intents, help_command=None)

initial_extensions = ['cogs.SquadQueue']

with open('./config.json', 'r') as cjson:
bot.config = json.load(cjson)
bot.config = common.CONFIG


@bot.event
Expand Down Expand Up @@ -50,6 +49,13 @@ async def on_command_error(ctx, error):
raise error


@bot.tree.error
async def on_app_command_error(interaction: discord.Interaction, error: discord.app_commands.AppCommandError):
if isinstance(error, discord.app_commands.errors.CommandOnCooldown):
await interaction.response.send_message(f'You are on cooldown. Try again in {round(error.retry_after)}s', ephemeral=True)
else:
raise error

@bot.event
async def setup_hook():
for extension in initial_extensions:
Expand Down
Loading