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:
+1
-1
@@ -48,7 +48,7 @@ class IgnCore:
|
||||
self.last_timer_event = 0
|
||||
self.start_time = int(time.time())
|
||||
self.major_version = "IGNCore v2.9"
|
||||
self.minor_version = "8"
|
||||
self.minor_version = "9"
|
||||
self.incoming_queue = FifoQueue()
|
||||
self.mass_message_queue = None
|
||||
self.conns = DictObject()
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -2,13 +2,16 @@ import time
|
||||
import typing
|
||||
from datetime import datetime
|
||||
|
||||
from core.aochat.BaseModule import BaseModule
|
||||
from core.buddy_service import BuddyService
|
||||
from core.chat_blob import ChatBlob
|
||||
from core.command_alias_service import CommandAliasService
|
||||
from core.command_param_types import Options, Const
|
||||
from core.db import DB
|
||||
from core.decorators import instance, command
|
||||
from core.decorators import instance, command, setting
|
||||
from core.job_scheduler import JobScheduler
|
||||
from core.logger import Logger
|
||||
from core.setting_types import TimeSettingType, NumberSettingType
|
||||
from core.text import Text
|
||||
from core.igncore import IgnCore
|
||||
from core.util import Util
|
||||
@@ -23,15 +26,12 @@ if typing.TYPE_CHECKING:
|
||||
|
||||
|
||||
@instance()
|
||||
class WeeklyController:
|
||||
class WeeklyController(BaseModule):
|
||||
# dates = {"ai": [1618704000, 1619395200],
|
||||
# "bs": [1619913600, 1620604800],
|
||||
# "dio": [1621123200, 1621814400],
|
||||
# }
|
||||
dates = {"ai": [1627171200, 1627862400],
|
||||
"bs": [1628380800, 1629072000],
|
||||
"dio": [1629590400, 1630281600],
|
||||
}
|
||||
dates = {}
|
||||
duration = 60 * 60 * 24 * 42 # 3628800
|
||||
|
||||
def inject(self, registry):
|
||||
@@ -53,6 +53,43 @@ class WeeklyController:
|
||||
self.alias_controller: OrgAliasController = registry.get_instance("org_alias_controller")
|
||||
self.account_service: AccountService = registry.get_instance("account_service")
|
||||
|
||||
def start(self):
|
||||
self.setup_timers(self.weekly_timer().get_value())
|
||||
|
||||
@setting("weekly_timer", 1659225600, "Basis timer for ICC Daily calculations")
|
||||
def weekly_timer(self):
|
||||
return NumberSettingType()
|
||||
|
||||
@command(command="icc", params=[Const("set"), Options(["ai", "bs", "dio"])], description="Adjust the ICC Weekly timer (set currently active week)", access_level="moderator", sub_command="modify")
|
||||
def set_icc_cmd(self, _, _1, daily):
|
||||
# magic numbers:
|
||||
offset = 138240
|
||||
no_weekly = 518400
|
||||
|
||||
daily = daily.lower()
|
||||
timer = time.time()
|
||||
new = (timer//offset) * offset
|
||||
if daily == "ai":
|
||||
pass
|
||||
elif daily == "bs":
|
||||
new -= 14*24*60*60
|
||||
elif daily == "dio":
|
||||
new -= 2*14*24*60*60
|
||||
new = int(new)
|
||||
|
||||
self.setup_timers(new)
|
||||
self.weekly_timer().set_value(new)
|
||||
return f"ICC Weekly timers adjusted. Currently running mission: {daily.upper()}"
|
||||
|
||||
def setup_timers(self, ai):
|
||||
basis = ai
|
||||
duration = 691200
|
||||
none = 518400
|
||||
self.dates.clear()
|
||||
for x in ['ai', 'bs', 'dio']:
|
||||
self.dates[x] = [basis, basis+duration]
|
||||
basis += duration+none
|
||||
|
||||
@command(command="icc", params=[], description="ICC Weekly", access_level="member")
|
||||
def show_raids(self, _):
|
||||
events = [self.get_next_bs(),
|
||||
|
||||
Reference in New Issue
Block a user