diff options
author | mathieui <mathieui@mathieui.net> | 2021-02-03 22:23:44 +0100 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2021-02-03 22:23:44 +0100 |
commit | f6761e513d820e658cd4fda9fa054f2e1787d4b8 (patch) | |
tree | 927461a4db157336c49d3c4485f647c28558c9b5 | |
parent | f2878e1764134ee525cc345e2f678afcffceb998 (diff) | |
download | slixmpp-f6761e513d820e658cd4fda9fa054f2e1787d4b8.tar.gz slixmpp-f6761e513d820e658cd4fda9fa054f2e1787d4b8.tar.bz2 slixmpp-f6761e513d820e658cd4fda9fa054f2e1787d4b8.tar.xz slixmpp-f6761e513d820e658cd4fda9fa054f2e1787d4b8.zip |
XEP-0108: Fix return values and typing
-rw-r--r-- | slixmpp/plugins/xep_0108/stanza.py | 11 | ||||
-rw-r--r-- | slixmpp/plugins/xep_0108/user_activity.py | 41 |
2 files changed, 23 insertions, 29 deletions
diff --git a/slixmpp/plugins/xep_0108/stanza.py b/slixmpp/plugins/xep_0108/stanza.py index c9a3c362..4664f3c1 100644 --- a/slixmpp/plugins/xep_0108/stanza.py +++ b/slixmpp/plugins/xep_0108/stanza.py @@ -1,10 +1,7 @@ -""" - Slixmpp: The Slick XMPP Library - Copyright (C) 2012 Nathanael C. Fritz, Lance J.T. Stout - This file is part of Slixmpp. - - See the file LICENSE for copying permission. -""" +# Slixmpp: The Slick XMPP Library +# Copyright (C) 2012 Nathanael C. Fritz, Lance J.T. Stout +# This file is part of Slixmpp. +# See the file LICENSE for copying permission. from slixmpp.xmlstream import ElementBase, ET diff --git a/slixmpp/plugins/xep_0108/user_activity.py b/slixmpp/plugins/xep_0108/user_activity.py index 089269bd..4004ab8e 100644 --- a/slixmpp/plugins/xep_0108/user_activity.py +++ b/slixmpp/plugins/xep_0108/user_activity.py @@ -1,13 +1,12 @@ -""" - Slixmpp: The Slick XMPP Library - Copyright (C) 2011 Nathanael C. Fritz, Lance J.T. Stout - This file is part of Slixmpp. - - See the file LICENSE for copying permission. -""" +# Slixmpp: The Slick XMPP Library +# Copyright (C) 2011 Nathanael C. Fritz, Lance J.T. Stout +# This file is part of Slixmpp. +# See the file LICENSE for copying permission. import logging +from asyncio import Future +from typing import Optional from slixmpp.plugins.base import BasePlugin from slixmpp.plugins.xep_0108 import stanza, UserActivity @@ -33,9 +32,8 @@ class XEP_0108(BasePlugin): def session_bind(self, jid): self.xmpp['xep_0163'].register_pep('user_activity', UserActivity) - def publish_activity(self, general, specific=None, text=None, - options=None, ifrom=None, callback=None, - timeout=None, timeout_callback=None): + def publish_activity(self, general: str, specific: Optional[str] = None, + text: Optional[str] = None, **pubsubkwargs) -> Future: """ Publish the user's current activity. @@ -44,24 +42,23 @@ class XEP_0108(BasePlugin): of the general category. :param text: Optional natural-language description or reason for the activity. - :param options: Optional form of publish options. """ activity = UserActivity() activity['value'] = (general, specific) activity['text'] = text - self.xmpp['xep_0163'].publish(activity, node=UserActivity.namespace, - options=options, ifrom=ifrom, - callback=callback, - timeout=timeout, - timeout_callback=timeout_callback) + return self.xmpp['xep_0163'].publish( + activity, + node=UserActivity.namespace, + **pubsubkwargs + ) - def stop(self, ifrom=None, callback=None, timeout=None, - timeout_callback=None): + def stop(self, **pubsubkwargs) -> Future: """ Clear existing user activity information to stop notifications. """ activity = UserActivity() - self.xmpp['xep_0163'].publish(activity, node=UserActivity.namespace, - ifrom=ifrom, callback=callback, - timeout=timeout, - timeout_callback=timeout_callback) + return self.xmpp['xep_0163'].publish( + activity, + node=UserActivity.namespace, + **pubsubkwargs + ) |