poezio/plugins/csi.py

52 lines
1.4 KiB
Python
Raw Permalink Normal View History

2016-06-05 11:48:04 +00:00
"""
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 poezio.plugin import BasePlugin
2016-06-05 11:48:04 +00:00
2018-08-15 11:13:17 +00:00
2016-06-05 11:48:04 +00:00
class Plugin(BasePlugin):
def init(self):
2018-08-15 11:13:17 +00:00
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')
2016-06-05 11:48:04 +00:00
def command_active(self, args):
if not self.core.xmpp.plugin['xep_0352'].enabled:
2018-08-15 11:13:17 +00:00
self.api.information('CSI is not enabled in this server',
'Warning')
2016-06-05 11:48:04 +00:00
else:
self.core.xmpp.plugin['xep_0352'].send_active()
def command_inactive(self, args):
if not self.core.xmpp.plugin['xep_0352'].enabled:
2018-08-15 11:13:17 +00:00
self.api.information('CSI is not enabled in this server',
'Warning')
2016-06-05 11:48:04 +00:00
else:
self.core.xmpp.plugin['xep_0352'].send_inactive()