# 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


import logging
import random
from abc import ABC
from twisted.internet import reactor
from bot.commands.abstract.command import Command
from bot.utilities.permission import Permission
"""Commands: "@[botname] XXXXX"."""




class Speech(Command, ABC):
    """Natural language."""

    perm = Permission.User
    reloadable = False

    def __init__(self, bot):
        """Define self.chatbot here"""
        self.chatbot = Chatbot()

    def match(self, bot, user, msg, tag_info):
        """Match if the bot is tagged."""
        return bot.config.nickname in msg.lower()

    def run(self, bot, user, msg, tag_info):
        """Send message to cleverbot only if no other command got triggered."""
        if not bot.antispeech:
            msg = msg.lower()
            msg = msg.replace("@", "")
            msg = msg.replace(bot.config.nickname, "")

            """Get reply in extra thread, so bot doesnt pause while waiting for the reply. 
            Problem: Only replies after someone else wrote something in chat."""

# 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/commands/abstract/speech.py
import logging
import random
from abc import ABC
from twisted.internet import reactor
from bot.commands.abstract.command import Command
from bot.utilities.permission import Permission

"""Commands: "@[botname] XXXXX"."""




class Speech(Command, ABC):
    """Natural language."""

    perm = Permission.User
    reloadable = False

    def __init__(self, bot):
        """Define self.chatbot here"""
        self.chatbot = Chatbot()

    def match(self, bot, user, msg, tag_info):
        """Match if the bot is tagged."""
        return bot.config.nickname in msg.lower()

    def run(self, bot, user, msg, tag_info):
        """Send message to cleverbot only if no other command got triggered."""
        if not bot.antispeech:
            msg = msg.lower()
            msg = msg.replace("@", "")
            msg = msg.replace(bot.config.nickname, "")

            """Get reply in extra thread, so bot doesnt pause while waiting for the reply. 
            Problem: Only replies after someone else wrote something in chat."""

            reactor.callInThread(self.answer, bot, user, msg)