<commit_before>import sys
import xmpp
from lib.bot import *
from lib.utils import *
from lib.event import *
from lib.cache import *

# Required parameters:
# - jid
# - password
# - source_room
# - force_tls

class AbuseHelperBot(Bot):

    def handle_message(self, xmpp_connection, message):
        try:
            event = Event.from_unicode(unicode(message.getBody()))
            
            for key in event.keys():
                value = event.value(key)
                event.clear(key)
                key = key.replace(' ','_')
                event.add(key, value)

            self.send_message(event)
        except:
            pass

    def start(self):
        jid = xmpp.JID(self.parameters.jid)
        
        xmpp_connection = xmpp.Client(jid.getDomain(), debug=[])
        connection_result = xmpp_connection.connect()

        if not connection_result:
            # TODO: Log error
            return

        if self.parameters.force_tls == 'true' and connection_result != 'tls':
            # TODO: Log error
            return

        authentication_result = xmpp_connection.auth(jid.getNode(), self.parameters.password)
        if not authentication_result:
            # TODO: Log error
            return

        xmpp_connection.RegisterHandler(name='message', handler=self.handle_message)
        xmpp_connection.sendInitPresence()

        xmpp_connection.send(xmpp.Presence(to='%s@conference.%s/%s' % (self.parameters.source_room, jid.getDomain(), self.bot_id)))

        while True:
            print 'Iteration'
            if not xmpp_connection.isConnected():
                xmpp_connection.reconnectAndReauth()
            else:
                xmpp_connection.Process()

            time.sleep(int(self.parameters.processing_interval))


if __name__ == "__main__":
    bot = AbuseHelperBot(sys.argv[1])
    bot.start()<commit_msg>Update abusehelper.py<commit_after>import sys
import xmpp
from lib.bot import *
from lib.utils import *
from lib.event import *
from lib.cache import *

# Required parameters:
# - jid
# - password
# - source_room
# - force_tls

class AbuseHelperBot(Bot):

    def handle_message(self, xmpp_connection, message):
        try:
            event = Event.from_unicode(unicode(message.getBody()))
            
            for key in event.keys():
                value = event.value(key)
                event.clear(key)
                key = key.replace(' ','_')
                event.add(key, value)

            self.send_message(event)
        except:
            pass

    def start(self):
        jid = xmpp.JID(self.parameters.jid)
        
        xmpp_connection = xmpp.Client(jid.getDomain(), debug=[])
        connection_result = xmpp_connection.connect()

        if not connection_result:
            # TODO: Log error
            return

        if self.parameters.force_tls == 'true' and connection_result != 'tls':
            # TODO: Log error
            return

        authentication_result = xmpp_connection.auth(jid.getNode(), self.parameters.password)
        if not authentication_result:
            # TODO: Log error
            return

        xmpp_connection.RegisterHandler(name='message', handler=self.handle_message)
        xmpp_connection.sendInitPresence()

        xmpp_connection.send(xmpp.Presence(to='%s@conference.%s/%s' % (self.parameters.source_room, jid.getDomain(), self.bot_id)))

        while True:
            if not xmpp_connection.isConnected():
                xmpp_connection.reconnectAndReauth()
            else:
                xmpp_connection.Process()

            time.sleep(int(self.parameters.processing_interval))


if __name__ == "__main__":
    bot = AbuseHelperBot(sys.argv[1])
    bot.start()
{'fraction_non_alphanumeric': 0.10338345864661654, 'fraction_numerical': 0.0005370569280343716, 'mean_word_length': 2.1328847771236332, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5552422', 'n_tokens_mistral': 1104, 'n_tokens_neox': 1065, 'n_words': 208}