parent
f5042ee19c
commit
2aac31c099
@ -0,0 +1,17 @@ |
||||
from d4dj_utils.manager.asset_manager import AssetManager |
||||
from discord.ext import commands |
||||
|
||||
from miyu_bot.bot.master_asset_manager import MasterFilterManager |
||||
from miyu_bot.bot.name_aliases import NameAliases |
||||
|
||||
|
||||
class D4DJBot(commands.Bot): |
||||
assets: AssetManager |
||||
asset_filters: MasterFilterManager |
||||
aliases: NameAliases |
||||
|
||||
def __init__(self, assets, asset_filters, *args, **kwargs): |
||||
self.assets = assets |
||||
self.asset_filters = asset_filters |
||||
self.aliases = NameAliases(assets) |
||||
super().__init__(*args, **kwargs) |
@ -0,0 +1,58 @@ |
||||
from functools import cached_property |
||||
|
||||
from d4dj_utils.manager.asset_manager import AssetManager |
||||
|
||||
|
||||
class NameAliases: |
||||
assets: AssetManager |
||||
|
||||
def __init__(self, assets): |
||||
self.assets = assets |
||||
|
||||
@cached_property |
||||
def characters_by_name(self): |
||||
characters_by_name = {} |
||||
for character in self.assets.character_master.values(): |
||||
for name in character.full_name_english.split(): |
||||
characters_by_name[name.lower()] = character |
||||
return characters_by_name |
||||
|
||||
@cached_property |
||||
def attributes_by_name(self): |
||||
return {attribute.en_name: attribute for attribute in self.assets.attribute_master.values()} |
||||
|
||||
@cached_property |
||||
def units_by_name(self): |
||||
units_by_name = {unit.name.lower().replace(' ', '_'): unit for unit in self.assets.unit_master.values()} |
||||
units_by_name['rondo'] = units_by_name['燐舞曲'] |
||||
units_by_name['special'] = units_by_name['スペシャル'] |
||||
units_by_name['other'] = units_by_name['その他'] |
||||
return units_by_name |
||||
|
||||
unit_aliases = { |
||||
'happyaround': 'happy_around!', |
||||
'happy_around': 'happy_around!', |
||||
'hapiara': 'happy_around!', |
||||
'happy': 'happy_around!', |
||||
'ha': 'happy_around', |
||||
'peakyp-key': 'peaky_p-key', |
||||
'peakypkey': 'peaky_p-key', |
||||
'peaky': 'peaky_p-key', |
||||
'p-key': 'peaky_p-key', |
||||
'pkey': 'peaky_p-key', |
||||
'pkpk': 'peaky_p-key', |
||||
'pk': 'peaky_p-key', |
||||
'photonmaiden': 'photon_maiden', |
||||
'photome': 'photon_maiden', |
||||
'photon': 'photon_maiden', |
||||
'pm': 'photon_maiden', |
||||
'mermaid': 'merm4id', |
||||
'mmd': 'merm4id', |
||||
'lyricallily': 'lyrical_lily', |
||||
'riririri': 'lyrical_lily', |
||||
'lililili': 'lyrical_lily', |
||||
'lily': 'lyrical_lily', |
||||
'lili': 'lyrical_lily', |
||||
'll': 'lyrical_lily', |
||||
'fuhifumi': 'lyrical_lily', |
||||
} |
@ -1,19 +0,0 @@ |
||||
from d4dj_utils.master.event_master import EventMaster, EventState |
||||
from discord.ext import commands |
||||
|
||||
from main import masters |
||||
|
||||
|
||||
def get_latest_event(ctx: commands.Context) -> EventMaster: |
||||
"""Returns the oldest event that has not ended or the newest event otherwise.""" |
||||
try: |
||||
# NY event overlapped with previous event |
||||
return min((v for v in masters.events.values(ctx) if v.state() == EventState.Open), |
||||
key=lambda e: e.start_datetime) |
||||
except ValueError: |
||||
try: |
||||
return min((v for v in masters.events.values(ctx) if v.state() < EventState.Ended), |
||||
key=lambda e: e.start_datetime) |
||||
except ValueError: |
||||
return max(masters.events.values(ctx), key=lambda v: v.start_datetime) |
||||
|
@ -1,40 +0,0 @@ |
||||
from main import asset_manager |
||||
|
||||
characters_by_name = {} |
||||
for character in asset_manager.character_master.values(): |
||||
for name in character.full_name_english.split(): |
||||
characters_by_name[name.lower()] = character |
||||
|
||||
attributes_by_name = {attribute.en_name: attribute for attribute in asset_manager.attribute_master.values()} |
||||
|
||||
units_by_name = {unit.name.lower().replace(' ', '_'): unit for unit in asset_manager.unit_master.values()} |
||||
units_by_name['rondo'] = units_by_name['燐舞曲'] |
||||
units_by_name['special'] = units_by_name['スペシャル'] |
||||
units_by_name['other'] = units_by_name['その他'] |
||||
unit_aliases = { |
||||
'happyaround': 'happy_around!', |
||||
'happy_around': 'happy_around!', |
||||
'hapiara': 'happy_around!', |
||||
'happy': 'happy_around!', |
||||
'ha': 'happy_around', |
||||
'peakyp-key': 'peaky_p-key', |
||||
'peakypkey': 'peaky_p-key', |
||||
'peaky': 'peaky_p-key', |
||||
'p-key': 'peaky_p-key', |
||||
'pkey': 'peaky_p-key', |
||||
'pkpk': 'peaky_p-key', |
||||
'pk': 'peaky_p-key', |
||||
'photonmaiden': 'photon_maiden', |
||||
'photome': 'photon_maiden', |
||||
'photon': 'photon_maiden', |
||||
'pm': 'photon_maiden', |
||||
'mermaid': 'merm4id', |
||||
'mmd': 'merm4id', |
||||
'lyricallily': 'lyrical_lily', |
||||
'riririri': 'lyrical_lily', |
||||
'lililili': 'lyrical_lily', |
||||
'lily': 'lyrical_lily', |
||||
'lili': 'lyrical_lily', |
||||
'll': 'lyrical_lily', |
||||
'fuhifumi': 'lyrical_lily', |
||||
} |
Loading…
Reference in new issue