Add IRCServer.Server.get_target, to get an IRCChannel if the given target is a
channel name or an IRCUser
This commit is contained in:
parent
b8518d745f
commit
2852afd5f7
1 changed files with 9 additions and 0 deletions
|
@ -194,6 +194,15 @@ class Server(IRCObject.Object):
|
|||
for channel in user.channels:
|
||||
channel.remove_user(user)
|
||||
|
||||
def get_target(self, name: str
|
||||
) -> typing.Union[IRCChannel.Channel, IRCUser.User]:
|
||||
if name[0] in self.channel_types:
|
||||
if name in self.channels:
|
||||
return self.channels.get(name)
|
||||
else:
|
||||
return self.get_user(name)
|
||||
return None
|
||||
|
||||
def change_user_nickname(self, old_nickname: str, new_nickname: str):
|
||||
user = self.users.pop(utils.irc.lower(self.case_mapping, old_nickname))
|
||||
user._id = self.get_user_id(new_nickname)
|
||||
|
|
Loading…
Reference in a new issue