fix for raid_loot.sql
Added "ALT" status for !raid list !icc is now correctable by using !icc set <currently running weekly mission>
This commit is contained in:
@@ -59,9 +59,9 @@ class Raid:
|
||||
@instance()
|
||||
class RaidbotController(BaseModule):
|
||||
NO_RAID_RUNNING_RESPONSE = "No raid is running."
|
||||
|
||||
lookup = {}
|
||||
def __init__(self):
|
||||
self.raid = None
|
||||
self.raid: Raid = None
|
||||
|
||||
def inject(self, registry):
|
||||
self.bot: IgnCore = registry.get_instance("bot")
|
||||
@@ -130,6 +130,17 @@ class RaidbotController(BaseModule):
|
||||
|
||||
@event(event_type="private_channel_left", description="Autokick inactive characters")
|
||||
def left_channel(self, _1, event_data: server_packets.PrivateChannelClientLeft):
|
||||
main = self.account_service.get_main(event_data.char_id).char_id
|
||||
data = self.is_in_raid(main)
|
||||
if type(data) != Raider:
|
||||
return
|
||||
for alt in data.alts:
|
||||
if self.private_channel_service.in_private_channel(alt.char_id) and alt.level >= self.raid.level:
|
||||
data.active_id = alt.char_id
|
||||
self.send_raid_msg("<green>ALT</green>", f"<highlight>{alt.name}</highlight> "
|
||||
f"[before: <highlight>{data.alts[0].name}</highlight>]")
|
||||
return
|
||||
|
||||
self.raid_kick_cmd(None, None, self.pork.get_character_info(event_data.char_id), "Left private channel")
|
||||
|
||||
@command(command="raid", params=[Const("start"), Any("raid_name")],
|
||||
@@ -399,11 +410,22 @@ class RaidbotController(BaseModule):
|
||||
for name, raider in raiders.items():
|
||||
if not raider.in_raid and raider.channel_id > 2:
|
||||
continue
|
||||
alt = None
|
||||
if not raider.in_raid:
|
||||
print(raider)
|
||||
for x in self.raid.raiders:
|
||||
x: Raider
|
||||
if not x.is_active:
|
||||
continue
|
||||
if raider.char_id in [y.char_id for y in x.alts]:
|
||||
print(raider)
|
||||
alt = f"<yellow>ALT</yellow> [{self.character_service.get_char_name(x.active_id)}]"
|
||||
entry = f"{self.util.get_prof_icon(raider.profession)} " \
|
||||
f"{self.text.zfill(raider.level, 220)}/<green>{self.text.zfill(raider.ai_level, 30)}</green> " \
|
||||
f"{raider.name} [<highlight>{raider.main_name or raider.name}</highlight>] - " \
|
||||
f"{'<green>In Raid</green>' if raider.in_raid else '<red>Not in Raid</red>'}"
|
||||
if raider.in_raid:
|
||||
f"{'<green>In Raid</green>' if raider.in_raid else alt if alt else '<red>Not in Raid</red>'}"
|
||||
|
||||
if raider.in_raid or alt:
|
||||
entry += f" - [{self.text.make_tellcmd('Kick', f'raid kick {raider.name} <no reason given>')}]"
|
||||
else:
|
||||
entry += f" - [{self.text.make_tellcmd('Add', f'raid add {raider.name}')}]"
|
||||
@@ -574,17 +596,20 @@ class RaidbotController(BaseModule):
|
||||
sql = "SELECT * FROM raid_log ORDER BY raid_end DESC LIMIT 30"
|
||||
raids = self.db.query(sql)
|
||||
|
||||
for x in raids:
|
||||
if x.started_by not in self.lookup:
|
||||
self.lookup[x.started_by] = self.db.query_single("SELECT name from player where char_id=?", [x.started_by]).name
|
||||
blob = ""
|
||||
for raid in raids:
|
||||
participant_link = self.text.make_chatcmd("Log", "/tell <myname> raid logentry %d" % raid.raid_id)
|
||||
timestamp = self.util.format_datetime(raid.raid_start)
|
||||
leader_name = self.character_service.resolve_char_to_name(raid.started_by)
|
||||
leader_name = self.character_service.resolve_char_to_name(self.lookup[raid.started_by])
|
||||
blob += f"[{raid.raid_id:d}] [{timestamp}] <highlight>{raid.raid_name}</highlight> " \
|
||||
f"started by <highlight>{leader_name}</highlight> [{participant_link}]\n"
|
||||
|
||||
return ChatBlob("Raid history", blob)
|
||||
|
||||
def is_in_raid(self, main_id: int) -> Union[bool, Raider]:
|
||||
def is_in_raid(self, main_id: int) -> Union[bool, Raider, None]:
|
||||
if self.raid is None:
|
||||
return True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user