<commit_before>import logging
import time

from stupid.chatbot import ChatBot, every_minute
from stupid.utils import weekday
from stupid.weather import WeatherForecast


logger = logging.getLogger(__name__)


class LunchBot(ChatBot):
    ASK_TIMEOUT = 15

    def __init__(self, *args, **kwargs):
        super(LunchBot, self).__init__(*args, **kwargs)
        self.weather = WeatherForecast()
        self.schedule.every().day.at("11:55").do(self.eat_some)
        self.schedule.every().day.at("15:55").do(self.eat_some)
        self.announce_ts = None
        self.ask_for_reply_after = None
        self.users_to_ask = []

    @every_minute
    @weekday
    def on_timeout(self):
        if self.ask_for_reply_after is not None:
            delta = round((time.time() - self.ask_for_reply_after) / 60)
            disable = False
            if 0 <= delta < self.ASK_TIMEOUT:
                disable = self.ask_for_reply()
            if delta > self.ASK_TIMEOUT:
                logger.debug("Asking for reply timeout - %d - cancelling", delta)
                disable = True
            if disable:
                self.ask_for_reply_after = None
                self.users_to_ask = []
        else:
            self.schedule.run_pending()

    def eat_some(self):
        response = self.broker.post(
            "Who is going to eat? Beware, it's {0}".format(self.weather.report()),
            color='warning',
        )<commit_msg>Fixed LunchBot recursion<commit_after>import logging
import time

from stupid.chatbot import ChatBot, every_minute
from stupid.utils import weekday
from stupid.weather import WeatherForecast


logger = logging.getLogger(__name__)


class LunchBot(ChatBot):
    ASK_TIMEOUT = 15

    def __init__(self, *args, **kwargs):
        super(LunchBot, self).__init__(*args, **kwargs)
        self.weather = WeatherForecast()
        self.schedule.every().day.at("11:55").do(self.eat_some)
        self.schedule.every().day.at("15:55").do(self.eat_some)
        self.announce_ts = None
        self.ask_for_reply_after = None
        self.users_to_ask = []

    @every_minute
    @weekday
    def on_timeout(self):
        if self.ask_for_reply_after is not None:
            delta = round((time.time() - self.ask_for_reply_after) / 60)
            disable = False
            if 0 <= delta < self.ASK_TIMEOUT:
                disable = self.ask_for_reply()
            if delta > self.ASK_TIMEOUT:
                logger.debug("Asking for reply timeout - %d - cancelling", delta)
                disable = True
            if disable:
                self.ask_for_reply_after = None
                self.users_to_ask = []

    def eat_some(self):
        response = self.broker.post(
            "Who is going to eat? Beware, it's {0}".format(self.weather.report()),
            color='warning',
        )
{'fraction_non_alphanumeric': 0.1075079309129362, 'fraction_numerical': 0.00986958054282693, 'mean_word_length': 2.221339387060159, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '1157791', 'n_tokens_mistral': 894, 'n_tokens_neox': 841, 'n_words': 184}