lykoss / lykos

Werewolf, the popular detective/social party game (a theme of Mafia)
https://werewolf.chat
Other
127 stars 63 forks source link

Issues with /ns logout then and rejoining the channel #430

Closed jacob1 closed 4 years ago

jacob1 commented 4 years ago

Joining the channel (identified to Nickserv) after being removed from the game for /ns logout won't cause you to be rejoined to the game. Also, lykos will give an error if you /part again after rejoining.

Steps: 1) start a game 2) during the game, /ns logout 3) /part 4) /ns identify 5) /join (you should be automatically rejoined here, but are not) 6) /part the channel again (Error happens here)

traceback
Traceback (most recent call last):
  File "/src/decorators.py", line 218, in __call__
    return self.func(*args, **kwargs)
  File "/src/decorators.py", line 382, in caller
    return self.func(*args, **kwargs)
  File "/src/hooks.py", line 765, in part_chan
    ch.remove_user(user)
  File "/src/channels.py", line 295, in remove_user
    self.users.remove(user)
  File "/lib/python3.8/_collections_abc.py", line 583, in remove
    raise KeyError(value)
KeyError: User('potato', '~jacob1', 'Powder/Developer/lykos.jacob1', None, {})

Local variables in all frames (most recent call last):

Local variables from frame #3 (in part_chan):

cli = 
rawnick = 'potato!~jacob1@Powder/Developer/lykos.jacob1'
chan = '#lykos-test'
reason = '"Leaving"'
ch = Channel('#lykos-test')
user = User('potato', '~jacob1', 'Powder/Developer/lykos.jacob1', None, {})

Local variables from frame #4 (in remove_user):

self = Channel('#lykos-test')
user = User('potato', '~jacob1', 'Powder/Developer/lykos.jacob1', None, {})

Local variables from frame #5 (in remove):

self = {User('thijseigenwijs', '~freenode', '51.77.200.162', 'thijseigenwijs', {Channel('#lykos-test'): set()}), User('ChanServ', 'ChanServ', 'services.', None, {Channel('#lykos-test'): {'o'}}), User('nyuszika7h', 'nyuszika7h', 'lykos/dev/nyuszika7h', 'nyuszika7h', {Channel('#lykos-test'): set()}), User('moonmoon', '~skizzerz', 'lykos/alwayswofl', 'Skizzerz', {Channel('#lykos-test'): set()}), User('ParuNexus', 'parunexus', 'c-73-25-116-162.hsd1.or.comcast.net', 'ParuNexus', {Channel('#lykos-test'): set()}), User('Timson', 'znc', 'unaffiliated/timson', 'Timson', {Channel('#lykos-test'): set()}), User('swagiloo', 'sid11717', 'lykos/Iciloo', 'Iciloo', {Channel('#lykos-test'): set()}), User('potato', '~jacob1', 'Powder/Developer/lykos.jacob1', 'jacob1', {Channel('#lykos-test'): set()}), User('i', 'nymeria', 'unaffiliated/misha/bot/i', 'i', {Channel('#lykos-test'): set()}), User('Nightmare', 'ddoscomin', 'unaffiliated/thetfef', 'TheTFEF', {Channel('#lykos-test'): set()}), User('RandRaven', 'sid405934', 'gateway/web/irccloud.com/x-nwitbimfqjlhacih', 'RandRaven', {Channel('#lykos-test'): set()}), User('Matthew', 'sid55177', 'wikimedia/matthewrbowker', 'matthewrbowker', {Channel('#lykos-test'): set()}), User('FastLizard4', 'fastlizard', 'wikipedia/pdpc.active.FastLizard4', 'FastLizard4', {Channel('#lykos-test'): set()}), User('Iciloo', 'Iciloo', 'lykos/Iciloo', 'Iciloo', {Channel('#lykos-test'): set()}), User('misha', 'sid11718', 'lykos/werekitten', 'misha', {Channel('#lykos-test'): set()}), User('jacob1', 'jacob1', 'Powder/Developer/lykos.jacob1', 'jacob1', {Channel('#lykos-test'): set(), Channel('[REDACTED]'): set()}), BotUser('wofljacobot', '~wofljacob', 'unaffiliated/jacob1/bot/jacobot', 'jacobot', {Channel('#lykos-test'): {'o'}, Channel('[REDACTED]'): set()}), User('[42]', 'N4Y', 'nothing4you.w.tf-w.tf', 'N4Y_', {Channel('#lykos-test'): set()}), User('Caroline', 'nyuszika7h', 'botters/nyuszika7h/bot/caroline', 'Caroline', {Channel('#lykos-test'): {'o'}}), User('Faely', '~fae', 'lykos/dev/Faely', 'Vgr255', {Channel('#lykos-test'): set()}), User('aismallard', '~quassel', 'lykos/aismallard', 'aismallard', {Channel('#lykos-test'): set()}), User('ilbelkyr', 'ilbelkyr', 'freenode/staff/atheme.ilbelkyr', 'ilbelkyr', {Channel('#lykos-test'): set()}), User('nasonfish', 'nasonfish', 'danielbarnes.me', None, {Channel('#lykos-test'): set()})}
value = User('potato', '~jacob1', 'Powder/Developer/lykos.jacob1', None, {})

I noticed that the channel's user list has me in there with my account, but it's trying to remove a version of me without an account. I also saw that user._users had me in there both with and without my account after my join.

Result of "print(target, var.DISCONNECTED, target in var.DISCONNECTED)" in return_to_village: User: potato!~jacob1@Powder/Developer/lykos.jacob1:jacob1 UserDict(potato: (datetime.datetime(2020, 4, 12, 20, 21, 31, 799058), 'account')) False

Not going to do further debugging today. I haven't seen this ever happen in practice. But it could happen if a user does /ns logout, then tries reconnecting to fix the problem.