mirror of
https://github.com/jlu5/PyLink.git
synced 2024-12-25 12:12:53 +01:00
parent
b3387f2d41
commit
03766b9f89
23
utils.py
23
utils.py
@ -16,6 +16,8 @@ from . import world, conf
|
|||||||
# This is just so protocols and plugins are importable.
|
# This is just so protocols and plugins are importable.
|
||||||
from pylinkirc import protocols, plugins
|
from pylinkirc import protocols, plugins
|
||||||
|
|
||||||
|
NORMALIZEWHITESPACE_RE = re.compile(r'\s+')
|
||||||
|
|
||||||
class NotAuthorizedError(Exception):
|
class NotAuthorizedError(Exception):
|
||||||
"""
|
"""
|
||||||
Exception raised by checkAuthenticated() when a user fails authentication
|
Exception raised by checkAuthenticated() when a user fails authentication
|
||||||
@ -362,14 +364,21 @@ class ServiceBot():
|
|||||||
lines = doc.splitlines()
|
lines = doc.splitlines()
|
||||||
# Bold the first line, which usually just tells you what
|
# Bold the first line, which usually just tells you what
|
||||||
# arguments the command takes.
|
# arguments the command takes.
|
||||||
lines[0] = '\x02%s %s\x02' % (command, lines[0])
|
args_desc = '\x02%s %s\x02' % (command, lines[0])
|
||||||
|
|
||||||
if shortform: # Short form is just the command name + args.
|
_reply(args_desc.strip())
|
||||||
_reply(lines[0].strip())
|
if not shortform:
|
||||||
else:
|
# Note: we handle newlines in docstrings a bit differently. Per
|
||||||
for line in lines:
|
# https://github.com/GLolol/PyLink/issues/307, only double newlines
|
||||||
# Otherwise, just output the rest of the docstring to IRC.
|
# have the effect of showing a new line on IRC. Single newlines
|
||||||
_reply(line.strip())
|
# are stripped so that word wrap can be applied in the source code
|
||||||
|
# without actually affecting the output on IRC.
|
||||||
|
for line in doc.replace('\r', '').split('\n\n')[1:]:
|
||||||
|
_reply(' ') # Empty line to break up output a bit.
|
||||||
|
real_line = line.replace('\n', ' ')
|
||||||
|
real_line = real_line.strip()
|
||||||
|
real_line = NORMALIZEWHITESPACE_RE.sub(' ', real_line)
|
||||||
|
_reply(real_line)
|
||||||
else:
|
else:
|
||||||
_reply("Error: Command %r doesn't offer any help." % command)
|
_reply("Error: Command %r doesn't offer any help." % command)
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user