From 0a2238def5c01f56ce5fb9b451071ab9f8121c88 Mon Sep 17 00:00:00 2001 From: mathieui Date: Sun, 5 Jun 2016 13:48:04 +0200 Subject: Add a manual CSI plugin --- doc/source/plugins/csi.rst | 6 ++++++ doc/source/plugins/index.rst | 6 ++++++ plugins/csi.py | 45 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 doc/source/plugins/csi.rst create mode 100644 plugins/csi.py diff --git a/doc/source/plugins/csi.rst b/doc/source/plugins/csi.rst new file mode 100644 index 00000000..f6594fe7 --- /dev/null +++ b/doc/source/plugins/csi.rst @@ -0,0 +1,6 @@ +.. _csi-plugin: + +CSI +=== + +.. automodule:: csi diff --git a/doc/source/plugins/index.rst b/doc/source/plugins/index.rst index b5969fd9..faad1e4d 100644 --- a/doc/source/plugins/index.rst +++ b/doc/source/plugins/index.rst @@ -87,6 +87,11 @@ Plugin index Close all tabs except MUCs and the roster. + CSI + :ref:`Documentation ` + + Set the client state indication manually. + Cyber :ref:`Documentation ` @@ -303,3 +308,4 @@ Plugin index close_all reorder cyber + csi diff --git a/plugins/csi.py b/plugins/csi.py new file mode 100644 index 00000000..5fe41666 --- /dev/null +++ b/plugins/csi.py @@ -0,0 +1,45 @@ +""" +This plugin lets you set the CSI_ state manually, when the autoaway plugin +is not sufficient for your usage. + +Commands +-------- + +.. glossary:: + + /csi_active + **Usage:** ``/csi_active`` + + Set CSI state to ``active``. + + /csi_inactive + **Usage:** ``/csi_inactive`` + + Set CSI state to ``inactive``. + +.. _CSI: https://xmpp.org/extensions/xep-0352.html +""" + +from plugin import BasePlugin +import tabs + +class Plugin(BasePlugin): + def init(self): + self.api.add_command('csi_active', self.command_active, + help='Set the client state indication to “active”', + short='Manual set active') + self.api.add_command('csi_inactive', self.command_inactive, + help='Set the client state indication to “inactive”', + short='Manual set inactive') + + def command_active(self, args): + if not self.core.xmpp.plugin['xep_0352'].enabled: + self.api.information('CSI is not enabled in this server', 'Warning') + else: + self.core.xmpp.plugin['xep_0352'].send_active() + + def command_inactive(self, args): + if not self.core.xmpp.plugin['xep_0352'].enabled: + self.api.information('CSI is not enabled in this server', 'Warning') + else: + self.core.xmpp.plugin['xep_0352'].send_inactive() -- cgit v1.2.3