Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slixmpp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
35
Issues
35
List
Boards
Labels
Service Desk
Milestones
Merge Requests
6
Merge Requests
6
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
poezio
slixmpp
Commits
b50bfb2f
Unverified
Commit
b50bfb2f
authored
Jul 13, 2019
by
mathieui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial commit for reactions protoxep
parent
b29bb30e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
97 additions
and
0 deletions
+97
-0
slixmpp/plugins/__init__.py
slixmpp/plugins/__init__.py
+1
-0
slixmpp/plugins/protoxep_reactions/__init__.py
slixmpp/plugins/protoxep_reactions/__init__.py
+11
-0
slixmpp/plugins/protoxep_reactions/reactions.py
slixmpp/plugins/protoxep_reactions/reactions.py
+54
-0
slixmpp/plugins/protoxep_reactions/stanza.py
slixmpp/plugins/protoxep_reactions/stanza.py
+31
-0
No files found.
slixmpp/plugins/__init__.py
View file @
b50bfb2f
...
...
@@ -85,4 +85,5 @@ __all__ = [
'xep_0323'
,
# IoT Systems Sensor Data
'xep_0325'
,
# IoT Systems Control
'xep_0332'
,
# HTTP Over XMPP Transport
'protoxep_reactions'
,
# https://dino.im/xeps/reactions.html
]
slixmpp/plugins/protoxep_reactions/__init__.py
0 → 100644
View file @
b50bfb2f
"""
Slixmpp: The Slick XMPP Library
Copyright (C) 2019 Mathieu Pasquet
This file is part of Slixmpp.
See the file LICENSE for copying permission.
"""
from
slixmpp.plugins.base
import
register_plugin
from
slixmpp.plugins.protoxep_reactions.reactions
import
XEP_Reactions
register_plugin
(
XEP_Reactions
)
slixmpp/plugins/protoxep_reactions/reactions.py
0 → 100644
View file @
b50bfb2f
"""
Slixmpp: The Slick XMPP Library
Copyright (C) 2019 Mathieu Pasquet
This file is part of Slixmpp.
See the file LICENSE for copying permission.
"""
from
typing
import
Iterable
from
slixmpp.plugins
import
BasePlugin
from
slixmpp.stanza
import
Message
from
slixmpp.xmlstream
import
register_stanza_plugin
from
slixmpp.xmlstream.matcher
import
MatchXMLMask
from
slixmpp.xmlstream.handler
import
Callback
from
slixmpp.plugins.protoxep_reactions
import
stanza
class
XEP_Reactions
(
BasePlugin
):
name
=
'protoxep_reactions'
description
=
'XEP-XXXX: Message Reactions'
dependencies
=
{
'xep_0030'
}
stanza
=
stanza
def
plugin_init
(
self
):
self
.
xmpp
.
register_handler
(
Callback
(
'Reaction received'
,
MatchXMLMask
(
'<message><reactions xmlns="urn:xmpp:reactions:0"/></message>'
),
self
.
_handle_reactions
,
)
)
self
.
xmpp
[
'xep_0030'
].
add_feature
(
'urn:xmpp:reactions:0'
)
register_stanza_plugin
(
Message
,
stanza
.
Reactions
)
def
plugin_end
(
self
):
self
.
xmpp
.
remove_handler
(
'Reaction received'
)
self
.
xmpp
[
'xep_0030'
].
remove_feature
(
'urn:xmpp:reactions:0'
)
def
_handle_reactions
(
self
,
message
:
Message
):
self
.
xmpp
.
event
(
'reactions'
,
message
)
@
staticmethod
def
set_reactions
(
message
:
Message
,
to_id
:
str
,
reactions
:
Iterable
[
str
]):
"""
Add reactions to a Message object.
"""
reactions_stanza
=
stanza
.
Reactions
()
reactions_stanza
[
'to'
]
=
to_id
for
reaction
in
reactions
:
reaction_stanza
=
stanza
.
Reaction
()
reaction_stanza
[
'value'
]
=
reaction
reactions_stanza
.
append
(
reaction_stanza
)
message
.
append
(
reactions_stanza
)
slixmpp/plugins/protoxep_reactions/stanza.py
0 → 100644
View file @
b50bfb2f
"""
Slixmpp: The Slick XMPP Library
Copyright (C) 2019 Mathieu Pasquet
This file is part of Slixmpp.
See the file LICENSE for copying permission.
"""
from
slixmpp.xmlstream
import
ElementBase
,
register_stanza_plugin
class
Reactions
(
ElementBase
):
name
=
'reactions'
plugin_attrib
=
'reactions'
namespace
=
'urn:xmpp:reactions:0'
interfaces
=
{
'to'
}
class
Reaction
(
ElementBase
):
name
=
'reaction'
namespace
=
'urn:xmpp:reactions:0'
interfaces
=
{
'value'
}
def
get_value
(
self
)
->
str
:
return
self
.
xml
.
text
def
set_value
(
self
,
value
:
str
):
self
.
xml
.
text
=
value
register_stanza_plugin
(
Reactions
,
Reaction
,
iterable
=
True
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment