summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2021-02-03 22:24:24 +0100
committermathieui <mathieui@mathieui.net>2021-02-03 22:24:24 +0100
commite6e57f6e8c729aaf1097491b48b7f0cd86ba3036 (patch)
treef9d5af44b91f4ae356a97fe3e828847a89c65a09
parent64299d6a5453c5c982a3daec74c41803458bdc75 (diff)
downloadslixmpp-e6e57f6e8c729aaf1097491b48b7f0cd86ba3036.tar.gz
slixmpp-e6e57f6e8c729aaf1097491b48b7f0cd86ba3036.tar.bz2
slixmpp-e6e57f6e8c729aaf1097491b48b7f0cd86ba3036.tar.xz
slixmpp-e6e57f6e8c729aaf1097491b48b7f0cd86ba3036.zip
XEP-0172: Fix return values and typing
-rw-r--r--slixmpp/plugins/xep_0172/stanza.py11
-rw-r--r--slixmpp/plugins/xep_0172/user_nick.py43
2 files changed, 21 insertions, 33 deletions
diff --git a/slixmpp/plugins/xep_0172/stanza.py b/slixmpp/plugins/xep_0172/stanza.py
index addba94a..dbc136d9 100644
--- a/slixmpp/plugins/xep_0172/stanza.py
+++ b/slixmpp/plugins/xep_0172/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_0172/user_nick.py b/slixmpp/plugins/xep_0172/user_nick.py
index ef96c51a..4f94c724 100644
--- a/slixmpp/plugins/xep_0172/user_nick.py
+++ b/slixmpp/plugins/xep_0172/user_nick.py
@@ -1,13 +1,11 @@
-"""
- 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, Callable
from slixmpp import JID
from slixmpp.stanza.message import Message
@@ -45,34 +43,27 @@ class XEP_0172(BasePlugin):
def session_bind(self, jid):
self.xmpp['xep_0163'].register_pep('user_nick', UserNick)
- def publish_nick(self, nick: Optional[str] = None,
- options: Optional[Form] = None,
- ifrom: Optional[JID] = None,
- timeout_callback: Optional[Callable] = None,
- callback: Optional[Callable] = None,
- timeout: Optional[int] = None):
+ def publish_nick(self, nick: Optional[str] = None, **pubsubkwargs) -> Future:
"""
Publish the user's current nick.
:param nick: The user nickname to publish.
- :param options: Optional form of publish options.
"""
nickname = UserNick()
nickname['nick'] = nick
- self.xmpp['xep_0163'].publish(nickname, node=UserNick.namespace,
- options=options, ifrom=ifrom,
- callback=callback, timeout=timeout,
- timeout_callback=timeout_callback)
+ return self.xmpp['xep_0163'].publish(
+ nickname,
+ node=UserNick.namespace,
+ **pubsubkwargs
+ )
- def stop(self, ifrom: Optional[JID] = None,
- timeout_callback: Optional[Callable] = None,
- callback: Optional[Callable] = None,
- timeout: Optional[int] = None):
+ def stop(self, **pubsubkwargs) -> Future:
"""
Clear existing user nick information to stop notifications.
"""
nick = UserNick()
- return self.xmpp['xep_0163'].publish(nick, node=UserNick.namespace,
- ifrom=ifrom, callback=callback,
- timeout=timeout,
- timeout_callback=timeout_callback)
+ return self.xmpp['xep_0163'].publish(
+ nick,
+ node=UserNick.namespace,
+ **pubsubkwargs
+ )