mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-01 09:19:23 +01:00
Declare IRCd casemapping in protocol modules, and respect these in utils.nickToUid
This adds a new utils.toLower(irc, text) function which returns the lowercased version of <text> based on <irc>'s declared case mapping. Closes #75.
This commit is contained in:
parent
8c1e1c18f1
commit
35cdfbf7e6
@ -10,6 +10,8 @@ from log import log
|
|||||||
|
|
||||||
from classes import *
|
from classes import *
|
||||||
|
|
||||||
|
casemapping = 'ascii'
|
||||||
|
|
||||||
# Raw commands sent from servers vary from protocol to protocol. Here, we map
|
# Raw commands sent from servers vary from protocol to protocol. Here, we map
|
||||||
# non-standard names to our hook handlers, so plugins get the information they need.
|
# non-standard names to our hook handlers, so plugins get the information they need.
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ from inspircd import handle_privmsg, handle_kill, handle_kick, handle_error, \
|
|||||||
handle_quit, handle_nick, handle_save, handle_squit, handle_mode, handle_topic, \
|
handle_quit, handle_nick, handle_save, handle_squit, handle_mode, handle_topic, \
|
||||||
handle_notice
|
handle_notice
|
||||||
|
|
||||||
|
casemapping = 'rfc1459'
|
||||||
hook_map = {'SJOIN': 'JOIN', 'TB': 'TOPIC', 'TMODE': 'MODE', 'BMASK': 'MODE'}
|
hook_map = {'SJOIN': 'JOIN', 'TB': 'TOPIC', 'TMODE': 'MODE', 'BMASK': 'MODE'}
|
||||||
|
|
||||||
def _send(irc, sid, msg):
|
def _send(irc, sid, msg):
|
||||||
|
11
utils.py
11
utils.py
@ -122,9 +122,18 @@ def add_hook(func, command):
|
|||||||
command = command.upper()
|
command = command.upper()
|
||||||
command_hooks[command].append(func)
|
command_hooks[command].append(func)
|
||||||
|
|
||||||
|
def toLower(irc, text):
|
||||||
|
if irc.proto.casemapping == 'rfc1459':
|
||||||
|
text = text.replace('{', '[')
|
||||||
|
text = text.replace('}', ']')
|
||||||
|
text = text.replace('|', '\\')
|
||||||
|
text = text.replace('~', '^')
|
||||||
|
return text.lower()
|
||||||
|
|
||||||
def nickToUid(irc, nick):
|
def nickToUid(irc, nick):
|
||||||
|
nick = toLower(irc, nick)
|
||||||
for k, v in irc.users.items():
|
for k, v in irc.users.items():
|
||||||
if v.nick == nick:
|
if toLower(irc, v.nick) == nick:
|
||||||
return k
|
return k
|
||||||
|
|
||||||
def clientToServer(irc, numeric):
|
def clientToServer(irc, numeric):
|
||||||
|
Loading…
Reference in New Issue
Block a user