<commit_before># -*- coding: utf-8 -*-

# Nemubot is a modulable IRC bot, built around XML configuration files.
# Copyright (C) 2012  <NAME>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import queue
import threading
import traceback
import sys

from message import Message
from response import Response

class MessageConsumer:
    """Store a message before treating"""
    def __init__(self, srv, raw, time, prvt, data):
        self.srv = srv
        self.raw = raw
        self.time = time
        self.prvt = prvt
        self.data = data

    def run(self):
        # Create, parse and treat the message
        try:
            msg = Message(self.srv, self.raw, self.time, self.prvt)
            res = msg.treat()
        except:
            print ("\033[1;31mERROR:\033[0m occurred during the "
                   "processing of the message: %s" % self.raw)
            exc_type, exc_value, exc_traceback = sys.exc_info()
            traceback.print_exception(exc_type, exc_value,
                                      exc_traceback)
            return

        # Send message
        if res is not None:
            if isinstance(res, list):
                for r in res:
                    if isinstance(r, Response):
                        self.srv.send_response(r, self.data)
            elif isinstance(res, Response):
                self.srv.send_response(res, self.data)
                
        # Inform that the message has been treated
        self.srv.msg_treated(self.data)
        

class EventConsumer:
    """Store a event before treating"""<commit_msg>Modules can return list of Responses<commit_after># -*- coding: utf-8 -*-

# Nemubot is a modulable IRC bot, built around XML configuration files.
# Copyright (C) 2012  <NAME>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import queue
import threading
import traceback
import sys

from message import Message
from response import Response

class MessageConsumer:
    """Store a message before treating"""
    def __init__(self, srv, raw, time, prvt, data):
        self.srv = srv
        self.raw = raw
        self.time = time
        self.prvt = prvt
        self.data = data

    def run(self):
        # Create, parse and treat the message
        try:
            msg = Message(self.srv, self.raw, self.time, self.prvt)
            res = msg.treat()
        except:
            print ("\033[1;31mERROR:\033[0m occurred during the "
                   "processing of the message: %s" % self.raw)
            exc_type, exc_value, exc_traceback = sys.exc_info()
            traceback.print_exception(exc_type, exc_value,
                                      exc_traceback)
            return

        # Send message
        if res is not None:
            if isinstance(res, list):
                for r in res:
                    if isinstance(r, Response):
                        self.srv.send_response(r, self.data)
                    elif isinstance(r, list):
                        for s in r:
                            if isinstance(s, Response):
                                self.srv.send_response(s, self.data)
            elif isinstance(res, Response):
                self.srv.send_response(res, self.data)
                
        # Inform that the message has been treated
        self.srv.msg_treated(self.data)
        

class EventConsumer:
    """Store a event before treating"""
{'fraction_non_alphanumeric': 0.07657266811279827, 'fraction_numerical': 0.006941431670281995, 'mean_word_length': 2.0925553319919517, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2911492', 'n_tokens_mistral': 1245, 'n_tokens_neox': 1193, 'n_words': 486}