# 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


import logging
import requests
from cardinal.decorators import command, help
from twisted.internet import defer
from twisted.internet.threads import deferToThread

    @defer.inlineCallbacks
    @command(['ud', 'urbandict'])
    @help('Returns the top Urban Dictionary definition for a given word.')
    @help('Syntax: .ud <word>')
    def get_ud(self, cardinal, user, channel, msg):
        try:
            word = msg.split(' ', 1)[1]
        except IndexError:
            cardinal.sendMsg(channel, 'Syntax: .ud <word>')
            return

        try:
            url = URBANDICT_API_PREFIX
            r = yield deferToThread(requests.get, url, params={'term': word})

            data = r.json()
            entry = data['list'].pop(0)

            definition = entry['definition']
            thumbs_up = entry['thumbs_up']
            thumbs_down = entry['thumbs_down']
            link = entry['permalink']

            response = 'UD [%s]: %s [\u25b2%d|\u25bc%d] - %s' % (
                word, definition, thumbs_up, thumbs_down, link
            )

            cardinal.sendMsg(channel, response)
        except Exception:

# 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: plugins/urbandict/plugin.py
import logging
import requests
from cardinal.decorators import command, help
from twisted.internet import defer
from twisted.internet.threads import deferToThread


    @defer.inlineCallbacks
    @command(['ud', 'urbandict'])
    @help('Returns the top Urban Dictionary definition for a given word.')
    @help('Syntax: .ud <word>')
    def get_ud(self, cardinal, user, channel, msg):
        try:
            word = msg.split(' ', 1)[1]
        except IndexError:
            cardinal.sendMsg(channel, 'Syntax: .ud <word>')
            return

        try:
            url = URBANDICT_API_PREFIX
            r = yield deferToThread(requests.get, url, params={'term': word})

            data = r.json()
            entry = data['list'].pop(0)

            definition = entry['definition']
            thumbs_up = entry['thumbs_up']
            thumbs_down = entry['thumbs_down']
            link = entry['permalink']

            response = 'UD [%s]: %s [\u25b2%d|\u25bc%d] - %s' % (
                word, definition, thumbs_up, thumbs_down, link
            )

            cardinal.sendMsg(channel, response)
        except Exception:

            self.logger.exception("Error with definition: %s", word)