Bots use inputfunc

This commit is contained in:
Tablet-PC\cloud 2017-01-18 12:26:42 +11:00
parent 55d956a799
commit e62418fd11
4 changed files with 40 additions and 29 deletions

View file

@ -80,6 +80,41 @@ def text(session, *args, **kwargs):
session.update_session_counters()
def bot_data_in(session, *args, **kwargs):
"""
Text input from the IRC and RSS bots.
This will trigger the execute_cmd method on the bots in-game counterpart.
Args:
text (str): First arg is text input. Other arguments are ignored.
"""
text = args[0] if args else None
# Explicitly check for None since text can be an empty string, which is
# also valid
if text is None:
return
# this is treated as a command input
# handle the 'idle' command
if text.strip() in _IDLE_COMMAND:
session.update_session_counters(idle=True)
return
if session.player:
# nick replacement
puppet = session.puppet
if puppet:
text = puppet.nicks.nickreplace(text,
categories=("inputline", "channel"), include_player=True)
else:
text = session.player.nicks.nickreplace(text,
categories=("inputline", "channel"), include_player=False)
kwargs.pop("options", None)
session.player.execute_cmd(text=text, session=session)
session.update_session_counters()
def echo(session, *args, **kwargs):
"""
Echo test function