diff options
author | mathieui <mathieui@mathieui.net> | 2020-05-24 13:33:51 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2020-05-24 13:33:51 +0200 |
commit | 2e31de3f456ac2e9e4d2950c04ff3594fe41db65 (patch) | |
tree | 55add6d1cd9aac7ab63e8eeb88a667336dd25824 /slixmpp/plugins/xep_0377/spam_reporting.py | |
parent | 04df50feac4041f20a70417136adbcc3cfc71d15 (diff) | |
download | slixmpp-2e31de3f456ac2e9e4d2950c04ff3594fe41db65.tar.gz slixmpp-2e31de3f456ac2e9e4d2950c04ff3594fe41db65.tar.bz2 slixmpp-2e31de3f456ac2e9e4d2950c04ff3594fe41db65.tar.xz slixmpp-2e31de3f456ac2e9e4d2950c04ff3594fe41db65.zip |
Add a plugin for XEP-0377: spam reporting
Diffstat (limited to 'slixmpp/plugins/xep_0377/spam_reporting.py')
-rw-r--r-- | slixmpp/plugins/xep_0377/spam_reporting.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/slixmpp/plugins/xep_0377/spam_reporting.py b/slixmpp/plugins/xep_0377/spam_reporting.py new file mode 100644 index 00000000..e1ca0143 --- /dev/null +++ b/slixmpp/plugins/xep_0377/spam_reporting.py @@ -0,0 +1,41 @@ +""" + Slixmpp: The Slick XMPP Library + Copyright (C) 2020 Mathieu Pasquet + This file is part of Slixmpp. + + See the file LICENSE for copying permission. +""" + +import logging + +import slixmpp +from slixmpp import Message +from slixmpp.plugins import BasePlugin +from slixmpp.xmlstream import register_stanza_plugin +from slixmpp.xmlstream.handler import Callback +from slixmpp.xmlstream.matcher import StanzaPath +from slixmpp.plugins.xep_0377 import stanza +from slixmpp.plugins.xep_0191 import Block + + +log = logging.getLogger(__name__) + + +class XEP_0377(BasePlugin): + """XEP-0377: Spam reporting""" + + name = 'xep_0377' + description = 'XEP-0377: Spam Reporting' + dependencies = {'xep_0030', 'xep_0191'} + stanza = stanza + + def plugin_init(self): + register_stanza_plugin(Block, stanza.Report) + register_stanza_plugin(stanza.Report, stanza.Text) + + def plugin_end(self): + self.xmpp['xep_0030'].del_feature(feature=stanza.Report.namespace) + + def session_bind(self, jid): + self.xmpp['xep_0030'].add_feature(stanza.Report.namespace) + |