Merge branch 'pep-xeps-fix-returns' into 'master'
Fix return values and improve typing in "user *" PEP XEPs See merge request poezio/slixmpp!115
This commit is contained in:
commit
d8dbfaa37e
@ -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
|
||||||
|
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
"""
|
# 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 import Message
|
from slixmpp import Message
|
||||||
from slixmpp.xmlstream import register_stanza_plugin
|
from slixmpp.xmlstream import register_stanza_plugin
|
||||||
from slixmpp.xmlstream.handler import Callback
|
from slixmpp.xmlstream.handler import Callback
|
||||||
@ -20,7 +22,6 @@ log = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
class XEP_0107(BasePlugin):
|
class XEP_0107(BasePlugin):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
XEP-0107: User Mood
|
XEP-0107: User Mood
|
||||||
"""
|
"""
|
||||||
@ -40,31 +41,30 @@ class XEP_0107(BasePlugin):
|
|||||||
def session_bind(self, jid):
|
def session_bind(self, jid):
|
||||||
self.xmpp['xep_0163'].register_pep('user_mood', UserMood)
|
self.xmpp['xep_0163'].register_pep('user_mood', UserMood)
|
||||||
|
|
||||||
def publish_mood(self, value=None, text=None, options=None, ifrom=None,
|
def publish_mood(self, value: Optional[str] = None, text: Optional[str] = None, **pubsubkwargs) -> Future:
|
||||||
callback=None, timeout=None, timeout_callback=None):
|
|
||||||
"""
|
"""
|
||||||
Publish the user's current mood.
|
Publish the user's current mood.
|
||||||
|
|
||||||
:param value: The name of the mood to publish.
|
:param value: The name of the mood to publish.
|
||||||
:param text: Optional natural-language description or reason
|
:param text: Optional natural-language description or reason
|
||||||
for the mood.
|
for the mood.
|
||||||
:param options: Optional form of publish options.
|
|
||||||
"""
|
"""
|
||||||
mood = UserMood()
|
mood = UserMood()
|
||||||
mood['value'] = value
|
mood['value'] = value
|
||||||
mood['text'] = text
|
mood['text'] = text
|
||||||
self.xmpp['xep_0163'].publish(mood, node=UserMood.namespace,
|
return self.xmpp['xep_0163'].publish(
|
||||||
options=options, ifrom=ifrom,
|
mood,
|
||||||
callback=callback, timeout=timeout,
|
node=UserMood.namespace,
|
||||||
timeout_callback=timeout_callback)
|
**pubsubkwargs
|
||||||
|
)
|
||||||
|
|
||||||
def stop(self, ifrom=None, callback=None, timeout=None,
|
def stop(self, **pubsubkwargs) -> Future:
|
||||||
timeout_callback=None):
|
|
||||||
"""
|
"""
|
||||||
Clear existing user mood information to stop notifications.
|
Clear existing user mood information to stop notifications.
|
||||||
"""
|
"""
|
||||||
mood = UserMood()
|
mood = UserMood()
|
||||||
self.xmpp['xep_0163'].publish(mood, node=UserMood.namespace,
|
return self.xmpp['xep_0163'].publish(
|
||||||
ifrom=ifrom, callback=callback,
|
mood,
|
||||||
timeout=timeout,
|
node=UserMood.namespace,
|
||||||
timeout_callback=timeout_callback)
|
**pubsubkwargs
|
||||||
|
)
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
@ -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_0108 import stanza, UserActivity
|
from slixmpp.plugins.xep_0108 import stanza, UserActivity
|
||||||
|
|
||||||
@ -33,9 +32,8 @@ class XEP_0108(BasePlugin):
|
|||||||
def session_bind(self, jid):
|
def session_bind(self, jid):
|
||||||
self.xmpp['xep_0163'].register_pep('user_activity', UserActivity)
|
self.xmpp['xep_0163'].register_pep('user_activity', UserActivity)
|
||||||
|
|
||||||
def publish_activity(self, general, specific=None, text=None,
|
def publish_activity(self, general: str, specific: Optional[str] = None,
|
||||||
options=None, ifrom=None, callback=None,
|
text: Optional[str] = None, **pubsubkwargs) -> Future:
|
||||||
timeout=None, timeout_callback=None):
|
|
||||||
"""
|
"""
|
||||||
Publish the user's current activity.
|
Publish the user's current activity.
|
||||||
|
|
||||||
@ -44,24 +42,23 @@ class XEP_0108(BasePlugin):
|
|||||||
of the general category.
|
of the general category.
|
||||||
:param text: Optional natural-language description or reason
|
:param text: Optional natural-language description or reason
|
||||||
for the activity.
|
for the activity.
|
||||||
:param options: Optional form of publish options.
|
|
||||||
"""
|
"""
|
||||||
activity = UserActivity()
|
activity = UserActivity()
|
||||||
activity['value'] = (general, specific)
|
activity['value'] = (general, specific)
|
||||||
activity['text'] = text
|
activity['text'] = text
|
||||||
self.xmpp['xep_0163'].publish(activity, node=UserActivity.namespace,
|
return self.xmpp['xep_0163'].publish(
|
||||||
options=options, ifrom=ifrom,
|
activity,
|
||||||
callback=callback,
|
node=UserActivity.namespace,
|
||||||
timeout=timeout,
|
**pubsubkwargs
|
||||||
timeout_callback=timeout_callback)
|
)
|
||||||
|
|
||||||
def stop(self, ifrom=None, callback=None, timeout=None,
|
def stop(self, **pubsubkwargs) -> Future:
|
||||||
timeout_callback=None):
|
|
||||||
"""
|
"""
|
||||||
Clear existing user activity information to stop notifications.
|
Clear existing user activity information to stop notifications.
|
||||||
"""
|
"""
|
||||||
activity = UserActivity()
|
activity = UserActivity()
|
||||||
self.xmpp['xep_0163'].publish(activity, node=UserActivity.namespace,
|
return self.xmpp['xep_0163'].publish(
|
||||||
ifrom=ifrom, callback=callback,
|
activity,
|
||||||
timeout=timeout,
|
node=UserActivity.namespace,
|
||||||
timeout_callback=timeout_callback)
|
**pubsubkwargs
|
||||||
|
)
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
@ -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)
|
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
"""
|
# 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, Callable
|
from typing import Optional, Callable
|
||||||
from slixmpp import JID
|
from slixmpp import JID
|
||||||
from slixmpp.stanza.message import Message
|
from slixmpp.stanza.message import Message
|
||||||
@ -45,34 +43,27 @@ class XEP_0172(BasePlugin):
|
|||||||
def session_bind(self, jid):
|
def session_bind(self, jid):
|
||||||
self.xmpp['xep_0163'].register_pep('user_nick', UserNick)
|
self.xmpp['xep_0163'].register_pep('user_nick', UserNick)
|
||||||
|
|
||||||
def publish_nick(self, nick: Optional[str] = None,
|
def publish_nick(self, nick: Optional[str] = None, **pubsubkwargs) -> Future:
|
||||||
options: Optional[Form] = None,
|
|
||||||
ifrom: Optional[JID] = None,
|
|
||||||
timeout_callback: Optional[Callable] = None,
|
|
||||||
callback: Optional[Callable] = None,
|
|
||||||
timeout: Optional[int] = None):
|
|
||||||
"""
|
"""
|
||||||
Publish the user's current nick.
|
Publish the user's current nick.
|
||||||
|
|
||||||
:param nick: The user nickname to publish.
|
:param nick: The user nickname to publish.
|
||||||
:param options: Optional form of publish options.
|
|
||||||
"""
|
"""
|
||||||
nickname = UserNick()
|
nickname = UserNick()
|
||||||
nickname['nick'] = nick
|
nickname['nick'] = nick
|
||||||
self.xmpp['xep_0163'].publish(nickname, node=UserNick.namespace,
|
return self.xmpp['xep_0163'].publish(
|
||||||
options=options, ifrom=ifrom,
|
nickname,
|
||||||
callback=callback, timeout=timeout,
|
node=UserNick.namespace,
|
||||||
timeout_callback=timeout_callback)
|
**pubsubkwargs
|
||||||
|
)
|
||||||
|
|
||||||
def stop(self, ifrom: Optional[JID] = None,
|
def stop(self, **pubsubkwargs) -> Future:
|
||||||
timeout_callback: Optional[Callable] = None,
|
|
||||||
callback: Optional[Callable] = None,
|
|
||||||
timeout: Optional[int] = None):
|
|
||||||
"""
|
"""
|
||||||
Clear existing user nick information to stop notifications.
|
Clear existing user nick information to stop notifications.
|
||||||
"""
|
"""
|
||||||
nick = UserNick()
|
nick = UserNick()
|
||||||
return self.xmpp['xep_0163'].publish(nick, node=UserNick.namespace,
|
return self.xmpp['xep_0163'].publish(
|
||||||
ifrom=ifrom, callback=callback,
|
nick,
|
||||||
timeout=timeout,
|
node=UserNick.namespace,
|
||||||
timeout_callback=timeout_callback)
|
**pubsubkwargs
|
||||||
|
)
|
||||||
|
@ -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.plugins.base import register_plugin
|
from slixmpp.plugins.base import register_plugin
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
"""
|
# 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 slixmpp import JID
|
from slixmpp import JID
|
||||||
from typing import Optional, Callable
|
from typing import Optional, Callable
|
||||||
from slixmpp.plugins.base import BasePlugin
|
from slixmpp.plugins.base import BasePlugin
|
||||||
@ -43,11 +41,7 @@ class XEP_0196(BasePlugin):
|
|||||||
character_name: Optional[str] = None,
|
character_name: Optional[str] = None,
|
||||||
character_profile: Optional[str] = None,
|
character_profile: Optional[str] = None,
|
||||||
server_address: Optional[str] = None,
|
server_address: Optional[str] = None,
|
||||||
options: Optional[Form] = None,
|
**pubsubkwargs) -> Future:
|
||||||
ifrom: Optional[JID] = None,
|
|
||||||
callback: Optional[Callable] = None,
|
|
||||||
timeout: Optional[int] = None,
|
|
||||||
timeout_callback: Optional[Callable]=None):
|
|
||||||
"""
|
"""
|
||||||
Publish the user's current gaming status.
|
Publish the user's current gaming status.
|
||||||
|
|
||||||
@ -69,20 +63,19 @@ class XEP_0196(BasePlugin):
|
|||||||
gaming['character_profile'] = character_profile
|
gaming['character_profile'] = character_profile
|
||||||
gaming['server_name'] = server_name
|
gaming['server_name'] = server_name
|
||||||
gaming['server_address'] = server_address
|
gaming['server_address'] = server_address
|
||||||
return self.xmpp['xep_0163'].publish(gaming,
|
return self.xmpp['xep_0163'].publish(
|
||||||
node=UserGaming.namespace,
|
gaming,
|
||||||
options=options, ifrom=ifrom,
|
node=UserGaming.namespace,
|
||||||
callback=callback, timeout=timeout,
|
**pubsubkwargs
|
||||||
timeout_callback=timeout_callback)
|
)
|
||||||
|
|
||||||
def stop(self, ifrom=None, callback=None, timeout=None,
|
def stop(self, **pubsubkwargs) -> Future:
|
||||||
timeout_callback=None):
|
|
||||||
"""
|
"""
|
||||||
Clear existing user gaming information to stop notifications.
|
Clear existing user gaming information to stop notifications.
|
||||||
"""
|
"""
|
||||||
gaming = UserGaming()
|
gaming = UserGaming()
|
||||||
return self.xmpp['xep_0163'].publish(gaming,
|
return self.xmpp['xep_0163'].publish(
|
||||||
node=UserGaming.namespace,
|
gaming,
|
||||||
ifrom=ifrom, callback=callback,
|
node=UserGaming.namespace,
|
||||||
timeout=timeout,
|
**pubsubkwargs
|
||||||
timeout_callback=timeout_callback)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user