# 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 os
import sqlite3
import logging
import requests
from twisted.internet import defer
from twisted.internet.threads import deferToThread
from cardinal.decorators import command, help
            )
        result = c.fetchone()

        # Use the returned username, or the entered/user's nick otherwise
        try:
            username = message[1]
        except IndexError:
            username = user.nick

        if result:
            username = result[0]

        try:
            msg = yield self._get_np_result(username)
        except Exception:
            self.logger.exception("Error communicating with Last.fm")
            cardinal.sendMsg(channel, "Error communicating with Last.fm")
            return

        cardinal.sendMsg(channel, msg)

    @defer.inlineCallbacks
    def _get_np_result(self, username):
        r = yield deferToThread(
            requests.get,
            "http://ws.audioscrobbler.com/2.0/",
            params={
                "method": "user.getrecenttracks",
                "user": username,
                "api_key": self.api_key,

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

            )
        result = c.fetchone()

        # Use the returned username, or the entered/user's nick otherwise
        try:
            username = message[1]
        except IndexError:
            username = user.nick

        if result:
            username = result[0]

        try:
            msg = yield self._get_np_result(username)
        except Exception:
            self.logger.exception("Error communicating with Last.fm")
            cardinal.sendMsg(channel, "Error communicating with Last.fm")
            return

        cardinal.sendMsg(channel, msg)

    @defer.inlineCallbacks
    def _get_np_result(self, username):
        r = yield deferToThread(
            requests.get,
            "http://ws.audioscrobbler.com/2.0/",
            params={
                "method": "user.getrecenttracks",
                "user": username,
                "api_key": self.api_key,

                "limit": 1,