# Path: invoker.py
# class ReplyObject:
#     """ Class for returning information from a command to the core program.
# 
#     Parameters used for creating this class defines the behaviour of the main
#     program when it comes across the reply object.
# 
#     Attributes:
#         text: str, the content of the reply.
#         samePlace: bool, if the response will always be in pm or where the command
#         was said.
#         ignoreEscaping: bool, default every reply is escaped to not allow
#         arbitrary commands to be executed through replies. Some commands require
#         to be able to use PS commands, which is when this should be overwritten.
#         ignoreBroadcastPermission: bool, ignore the global broadcast permission
#         for the reply if this is true.
#         gameCommand: bool, unused, pending removal.
#         canPmReply: bool, override the default request for users without broadcast
#         permission to pm the command and instead return the result of the action.
#         isException: bool, if a command throws an exception this will be true.
#     """
#     def __init__(self, res = '', reply = False, escape = False, broadcast = False, game = False, pmreply = False, ignoreml = False):
#         self.text = str(res)
#         self.samePlace = reply
#         self.ignoreEscaping = escape
#         self.ignoreBroadcastPermission = broadcast
#         self.ignoreMultiline = ignoreml
#         self.gameCommand = game
#         self.canPmReply = pmreply
#         self.isException = isinstance(res, Exception)
# 
#     def __eq__(self, other):
#         try:
#             return (self.text == other.text
#                 and self.samePlace == other.samePlace
#                 and self.ignoreEscaping == other.ignoreEscaping
#                 and self.ignoreBroadcastPermission == other.ignoreBroadcastPermission
#                 and self.ignoreMultiline == other.ignoreMultiline
#                 and self.gameCommand == other.gameCommand
#                 and self.canPmReply == other.canPmReply
#                 and self.isException == other.isException
#             )
#         except:
#             # This only happens if the other object isn't a matching object
#             return False
# 
#     def response(self, text):
#         self.text = text
#         return self
#     def extra(self, text):
#         self.text += text
#         return self
# 
# class Command:
#     """ Wrapper class that every command should use when being created.
# 
#     The default run method should never be called, and any instance of the
#     class should override this method on creation of the instance.
# 
#     Commands should also implement any private methods they may need for completion
# 
#     Attributes:
#         cmdTriggers: List, list of every trigger that should be used to invoke
#         this method.
#         altHtml: Bool, true if the command has alternate output if HTML is supported.
#     """
#     def __init__(self, triggers, nonAbsRun = None, html = False):
#         self.cmdTriggers = triggers
#         self.altHtml = html
#         self.hasBroadcastAlt = False
#         # This will hide the default run method if it is given on object creation
#         self.run = nonAbsRun if nonAbsRun else self.run
#     def run(self, robot, cmd, room, params, user):
#         """Abstract method for executing a command after it has been found. Each command
#         has to reimplement this function to work.
# 
#         Args:
#             robot: PokemonShowdownBot, the instance of PokemonShowdownBot that called this function.
#             cmd: string, the command that was send.
#             room: Room, the room object that the command was sent from.
#             params: string, additional paramters that the command may need.
#             user: User, the user object of the user who sent the command.
#         Returns:
#             ReplyObject.
#         Raises:
#             NotImplementedError if not implemented, otherwise unknown. """
#         raise NotImplementedError('Command#run method not implemented')


from invoker import ReplyObject, Command
from datetime import datetime, timedelta
import robot as r
import random
import re
    reply.samePlace = True
    responseText = "I'll be sure to tell {user} that.".format(user = msg[0])
    if to == user.id:
        responseText = "You sent yourself a message. Was this intended? It will work, but why?"
    return reply.response(responseText)

def read(bot, cmd, msg, user):
    reply = ReplyObject()
    notes = bot.usernotes
    if not notes.hasMessage(user.id): return reply.response('You have no messages waiting')
    if not msg:
        # If the user didn't speify any amount to return, give back a single message
        return reply.response(notes.getMessages(user.id, 1))
    if not msg.isdigit() and int(msg) < 1: return reply.response('Please enter a positive integer')
    return reply.response(notes.getMessages(user.id, int(msg)))

def untell(bot, cmd, msg, user):
    reply = ReplyObject()
    notes = bot.usernotes
    if not msg: return reply.response('You need to specify a user to remove')
    if not notes.hasMessage(msg): return reply.response('This user has no waiting messages')
    if not notes.removeMessage(msg, user.id): return reply.response('You have no message to this user waiting')
    return reply.response('Message removed')

handlers = {
    'j': join
}

commands = [
    Command(['tell'], tell),

# Path: invoker.py
# class ReplyObject:
#     """ Class for returning information from a command to the core program.
# 
#     Parameters used for creating this class defines the behaviour of the main
#     program when it comes across the reply object.
# 
#     Attributes:
#         text: str, the content of the reply.
#         samePlace: bool, if the response will always be in pm or where the command
#         was said.
#         ignoreEscaping: bool, default every reply is escaped to not allow
#         arbitrary commands to be executed through replies. Some commands require
#         to be able to use PS commands, which is when this should be overwritten.
#         ignoreBroadcastPermission: bool, ignore the global broadcast permission
#         for the reply if this is true.
#         gameCommand: bool, unused, pending removal.
#         canPmReply: bool, override the default request for users without broadcast
#         permission to pm the command and instead return the result of the action.
#         isException: bool, if a command throws an exception this will be true.
#     """
#     def __init__(self, res = '', reply = False, escape = False, broadcast = False, game = False, pmreply = False, ignoreml = False):
#         self.text = str(res)
#         self.samePlace = reply
#         self.ignoreEscaping = escape
#         self.ignoreBroadcastPermission = broadcast
#         self.ignoreMultiline = ignoreml
#         self.gameCommand = game
#         self.canPmReply = pmreply
#         self.isException = isinstance(res, Exception)
# 
#     def __eq__(self, other):
#         try:
#             return (self.text == other.text
#                 and self.samePlace == other.samePlace
#                 and self.ignoreEscaping == other.ignoreEscaping
#                 and self.ignoreBroadcastPermission == other.ignoreBroadcastPermission
#                 and self.ignoreMultiline == other.ignoreMultiline
#                 and self.gameCommand == other.gameCommand
#                 and self.canPmReply == other.canPmReply
#                 and self.isException == other.isException
#             )
#         except:
#             # This only happens if the other object isn't a matching object
#             return False
# 
#     def response(self, text):
#         self.text = text
#         return self
#     def extra(self, text):
#         self.text += text
#         return self
# 
# class Command:
#     """ Wrapper class that every command should use when being created.
# 
#     The default run method should never be called, and any instance of the
#     class should override this method on creation of the instance.
# 
#     Commands should also implement any private methods they may need for completion
# 
#     Attributes:
#         cmdTriggers: List, list of every trigger that should be used to invoke
#         this method.
#         altHtml: Bool, true if the command has alternate output if HTML is supported.
#     """
#     def __init__(self, triggers, nonAbsRun = None, html = False):
#         self.cmdTriggers = triggers
#         self.altHtml = html
#         self.hasBroadcastAlt = False
#         # This will hide the default run method if it is given on object creation
#         self.run = nonAbsRun if nonAbsRun else self.run
#     def run(self, robot, cmd, room, params, user):
#         """Abstract method for executing a command after it has been found. Each command
#         has to reimplement this function to work.
# 
#         Args:
#             robot: PokemonShowdownBot, the instance of PokemonShowdownBot that called this function.
#             cmd: string, the command that was send.
#             room: Room, the room object that the command was sent from.
#             params: string, additional paramters that the command may need.
#             user: User, the user object of the user who sent the command.
#         Returns:
#             ReplyObject.
#         Raises:
#             NotImplementedError if not implemented, otherwise unknown. """
#         raise NotImplementedError('Command#run method not implemented')


# Path: plugins/messages.py
from invoker import ReplyObject, Command
from datetime import datetime, timedelta
import robot as r
import random
import re

    reply.samePlace = True
    responseText = "I'll be sure to tell {user} that.".format(user = msg[0])
    if to == user.id:
        responseText = "You sent yourself a message. Was this intended? It will work, but why?"
    return reply.response(responseText)

def read(bot, cmd, msg, user):
    reply = ReplyObject()
    notes = bot.usernotes
    if not notes.hasMessage(user.id): return reply.response('You have no messages waiting')
    if not msg:
        # If the user didn't speify any amount to return, give back a single message
        return reply.response(notes.getMessages(user.id, 1))
    if not msg.isdigit() and int(msg) < 1: return reply.response('Please enter a positive integer')
    return reply.response(notes.getMessages(user.id, int(msg)))

def untell(bot, cmd, msg, user):
    reply = ReplyObject()
    notes = bot.usernotes
    if not msg: return reply.response('You need to specify a user to remove')
    if not notes.hasMessage(msg): return reply.response('This user has no waiting messages')
    if not notes.removeMessage(msg, user.id): return reply.response('You have no message to this user waiting')
    return reply.response('Message removed')

handlers = {
    'j': join
}

commands = [
    Command(['tell'], tell),

    Command(['untell'], untell),