ElementalAlchemist / txircd

Modular IRCd built using Twisted. Made to be extremely customizable.
BSD 3-Clause "New" or "Revised" License
19 stars 5 forks source link

Implement server notices (usermode +s) #56

Closed Heufneutje closed 10 years ago

Heufneutje commented 10 years ago

This implements the server notice mechanism. It adds umode +s which acts as a listmode and keeps track of what users are subscribed to what events. It supports using multiple mode parameters using commas and can list what events the user is subscribed to. Oper permissions are split into different permissions for each event with a "servernotice-all" wildcard permission. It also implements the following snomasks:

Heufneutje commented 10 years ago

This should be ready now.

ElementalAlchemist commented 10 years ago

Since you store users in the subscribe lists and then just leave them and hope for the best, you'll end up with lots of disconnected users in the list. Instead, you should do one of the following:

  1. Use the "quit" action (and the "remotequit" action unless you filter entries that are going in to just local users as I mentioned in the diff comments) and remove all instances of the quitting user from the subscribe lists.
  2. Save UUIDs instead of users and garbage collect them when you send a notice.
ekimekim commented 10 years ago

option 3: use a weakref.WeakSet(), which is like a set() but will automatically drop members when they're no longer referenced anywhere else.

Eg.

x = object() s = WeakSet([x]) print len(s) 1 del x print len(s) 0

edit: ugh, why is the markdown so broken just on this one comment

Heufneutje commented 10 years ago

Can we guarantee the reference is gone when a user disconnects though? And yes, I'll change it so that only a local user gets added to the subscribe list. That should prevent them from getting the same notice from every single server.

ekimekim commented 10 years ago

Well you'd still have to check if the user is still connected before sending them anything. But that case would be rare, and you won't need to manually delete things.

Heufneutje commented 10 years ago

Added a check to make sure only local users get added to the subscribed list and implemented ekimekim's idea of using a WeakSet.