Allow commands to append to out/err prefix
This commit is contained in:
parent
230541e11c
commit
d30f01670e
1 changed files with 11 additions and 7 deletions
|
@ -8,7 +8,7 @@ STR_CONTINUED = "(...continued) "
|
||||||
class Out(object):
|
class Out(object):
|
||||||
def __init__(self, server, module_name, target, target_str, tags):
|
def __init__(self, server, module_name, target, target_str, tags):
|
||||||
self.server = server
|
self.server = server
|
||||||
self.module_name = module_name
|
self._prefix = self._default_prefix(module_name)
|
||||||
self._hide_prefix = False
|
self._hide_prefix = False
|
||||||
self.target = target
|
self.target = target
|
||||||
self._target_str = target_str
|
self._target_str = target_str
|
||||||
|
@ -29,7 +29,7 @@ class Out(object):
|
||||||
if self.has_text():
|
if self.has_text():
|
||||||
prefix = ""
|
prefix = ""
|
||||||
if not self._hide_prefix:
|
if not self._hide_prefix:
|
||||||
prefix = utils.consts.RESET + "[%s] " % self.prefix()
|
prefix = utils.consts.RESET + "[%s] " % self._prefix
|
||||||
|
|
||||||
full_text = "%s%s" % (prefix, self._text)
|
full_text = "%s%s" % (prefix, self._text)
|
||||||
line_factory = None
|
line_factory = None
|
||||||
|
@ -55,8 +55,12 @@ class Out(object):
|
||||||
|
|
||||||
sent_line = self.server.send(line)
|
sent_line = self.server.send(line)
|
||||||
|
|
||||||
|
def _default_prefix(self, s: str):
|
||||||
|
return s
|
||||||
def set_prefix(self, prefix):
|
def set_prefix(self, prefix):
|
||||||
self.module_name = prefix
|
self._prefix = self._default_prefix(prefix)
|
||||||
|
def append_prefix(self, s: str):
|
||||||
|
self._prefix = "%s%s" % (self._prefix, s)
|
||||||
def hide_prefix(self):
|
def hide_prefix(self):
|
||||||
self._hide_prefix = True
|
self._hide_prefix = True
|
||||||
|
|
||||||
|
@ -64,9 +68,9 @@ class Out(object):
|
||||||
return bool(self._text)
|
return bool(self._text)
|
||||||
|
|
||||||
class StdOut(Out):
|
class StdOut(Out):
|
||||||
def prefix(self):
|
def _default_prefix(self, s: str):
|
||||||
return utils.irc.color(self.module_name, utils.consts.GREEN)
|
return utils.irc.color(s, utils.consts.GREEN)
|
||||||
class StdErr(Out):
|
class StdErr(Out):
|
||||||
def prefix(self):
|
def _default_prefix(self, s: str):
|
||||||
return utils.irc.color(self.module_name, utils.consts.RED)
|
return utils.irc.color(s, utils.consts.RED)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue