# Path: bot/commands/abstract/command.py
# class Command(ABC):
#     """Represents a command, a way of reacting to chat messages."""
# 
#     perm = Permission.Admin
# 
#     def __init__(self, bot):
#         """Initialize the command."""
#         pass
# 
#     def match(self, bot, user, msg, tag_info):
#         """Return whether this command should be run."""
#         return False
# 
#     def run(self, bot, user, msg, tag_info):
#         """Run this command."""
#         pass
# 
#     def close(self, bot):
#         """Clean up."""
#         pass
# 
# Path: bot/utilities/tools.py
# def is_call_id_active(call_id):
#     """Check if reactor.callLater() from callID is active."""
#     if call_id is None:
#         return False
#     elif (call_id.called == 0) and (call_id.cancelled == 0):
#         return True
#     else:
#         return False


import random
from twisted.internet import reactor
from bot.commands.abstract.command import Command
from bot.utilities.permission import Permission
from bot.utilities.tools import is_call_id_active
        return msg.lower().startswith("!games on") or msg.lower().startswith(
            "!games off"
        )

    def run(self, bot, user, msg, tag_info):
        """Start/stop automatic games."""
        self.responses = bot.config.responses["AutoGames"]
        cmd = msg[len("!games ") :]
        cmd.strip()

        if cmd == "on":
            if not self.active:
                self.active = True
                self.callID = reactor.callLater(
                    self.auto_game_interval, self.random_game, bot
                )
                bot.write(self.responses["autogames_activate"]["msg"])
            else:
                bot.write(self.responses["autogames_already_on"]["msg"])
        elif cmd == "off":
            if is_call_id_active(self.callID):
                self.callID.cancel()
            if self.active:
                self.active = False
                bot.write(self.responses["autogames_deactivate"]["msg"])
            else:
                bot.write(self.responses["autogames_already_off"]["msg"])

    def close(self, bot):
        """Close the game."""

# Path: bot/commands/abstract/command.py
# class Command(ABC):
#     """Represents a command, a way of reacting to chat messages."""
# 
#     perm = Permission.Admin
# 
#     def __init__(self, bot):
#         """Initialize the command."""
#         pass
# 
#     def match(self, bot, user, msg, tag_info):
#         """Return whether this command should be run."""
#         return False
# 
#     def run(self, bot, user, msg, tag_info):
#         """Run this command."""
#         pass
# 
#     def close(self, bot):
#         """Clean up."""
#         pass
# 
# Path: bot/utilities/tools.py
# def is_call_id_active(call_id):
#     """Check if reactor.callLater() from callID is active."""
#     if call_id is None:
#         return False
#     elif (call_id.called == 0) and (call_id.cancelled == 0):
#         return True
#     else:
#         return False


# Path: bot/commands/autogames.py
import random
from twisted.internet import reactor
from bot.commands.abstract.command import Command
from bot.utilities.permission import Permission
from bot.utilities.tools import is_call_id_active

        return msg.lower().startswith("!games on") or msg.lower().startswith(
            "!games off"
        )

    def run(self, bot, user, msg, tag_info):
        """Start/stop automatic games."""
        self.responses = bot.config.responses["AutoGames"]
        cmd = msg[len("!games ") :]
        cmd.strip()

        if cmd == "on":
            if not self.active:
                self.active = True
                self.callID = reactor.callLater(
                    self.auto_game_interval, self.random_game, bot
                )
                bot.write(self.responses["autogames_activate"]["msg"])
            else:
                bot.write(self.responses["autogames_already_on"]["msg"])
        elif cmd == "off":
            if is_call_id_active(self.callID):
                self.callID.cancel()
            if self.active:
                self.active = False
                bot.write(self.responses["autogames_deactivate"]["msg"])
            else:
                bot.write(self.responses["autogames_already_off"]["msg"])

    def close(self, bot):
        """Close the game."""

        if is_call_id_active(self.callID):