refactor all checks for channel_type to server.is_channel()
This commit is contained in:
parent
95a22f53f2
commit
47d38c7d18
5 changed files with 10 additions and 8 deletions
|
@ -53,7 +53,7 @@ class Module(ModuleManager.BaseModule):
|
||||||
else:
|
else:
|
||||||
#we're in a channel
|
#we're in a channel
|
||||||
return channel, "channelset", None
|
return channel, "channelset", None
|
||||||
if context_desc_lower[0] in server.channel_types:
|
elif server.is_channel(context_desc):
|
||||||
return context_desc, "channelset", context_desc
|
return context_desc, "channelset", context_desc
|
||||||
elif server.irc_lower(context_desc) == user.nickname_lower:
|
elif server.irc_lower(context_desc) == user.nickname_lower:
|
||||||
return user, "set", None
|
return user, "set", None
|
||||||
|
|
|
@ -77,7 +77,7 @@ def _own_modes(server, modes):
|
||||||
def mode(events, event):
|
def mode(events, event):
|
||||||
user = event["server"].get_user(event["line"].source.nickname)
|
user = event["server"].get_user(event["line"].source.nickname)
|
||||||
target = event["line"].args[0]
|
target = event["line"].args[0]
|
||||||
is_channel = target[0] in event["server"].channel_types
|
is_channel = event["server"].is_channel(target)
|
||||||
if is_channel:
|
if is_channel:
|
||||||
channel = event["server"].channels.get(target)
|
channel = event["server"].channels.get(target)
|
||||||
modes = event["line"].args[1]
|
modes = event["line"].args[1]
|
||||||
|
|
|
@ -41,10 +41,9 @@ def message(events, event):
|
||||||
# voiced-or-above users
|
# voiced-or-above users
|
||||||
target = target_str.lstrip("".join(event["server"].statusmsg))
|
target = target_str.lstrip("".join(event["server"].statusmsg))
|
||||||
|
|
||||||
is_channel = False
|
is_channel = event["server"].is_channel(target)
|
||||||
|
|
||||||
if target[0] in event["server"].channel_types:
|
if is_channel:
|
||||||
is_channel = True
|
|
||||||
if not target in event["server"].channels:
|
if not target in event["server"].channels:
|
||||||
return
|
return
|
||||||
target_obj = event["server"].channels.get(target)
|
target_obj = event["server"].channels.get(target)
|
||||||
|
|
|
@ -34,8 +34,8 @@ class Channels(object):
|
||||||
return self._server.irc_lower(channel_name)
|
return self._server.irc_lower(channel_name)
|
||||||
|
|
||||||
def contains(self, name: str) -> bool:
|
def contains(self, name: str) -> bool:
|
||||||
lower = self._name_lower(name)
|
return (self._server.is_channel(name) and
|
||||||
return name[0] in self._server.channel_types and lower in self._channels
|
self._name_lower(name) in self._channels)
|
||||||
|
|
||||||
def add(self, name: str) -> IRCChannel.Channel:
|
def add(self, name: str) -> IRCChannel.Channel:
|
||||||
id = self.get_id(name)
|
id = self.get_id(name)
|
||||||
|
|
|
@ -186,10 +186,13 @@ class Server(IRCObject.Object):
|
||||||
for channel in user.channels:
|
for channel in user.channels:
|
||||||
channel.remove_user(user)
|
channel.remove_user(user)
|
||||||
|
|
||||||
|
def is_channel(self, name: str) -> bool:
|
||||||
|
return name[0] in self.channel_types
|
||||||
|
|
||||||
def get_target(self, name: str
|
def get_target(self, name: str
|
||||||
) -> typing.Optional[
|
) -> typing.Optional[
|
||||||
typing.Union[IRCChannel.Channel, IRCUser.User]]:
|
typing.Union[IRCChannel.Channel, IRCUser.User]]:
|
||||||
if name[0] in self.channel_types:
|
if self.is_channel(name):
|
||||||
if name in self.channels:
|
if name in self.channels:
|
||||||
return self.channels.get(name)
|
return self.channels.get(name)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue