add "lstring" command spec; "last string" - explicit args or last message
This commit is contained in:
parent
c1543ed899
commit
616eb84264
2 changed files with 13 additions and 7 deletions
|
@ -10,19 +10,14 @@ REGEX_LANGUAGES = re.compile("(\w+)?:(\w+)? ")
|
|||
class Module(ModuleManager.BaseModule):
|
||||
@utils.hook("received.command.tr", alias_of="translate")
|
||||
@utils.hook("received.command.translate")
|
||||
@utils.spec("!<phrase>lstring")
|
||||
def translate(self, event):
|
||||
"""
|
||||
:help: Translate the provided phrase or the last line in thie current
|
||||
channel
|
||||
:usage: [phrase]
|
||||
"""
|
||||
phrase = event["args"]
|
||||
if not phrase:
|
||||
phrase = event["target"].buffer.get()
|
||||
if phrase:
|
||||
phrase = utils.irc.strip_font(phrase.message)
|
||||
if not phrase:
|
||||
raise utils.EventError("No phrase provided.")
|
||||
phrase = event["spec"][0]
|
||||
source_language = "auto"
|
||||
target_language = "en"
|
||||
|
||||
|
|
|
@ -88,6 +88,17 @@ class Module(ModuleManager.BaseModule):
|
|||
if args:
|
||||
value = server.get_user(args[0], create=True)
|
||||
n = 1
|
||||
elif argument_type.type == "lstring":
|
||||
if args:
|
||||
value = " ".join(args)
|
||||
n = len(args)
|
||||
else:
|
||||
last_message = (channel or user).buffer.get()
|
||||
if last_message:
|
||||
value = last_message.message
|
||||
n = 0
|
||||
else:
|
||||
n = 1
|
||||
elif argument_type.type == "channelonly":
|
||||
if channel:
|
||||
value = True
|
||||
|
|
Loading…
Reference in a new issue