Skip to content

Commit 63e9c98

Browse files
committed
Make sure channel names are always lower-case. is_op_in() client method.
1 parent 2eaf09e commit 63e9c98

3 files changed

Lines changed: 13 additions & 4 deletions

File tree

fredirc/client.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,15 @@ def pong(self):
206206
""" Send a pong message to the server. """
207207
self._send_message(messages.pong(self._state.server))
208208

209+
def is_op_in(self, channel):
210+
"""
211+
Check if this client has operator rights in the given channel.
212+
213+
Args:
214+
channel (str): the channel (case-insensitive)
215+
"""
216+
return channel.lower() in self._state.operatorIn;
217+
209218
# --- Private methods ---
210219

211220
def _send_message(self, message):
@@ -380,8 +389,7 @@ def __init__(self):
380389
# Note: Nicks in server messages always have the case in which they
381390
# were registered.
382391
self.nick = None
383-
# Note: Channel names seem to be always lower case in messages from
384-
# the server.
392+
# Note: Channel names will always be saved lower case
385393
self.channels = []
386394
# Channels, where the client is channel operator in:
387395
self.operatorIn = []

fredirc/parsing.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ def parse_message_target(msg_target):
102102
if msgto.startswith('#') or \
103103
msgto.startswith('+') or \
104104
msgto.startswith('&'):
105-
mt = MessageTarget(channel=msgto)
105+
# We want channel names to always be lower-case in fredirc!
106+
mt = MessageTarget(channel=msgto.lower())
106107
elif '@' in msgto:
107108
user_split = msgto.split('@', 1)
108109
if '!' in user_split[0]:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
dependencies = []
2121

2222
def read(file):
23-
""" Utility function to the the README file. """
23+
""" Utility function to read the README-file. """
2424
return open(os.path.join(os.path.dirname(__file__), file)).read()
2525

2626
setup(

0 commit comments

Comments
 (0)