Skip to content

Commit

Permalink
Bugfixes
Browse files Browse the repository at this point in the history
Properly load custom hooks, and ensure that update_account_data works as
intended on networks without services (it will break horribly if you try
to use it on a network with services, a future thing could address that
if desired for cross-network stats tracking or whatever)
  • Loading branch information
skizzerz committed Oct 9, 2023
1 parent 9e7e51e commit a7810a9
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
gamemodes.import_builtin_modes()

# Import user-defined hooks
from src import hooks
import hooks as custom_hooks # type: ignore

# Perform final initialization
events.Event("init", {}).dispatch()
4 changes: 2 additions & 2 deletions src/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from src.events import Event, EventListener
from src import users, config
from src.debug import CheckedSet, CheckedDict
from src.users import User
from src.users import User, BotUser

if TYPE_CHECKING:
# gamestate depends on channels; can't turn this into a top-level import
Expand Down Expand Up @@ -79,7 +79,7 @@ def channels():
yield from _channels.values()

def _chan_join(evt, channel: Channel, user: User):
if user is users.Bot:
if isinstance(user, BotUser):
channel.state = _States.Joined

EventListener(_chan_join).install("chan_join")
Expand Down
4 changes: 3 additions & 1 deletion src/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,9 @@ def join_chan(cli, rawnick, chan, account=None, realname=None):

Event("chan_join", {}).dispatch(ch, user)

if user is users.Bot:
# don't test for users.Bot specifically since chan_join may have caused a swap
# (this only happens in exotic situations where custom code listens to update_account_data)
if isinstance(user, users.BotUser):
ch.mode()
ch.mode(Features["CHANMODES"][0])
ch.who()
Expand Down
5 changes: 3 additions & 2 deletions src/locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,6 @@ def set_home(var: GameState, player: User, home: Location):

@event_listener("del_player")
def on_del_player(evt: Event, var: GameState, player: User, allroles: set[str], death_triggers: bool):
del var.home_locations[:player:]
del var.current_locations[:player:]
if var.in_game:
del var.home_locations[:player:]
del var.current_locations[:player:]
4 changes: 3 additions & 1 deletion src/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ def get(nick=None, ident=None, host=None, account=None, *, allow_multiple=False,
if update and have_raw_nick:
# check for variations in case; this is the *only* time when users.get() can be case-insensitive
if user.lower().partial_match(temp.lower()):
# changing rawnick could swap user out, so we need to fetch the new instance
# (with update=False to avoid recursion)
user.rawnick = raw_nick
return [user] if allow_multiple else user
return get(raw_nick, allow_multiple=allow_multiple, allow_none=allow_none, allow_bot=allow_bot, allow_ghosts=allow_ghosts, update=False)
elif user.partial_match(temp):
potential.append(user)

Expand Down

0 comments on commit a7810a9

Please sign in to comment.