<commit_before>import json, re, threading, time, urllib2, websocket
from exceptions import SlackError

SLACK_API_BASE = 'https://slack.com/api/'

class SlackBot(object):
    """
    The SlackBot class represents a Bot Integration connection to a Slack team.
    
    """
    def __init__(self, api_token, debug=False):
        self.api_token = api_token
        self.event_listeners = {}
        self.message_id = 0
        self.show_typing = False
        self.debug = debug
        self._threads = []

    def add_event_listener(self, event, handler):
        """
        Add a listener function which runs when ``event`` occurs.

        Arguments:
            event   -- One of: open, close, error, message, presence_change, user_typing
            handler -- Function to execute when the event occurs.
        
        """
        if event not in self.event_listeners:
            self.event_listeners[event] = []

        self.event_listeners[event].append(handler)

    def add_thread(self, f):
        self._threads.append(f)
        
    def channel_from_id(self, id):
        """Return SlackChannel object with given id."""
        for channel in self.channels:
            if channel.id == id:
                return channel
        else:
            raise SlackError('No channel with id %s' % id)
        
    def get_channel_id(self, channel_name):
        """Convert channel name to channel id."""
        for channel in self.channels:
            if channel.name == channel_name:<commit_msg>Allowed SlackBot.add_thread() to be called after bot has been started with SlackBot.run().<commit_after>import json, re, threading, time, urllib2, websocket
from exceptions import SlackError

SLACK_API_BASE = 'https://slack.com/api/'

class SlackBot(object):
    """
    The SlackBot class represents a Bot Integration connection to a Slack team.
    
    """
    def __init__(self, api_token, debug=False):
        self.api_token = api_token
        self.event_listeners = {}
        self.message_id = 0
        self.show_typing = False
        self.debug = debug
        self.running = False
        self._threads = []

    def add_event_listener(self, event, handler):
        """
        Add a listener function which runs when ``event`` occurs.

        Arguments:
            event   -- One of: open, close, error, message, presence_change, user_typing
            handler -- Function to execute when the event occurs.
        
        """
        if event not in self.event_listeners:
            self.event_listeners[event] = []

        self.event_listeners[event].append(handler)

    def add_thread(self, f):
        self._threads.append(f)
        if self.running:
            t = threading.Thread(target=f)
            t.daemon = True
            t.start()
        
    def channel_from_id(self, id):
        """Return SlackChannel object with given id."""
        for channel in self.channels:
            if channel.id == id:
                return channel
        else:
            raise SlackError('No channel with id %s' % id)
        
    def get_channel_id(self, channel_name):
        """Convert channel name to channel id."""
        for channel in self.channels:
            if channel.name == channel_name:
{'fraction_non_alphanumeric': 0.09301606922126082, 'fraction_numerical': 0.0012360939431396785, 'mean_word_length': 2.1125, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '607405', 'n_tokens_mistral': 905, 'n_tokens_neox': 889, 'n_words': 269}