XEP-0172: Fix return values and typing
This commit is contained in:
parent
64299d6a54
commit
e6e57f6e8c
2 changed files with 21 additions and 33 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue