Remove 'channels' from the user interface

We don't use it, as the only places where we'd need to, it's only one channel, and the surrounding code needs to add the user to the channel and vice-versa, so that's pretty pointless.
This commit is contained in:
Vgr E. Barry 2016-11-10 10:44:38 -05:00
parent 52b28b4317
commit e161325d01
2 changed files with 7 additions and 12 deletions

View File

@ -56,7 +56,7 @@ def connect_callback(cli):
# This callback only sets up event listeners # This callback only sets up event listeners
wolfgame.connect_callback() wolfgame.connect_callback()
users.Bot = users.User(cli, botconfig.NICK, None, None, None, None, {}) users.Bot = users.User(cli, botconfig.NICK, None, None, None, None)
users.Bot.modes = set() # only for the bot (user modes) users.Bot.modes = set() # only for the bot (user modes)
# just in case we haven't managed to successfully auth yet # just in case we haven't managed to successfully auth yet

View File

@ -90,11 +90,11 @@ def get(nick, *stuff, **morestuff): # backwards-compatible API - kill this as so
var.USERS[nick] # _user(nick) evaluates lazily, so check eagerly if the nick exists var.USERS[nick] # _user(nick) evaluates lazily, so check eagerly if the nick exists
return _user(nick) return _user(nick)
def _add(cli, *, nick, ident=None, host=None, realname=None, account=None, channels=None): def _add(cli, *, nick, ident=None, host=None, realname=None, account=None):
"""Create a new user, add it to the user list and return it. """Create a new user, add it to the user list and return it.
This function takes up to 6 keyword-only arguments (and no positional This function takes up to 5 keyword-only arguments (and no positional
arguments): nick, ident, host, realname, account and channels. arguments): nick, ident, host, realname and account.
With the exception of the first one, any parameter can be omitted. With the exception of the first one, any parameter can be omitted.
If a matching user already exists, a ValueError will be raised. If a matching user already exists, a ValueError will be raised.
@ -106,16 +106,11 @@ def _add(cli, *, nick, ident=None, host=None, realname=None, account=None, chann
if _exists(nick, ident, host, realname, account, allow_multiple=True, allow_bot=True): # FIXME if _exists(nick, ident, host, realname, account, allow_multiple=True, allow_bot=True): # FIXME
raise ValueError("User already exists: " + _arg_msg.format(nick, ident, host, realname, account, True)) raise ValueError("User already exists: " + _arg_msg.format(nick, ident, host, realname, account, True))
if channels is None:
channels = {}
else:
channels = dict(channels)
cls = User cls = User
if predicate(nick): if predicate(nick):
cls = FakeUser cls = FakeUser
new = cls(cli, nick, ident, host, realname, account, channels) new = cls(cli, nick, ident, host, realname, account)
_users.add(new) _users.add(new)
return new return new
@ -176,14 +171,14 @@ class User(IRCContext):
_messages = defaultdict(list) _messages = defaultdict(list)
def __init__(self, cli, nick, ident, host, realname, account, channels, **kwargs): def __init__(self, cli, nick, ident, host, realname, account, **kwargs):
super().__init__(nick, cli, **kwargs) super().__init__(nick, cli, **kwargs)
self.nick = nick self.nick = nick
self.ident = ident self.ident = ident
self.host = host self.host = host
self.realname = realname self.realname = realname
self.account = account self.account = account
self.channels = channels self.channels = {}
def __str__(self): def __str__(self):
return "{self.__class__.__name__}: {self.nick}!{self.ident}@{self.host}#{self.realname}:{self.account}".format(self=self) return "{self.__class__.__name__}: {self.nick}!{self.ident}@{self.host}#{self.realname}:{self.account}".format(self=self)