2 Slixmpp: The Slick XMPP Library
3 Copyright (C) 2011 Nathanael C. Fritz, Lance J.T. Stout
4 This file is part of Slixmpp.
6 See the file LICENSE for copying permission.
11 from slixmpp
.plugins
.base
import BasePlugin
12 from slixmpp
.plugins
.xep_0196
import stanza
, UserGaming
15 log
= logging
.getLogger(__name__
)
18 class XEP_0196(BasePlugin
):
25 description
= 'XEP-0196: User Gaming'
26 dependencies
= set(['xep_0163'])
30 self
.xmpp
['xep_0030'].del_feature(feature
=UserGaming
.namespace
)
31 self
.xmpp
['xep_0163'].remove_interest(UserGaming
.namespace
)
33 def session_bind(self
, jid
):
34 self
.xmpp
['xep_0163'].register_pep('user_gaming', UserGaming
)
36 def publish_gaming(self
, name
=None, level
=None, server_name
=None,
37 uri
=None, character_name
=None,
38 character_profile
=None, server_address
=None,
39 options
=None, ifrom
=None, callback
=None,
40 timeout
=None, timeout_callback
=None):
42 Publish the user's current gaming status.
45 name -- The name of the game.
46 level -- The user's level in the game.
47 uri -- A URI for the game or relevant gaming service
48 server_name -- The name of the server where the user is playing.
49 server_address -- The hostname or IP address of the server where the
51 character_name -- The name of the user's character in the game.
52 character_profile -- A URI for a profile of the user's character.
53 options -- Optional form of publish options.
54 ifrom -- Specify the sender's JID.
55 timeout -- The length of time (in seconds) to wait for a response
56 before exiting the send call if blocking is used.
57 Defaults to slixmpp.xmlstream.RESPONSE_TIMEOUT
58 callback -- Optional reference to a stream handler function. Will
59 be executed when a reply stanza is received.
63 gaming
['level'] = level
65 gaming
['character_name'] = character_name
66 gaming
['character_profile'] = character_profile
67 gaming
['server_name'] = server_name
68 gaming
['server_address'] = server_address
69 return self
.xmpp
['xep_0163'].publish(gaming
,
70 node
=UserGaming
.namespace
,
71 options
=options
, ifrom
=ifrom
,
72 callback
=callback
, timeout
=timeout
,
73 timeout_callback
=timeout_callback
)
75 def stop(self
, ifrom
=None, callback
=None, timeout
=None,
76 timeout_callback
=None):
78 Clear existing user gaming information to stop notifications.
81 ifrom -- Specify the sender's JID.
82 timeout -- The length of time (in seconds) to wait for a response
83 before exiting the send call if blocking is used.
84 Defaults to slixmpp.xmlstream.RESPONSE_TIMEOUT
85 callback -- Optional reference to a stream handler function. Will
86 be executed when a reply stanza is received.
89 return self
.xmpp
['xep_0163'].publish(gaming
,
90 node
=UserGaming
.namespace
,
91 ifrom
=ifrom
, callback
=callback
,
93 timeout_callback
=timeout_callback
)