summaryrefslogtreecommitdiff
path: root/slixmpp/plugins/xep_0377/spam_reporting.py
blob: d6ef6d7ea98e7da4b0ca44c76a9454a04d734369 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

# 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)