# Path: cardinal/decorators.py
# def command(triggers):
#     if isinstance(triggers, str):
#         triggers = [triggers]
# 
#     if not isinstance(triggers, list):
#         raise TypeError("Command must be a trigger string or list of triggers")
# 
#     def wrap(f):
#         f.commands = triggers
#         return f
# 
#     return wrap
# 
# def help(lines):
#     # For backwards compatibility
#     if isinstance(lines, str):
#         lines = [lines]
# 
#     if not isinstance(lines, list):
#         raise TypeError("Help must be a help string or list of help strings")
# 
#     def wrap(f):
#         # Create help list or prepend to it
#         if not hasattr(f, 'help'):
#             f.help = lines
#         else:
#             f.help = lines + f.help
# 
#         return f
# 
#     return wrap
# 
# Path: cardinal/util.py
# def sleep(secs):
#     """Async sleep function"""
#     return deferLater(reactor, secs, lambda: None)


import random
from twisted.internet import defer
from cardinal.decorators import command, help
from cardinal.util import sleep




class Magic8BallPlugin:
    @command(['8', '8ball'])
    @help("Ask the might 8-ball a question.")
    @help("Syntax: .8 <question>")
    @defer.inlineCallbacks
    def answer(self, cardinal, user, channel, msg):
        if not (msg.endswith("?") and len(msg.split()) > 1):
            cardinal.sendMsg(channel, "Was that a question?")
            return

        cardinal.sendMsg(
            channel,
            "Let me dig deep into the waters of life, and find your answer."
        )
        yield sleep(2)
        cardinal.sendMsg(channel, "Hmmm...")

# Path: cardinal/decorators.py
# def command(triggers):
#     if isinstance(triggers, str):
#         triggers = [triggers]
# 
#     if not isinstance(triggers, list):
#         raise TypeError("Command must be a trigger string or list of triggers")
# 
#     def wrap(f):
#         f.commands = triggers
#         return f
# 
#     return wrap
# 
# def help(lines):
#     # For backwards compatibility
#     if isinstance(lines, str):
#         lines = [lines]
# 
#     if not isinstance(lines, list):
#         raise TypeError("Help must be a help string or list of help strings")
# 
#     def wrap(f):
#         # Create help list or prepend to it
#         if not hasattr(f, 'help'):
#             f.help = lines
#         else:
#             f.help = lines + f.help
# 
#         return f
# 
#     return wrap
# 
# Path: cardinal/util.py
# def sleep(secs):
#     """Async sleep function"""
#     return deferLater(reactor, secs, lambda: None)


# Path: plugins/8ball/plugin.py
import random
from twisted.internet import defer
from cardinal.decorators import command, help
from cardinal.util import sleep





class Magic8BallPlugin:
    @command(['8', '8ball'])
    @help("Ask the might 8-ball a question.")
    @help("Syntax: .8 <question>")
    @defer.inlineCallbacks
    def answer(self, cardinal, user, channel, msg):
        if not (msg.endswith("?") and len(msg.split()) > 1):
            cardinal.sendMsg(channel, "Was that a question?")
            return

        cardinal.sendMsg(
            channel,
            "Let me dig deep into the waters of life, and find your answer."
        )
        yield sleep(2)
        cardinal.sendMsg(channel, "Hmmm...")

        yield sleep(2)