diff options
Diffstat (limited to 'Scripts/osc_ctrl.py')
| -rw-r--r-- | Scripts/osc_ctrl.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Scripts/osc_ctrl.py b/Scripts/osc_ctrl.py index 7c7d0ae..e57a843 100644 --- a/Scripts/osc_ctrl.py +++ b/Scripts/osc_ctrl.py @@ -30,6 +30,7 @@ class OscState: self.client = getClient(ip, port) self.pager = MultiLinePager(chars_per_sync, rows, cols) self.encoding= generateEncoding() + self.builtin_msg = "" # The last message sent to the built-in chatbox def reset(self): self.pager.reset() @@ -137,6 +138,23 @@ def pageMessage(osc_state: OscState, msg: str) -> bool: addr="/avatar/parameters/" + generate_utils.getSpeechNoiseToggleParam() osc_state.client.send_message(addr, False) +# Like `pageMessage` but uses the built-in chatbox. The built-in chatbox +# truncates data at about 150 chars, so just send the suffix of the message for +# now. +def pageMessageBuiltin(osc_state: OscState, msg: str) -> bool: + msg_begin = max(len(msg) - 140, 0) + msg_suffix = msg[msg_begin:len(msg)] + + if osc_state.builtin_msg != msg: + addr="/chatbox/typing" + osc_state.client.send_message(addr, False) + + addr="/chatbox/input" + osc_state.client.send_message(addr, (msg_suffix, True)) + osc_state.builtin_msg = msg + + return False # Not paging + if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("-i", default="127.0.0.1", help="OSC server IP") |
