XEP-0118: Fix return values and typing

This commit is contained in:
mathieui 2021-02-03 22:24:03 +01:00
parent f6761e513d
commit 64299d6a54
2 changed files with 26 additions and 32 deletions

View File

@ -1,10 +1,7 @@
""" # Slixmpp: The Slick XMPP Library
Slixmpp: The Slick XMPP Library # Copyright (C) 2012 Nathanael C. Fritz, Lance J.T. Stout
Copyright (C) 2012 Nathanael C. Fritz, Lance J.T. Stout # This file is part of Slixmpp.
This file is part of Slixmpp. # See the file LICENSE for copying permission.
See the file LICENSE for copying permission.
"""
from slixmpp.xmlstream import ElementBase, ET from slixmpp.xmlstream import ElementBase, ET

View File

@ -1,13 +1,12 @@
""" # Slixmpp: The Slick XMPP Library
Slixmpp: The Slick XMPP Library # Copyright (C) 2011 Nathanael C. Fritz, Lance J.T. Stout
Copyright (C) 2011 Nathanael C. Fritz, Lance J.T. Stout # This file is part of Slixmpp.
This file is part of Slixmpp. # See the file LICENSE for copying permission.
See the file LICENSE for copying permission.
"""
import logging import logging
from asyncio import Future
from typing import Optional
from slixmpp.plugins.base import BasePlugin from slixmpp.plugins.base import BasePlugin
from slixmpp.plugins.xep_0118 import stanza, UserTune from slixmpp.plugins.xep_0118 import stanza, UserTune
@ -33,9 +32,11 @@ class XEP_0118(BasePlugin):
def session_bind(self, jid): def session_bind(self, jid):
self.xmpp['xep_0163'].register_pep('user_tune', UserTune) self.xmpp['xep_0163'].register_pep('user_tune', UserTune)
def publish_tune(self, artist=None, length=None, rating=None, source=None, def publish_tune(self, *, artist: Optional[str] = None,
title=None, track=None, uri=None, options=None, length: Optional[int] =None, rating: Optional[int] = None,
ifrom=None, callback=None, timeout=None, timeout_callback=None): source: Optional[str] = None, title: Optional[str] = None,
track: Optional[str] = None, uri: Optional[str] = None,
**pubsubkwargs) -> Future:
""" """
Publish the user's current tune. Publish the user's current tune.
@ -46,7 +47,6 @@ class XEP_0118(BasePlugin):
:param title: The title of the song. :param title: The title of the song.
:param track: The song's track number, or other unique identifier. :param track: The song's track number, or other unique identifier.
:param uri: A URL to more information about the song. :param uri: A URL to more information about the song.
:param options: Optional form of publish options.
""" """
tune = UserTune() tune = UserTune()
tune['artist'] = artist tune['artist'] = artist
@ -56,22 +56,19 @@ class XEP_0118(BasePlugin):
tune['title'] = title tune['title'] = title
tune['track'] = track tune['track'] = track
tune['uri'] = uri tune['uri'] = uri
return self.xmpp['xep_0163'].publish(tune, return self.xmpp['xep_0163'].publish(
node=UserTune.namespace, tune,
options=options, node=UserTune.namespace,
ifrom=ifrom, **pubsubkwargs
callback=callback, )
timeout=timeout,
timeout_callback=timeout_callback)
def stop(self, ifrom=None, callback=None, timeout=None, timeout_callback=None): def stop(self, **pubsubkwargs) -> Future:
""" """
Clear existing user tune information to stop notifications. Clear existing user tune information to stop notifications.
""" """
tune = UserTune() tune = UserTune()
return self.xmpp['xep_0163'].publish(tune, return self.xmpp['xep_0163'].publish(
node=UserTune.namespace, tune,
ifrom=ifrom, node=UserTune.namespace,
callback=callback, **pubsubkwargs
timeout=timeout, )
timeout_callback=timeout_callback)