ocarina/src/core/rand.py

47 lines
884 B
Python

# This is a simple test plugin, to make sure everything is working
__author__="bjschuma"
__date__ ="$Jan 2, 2010 1:14:04 PM$"
global name, app, type, path, opt
name = "rand"
app = "ocarina"
type = "core"
path = ""
opt = []
from bt.message import write
from tools import database
import random
import settings
def next():
count = database.count("track")
return random.randint(0,count)
# Called every time the plugin is enabled
def open():
settings.set("random",False)
pass
# Called every time the plugin is stopped
def close():
pass
# Called when the plugin needs to perform some action
def run(args=None):
if args==None or len(args)==0:
settings.replace("random",not settings.get("random"))
random = settings.get("random")
if random == True:
settings.set("next",next)
else:
settings.pop("next")
elif args[0]=="?":
write(str(settings.get("random")))