# 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

        self.config = config or {}
        if 'api_key' not in self.config:
            raise Exception("Missing required api_key in config")

        # Connect to or create the database - raises on failure
        self._connect_or_create_db(cardinal)

    @property
    def api_key(self):
        return self.config['api_key']

    def _connect_or_create_db(self, cardinal):
        self.conn = None
        self.conn = sqlite3.connect(os.path.join(
            cardinal.storage_path,
            'database',
            'lastfm-%s.db' % cardinal.network
        ))

        c = self.conn.cursor()
        c.execute(
            "CREATE TABLE IF NOT EXISTS users ("
            "   nick text collate nocase,"
            "   vhost text,"
            "   username text"
            ")"
        )
        self.conn.commit()


# 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


        self.config = config or {}
        if 'api_key' not in self.config:
            raise Exception("Missing required api_key in config")

        # Connect to or create the database - raises on failure
        self._connect_or_create_db(cardinal)

    @property
    def api_key(self):
        return self.config['api_key']

    def _connect_or_create_db(self, cardinal):
        self.conn = None
        self.conn = sqlite3.connect(os.path.join(
            cardinal.storage_path,
            'database',
            'lastfm-%s.db' % cardinal.network
        ))

        c = self.conn.cursor()
        c.execute(
            "CREATE TABLE IF NOT EXISTS users ("
            "   nick text collate nocase,"
            "   vhost text,"
            "   username text"
            ")"
        )
        self.conn.commit()


    @command('setlastfm')