mirror of https://github.com/Mikaela/Limnoria.git
Changed definition of notFunky to include extended characters that might not be printable in my locale.
This commit is contained in:
parent
73a5de98eb
commit
7fa59b0f35
|
@ -34,6 +34,7 @@ from fix import *
|
|||
import re
|
||||
import string
|
||||
import fnmatch
|
||||
import operator
|
||||
|
||||
import debug
|
||||
import world
|
||||
|
@ -190,7 +191,7 @@ def bold(s):
|
|||
def isValidArgument(s):
|
||||
return '\r' not in s and '\n' not in s and '\x00' not in s
|
||||
|
||||
notFunky = string.printable+'\x02'
|
||||
notFunky = string.ascii[32:]+'\x02'
|
||||
def safeArgument(s):
|
||||
if isValidArgument(s) and s.translate(string.ascii, notFunky) == '':
|
||||
return s
|
||||
|
@ -203,6 +204,21 @@ def replyTo(msg):
|
|||
else:
|
||||
return msg.nick
|
||||
|
||||
def privmsgPayload(L, sep, limit=450):
|
||||
"""Returns a valid privmsg payload given a list of strings and a separator.
|
||||
|
||||
Items are popped from the back of the list until the payload is small
|
||||
enough to fit into a single PRIVMSG payload.
|
||||
"""
|
||||
shrinkList(L, sep, limit)
|
||||
return sep.join(L)
|
||||
|
||||
def shrinkList(L, sep='', limit=450):
|
||||
"""Shrinks a list of strings to a given combined length of limit."""
|
||||
length = len(sep)
|
||||
while reduce(operator.add, map(length.__add__, map(len, L)), 0)> limit:
|
||||
L.pop()
|
||||
|
||||
|
||||
class nick(str):
|
||||
"""This class does case-insensitive comparisons of nicks."""
|
||||
|
|
Loading…
Reference in New Issue