def browse_cmd(): args = [es.getargv(x) for x in xrange(1, es.getargc())] if not len(args): xamodule.logging.log("Incorrect usage: xa_browse <url>") return url = urllib.quote(args[0]) if not url.startswith('http://'): url = 'http://'+url xamodule.logging.log("Opening url: %s" % url) usermsg.motd(es.getcmduserid(), 2, "XA Browse", url)
def browse_cmd(): args = [es.getargv(x) for x in xrange(1, es.getargc())] if not len(args): xamodule.logging.log("Incorrect usage: xa_browse <url>") return url = urllib.quote(args[0]) if not url.startswith('http://'): url = 'http://' + url xamodule.logging.log("Opening url: %s" % url) usermsg.motd(es.getcmduserid(), 2, "XA Browse", url)
def usermsg_cmd(args): if len(args) == 1: if args[0] == 'list': es.dbgmsg(0, "usermsg fade: Syntax: fade <userid> <0 = no fade, 1 = fade Out 2 = fade in> <time to fade (in frames)> <time faded (in frames)> <red> <green> <blue> <alpha>") es.dbgmsg(0, "usermsg shake: Syntax: shake <userid> <magnitude> <time>") es.dbgmsg(0, "usermsg motd: Syntax: motd <userid> <0 = text, 2 = url> <title> <msg>") es.dbgmsg(0, "usermsg hudhint: Syntax: hudhint <userid> <msg>") es.dbgmsg(0, "usermsg keyhint: Syntax: keyhint <userid> <msg>") es.dbgmsg(0, "usermsg centermsg: Syntax: centermsg <userid> <msg>") else: es.dbgmsg(0, 'usermsg: Invalid parameters, type "usermsg list" to see a list of valid subcommands') elif len(args) > 1: subcommand = args[0] if subcommand == 'fade': if len(args) > 8: usermsg.fade(args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]) else: es.dbgmsg(0, "usermsg fade: Syntax: fade <userid> <0 = no fade, 1 = fade Out 2 = fade in> <time to fade (in frames)> <time faded (in frames)> <red> <green> <blue> <alpha>") elif subcommand == 'shake': if len(args) > 3: usermsg.shake(args[1], args[2], args[3]) else: es.dbgmsg(0, "usermsg shake: Syntax: shake <userid> <magnitude> <time>") elif subcommand == 'motd': if len(args) > 4: usermsg.motd(args[1], args[2], args[3], args[4]) else: es.dbgmsg(0, "usermsg motd: Syntax: motd <userid> <0 = text, 2 = url> <title> <msg>") elif subcommand == 'hudhint': if len(args) > 2: usermsg.hudhint(args[1], args[2]) else: es.dbgmsg(0, "usermsg hudhint: Syntax: hudhint <userid> <msg>") elif subcommand == 'keyhint': if len(args) > 2: usermsg.keyhint(args[1], args[2]) else: es.dbgmsg(0, "usermsg keyhint: Syntax: keyhint <userid> <msg>") elif subcommand == 'centermsg': if len(args) > 2: usermsg.centermsg(args[1], args[2]) else: es.dbgmsg(0, "usermsg centermsg: Syntax: centermsg <userid> <msg>") elif subcommand == 'echo': if len(args) > 2: usermsg.echo(args[1], args[2]) else: es.dbgmsg(0, "usermsg echo: Syntax: echo <userid> <msg>") else: es.dbgmsg(0, 'usermsg: Invalid subcommand, type "usermsg list" to see a list of valid subcommands') else: es.dbgmsg(0, 'usermsg: Missing userid and subcommand, type "usermsg list" to see a list of valid subcommands')
def radio_menu_select(userid, choice, popupid): steamid = es.getplayersteamid(userid) data_pack = {'steamid':userid, 'userid':userid} if choice == "tune_in": if client[steamid]['radio']: client[steamid]['radio'] = 0 esc.tell(userid, '#50,50,50[Radio] #snowYou have turned radio #50,50,50off') usermsg.motd(userid, 2, 'Cafe Radio - Youtube', "http://www.google.com", visible=False) else: client[steamid]['radio'] = 1 esc.tell(userid, '#50,50,50[Radio] #snowYou have turned radio #50,50,50on') my_song = str(radio['song']) + "&feature=youtu.be&t=" + str(radio['current_duration']) usermsg.motd(userid, 2, 'Cafe Radio - Youtube', my_song, visible=False) TSQL.Query.fetchall("SELECT title FROM playlist ORDER BY date DESC", callback=data_to_menu_callback, data_pack=data_pack)
def player_say(ev): text = ev['text'] userid = ev['userid'] data_pack = {'userid': userid, 'text': text} if text.startswith("!radio"): TSQL.Query.fetchall("SELECT title FROM playlist ORDER BY date DESC", callback=data_to_menu_callback, data_pack=data_pack) if text == "!songname": esc.msg('#50,50,50[Radio] #snowCurrently playing: %s' % radio['title'] + "#50,50,50|#snow duration: %s" % radio['duration']) if text == "!youtube": usermsg.motd(userid, 2, 'Add a song..', "http://dreamaboutnow.com/youtube", visible=True) if text == "!skip": radio['current_duration'] = 5000 esc.msg('#50,50,50[Radio] #snowSong has been skipped!')
def jukebox_loop(): if radio['current_duration'] >= radio['duration']: data = mysql.query.fetchone("SELECT title, duration, url, id FROM playlist ORDER BY date ASC") if bool(data): if not data[2] == None or not data[0] == None: radio['song'] = data[2] radio['title'] = data[0] radio['duration'] = get_time(data[1]) radio['current_duration'] = 0 for userid in es.getUseridList(): steamid = es.getplayersteamid(userid) if client[steamid]['radio']: usermsg.motd(userid, 2, 'Cafe Radio - Youtube', radio['song'], visible=False) esc.msg('#50,50,50[Radio] #snowTune it with !radio') esc.msg('#50,50,50[Radio] #snowNow playing: #50,50,50%s' % radio['title']) else: radio['song'] = "" radio['title'] = "" radio['duration'] = 0 radio['current_duration'] = 0 mysql.query.execute("DELETE FROM playlist WHERE id='%s'" % data[3]) else: radio['song'] = "" radio['title'] = "" radio['duration'] = 0 radio['current_duration'] = 0 radio['current_duration'] += 1 gamethread.delayedname(1, "jukebox_loop", jukebox_loop)
def usermsg_cmd(args): if len(args) == 1: if args[0] == 'list': es.dbgmsg( 0, "usermsg fade: Syntax: fade <userid> <0 = no fade, 1 = fade Out 2 = fade in> <time to fade (in frames)> <time faded (in frames)> <red> <green> <blue> <alpha>" ) es.dbgmsg( 0, "usermsg shake: Syntax: shake <userid> <magnitude> <time>") es.dbgmsg( 0, "usermsg motd: Syntax: motd <userid> <0 = text, 2 = url> <title> <msg>" ) es.dbgmsg(0, "usermsg hudhint: Syntax: hudhint <userid> <msg>") es.dbgmsg(0, "usermsg keyhint: Syntax: keyhint <userid> <msg>") es.dbgmsg(0, "usermsg centermsg: Syntax: centermsg <userid> <msg>") else: es.dbgmsg( 0, 'usermsg: Invalid parameters, type "usermsg list" to see a list of valid subcommands' ) elif len(args) > 1: subcommand = args[0] if subcommand == 'fade': if len(args) > 8: usermsg.fade(args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]) else: es.dbgmsg( 0, "usermsg fade: Syntax: fade <userid> <0 = no fade, 1 = fade Out 2 = fade in> <time to fade (in frames)> <time faded (in frames)> <red> <green> <blue> <alpha>" ) elif subcommand == 'shake': if len(args) > 3: usermsg.shake(args[1], args[2], args[3]) else: es.dbgmsg( 0, "usermsg shake: Syntax: shake <userid> <magnitude> <time>") elif subcommand == 'motd': if len(args) > 4: usermsg.motd(args[1], args[2], args[3], args[4]) else: es.dbgmsg( 0, "usermsg motd: Syntax: motd <userid> <0 = text, 2 = url> <title> <msg>" ) elif subcommand == 'hudhint': if len(args) > 2: usermsg.hudhint(args[1], args[2]) else: es.dbgmsg(0, "usermsg hudhint: Syntax: hudhint <userid> <msg>") elif subcommand == 'keyhint': if len(args) > 2: usermsg.keyhint(args[1], args[2]) else: es.dbgmsg(0, "usermsg keyhint: Syntax: keyhint <userid> <msg>") elif subcommand == 'centermsg': if len(args) > 2: usermsg.centermsg(args[1], args[2]) else: es.dbgmsg( 0, "usermsg centermsg: Syntax: centermsg <userid> <msg>") elif subcommand == 'echo': if len(args) > 2: usermsg.echo(args[1], args[2]) else: es.dbgmsg(0, "usermsg echo: Syntax: echo <userid> <msg>") else: es.dbgmsg( 0, 'usermsg: Invalid subcommand, type "usermsg list" to see a list of valid subcommands' ) else: es.dbgmsg( 0, 'usermsg: Missing userid and subcommand, type "usermsg list" to see a list of valid subcommands' )