· 8 years ago · Mar 10, 2018, 09:34 AM
1on *:START:{
2 set %jukebox_ctl_db $sqlite_open(jukebox_ctl.db)
3 if (!%jukebox_ctl_db) {
4 echo 4 -a Error: %sqlite_errstr
5 return
6 }
7 sqlite_exec %jukebox_ctl_db CREATE TABLE IF NOT EXISTS nicks (id INTEGER PRIMARY KEY AUTOINCREMENT , nick TEXT UNIQUE NOT NULL , last TEXT NOT NULL , date TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP)
8 sqlite_exec %jukebox_ctl_db CREATE TABLE IF NOT EXISTS curList (id INTEGER PRIMARY KEY AUTOINCREMENT , queNum TEXT UNIQUE NOT NULL , title TEXT )
9}
10
11on *:JOIN:# {
12 var %table2 = INSERT INTO nicks (nick,last) values(" $+ $nick $+ ","dash")
13 var %request2 = $sqlite_query(%jukebox_ctl_db, %table2)
14 if (!%request2) {
15 echo 4 -a Error: %sqlite_errstr
16 return
17 }
18}
19
20
21
22alias putQue {
23 var %x = 1
24 var %lLength = $dll(ac,meval,var_ll)
25 while (%x <= %lLength) {
26 var %safe_title = $sqlite_escape_string($dll(ac,meval,title %x))
27 ; UPDATE or REPLACE curList set queNum,title = %x,%safe_title WHERE title LIKE %safe_title
28 sqlite_exec %jukebox_ctl_db REPLACE INTO curList (queNum, title) VALUES (' $+ %x $+ ', ' $+ %safe_title $+ ')
29 echo 3 -a added track: %x set title to %safe_title
30 inc %x
31 }
32}
33
34
35alias dbNext5 {
36 if (!%jukebox_ctl_db) { return }
37 var %xcnt = 1
38 while ( %xcnt <= 5 ) {
39 ;//echo 3 -a SELECT title FROM curList WHERE queNum = ' $+ $queue(playqueue,[ $+ [ %xcnt ] ]) $+ '
40 var %sql = SELECT title FROM curList WHERE queNum = ' $+ $queue(playqueue,[ $+ [ %xcnt ] ]) $+ '
41 var %request = $sqlite_query(%jukebox_ctl_db, %sql)
42 if (!%request) {
43 echo 4 -a Error: %sqlite_errstr
44 return
45 }
46
47 if ($sqlite_num_rows(%request)) {
48 set %title [ $+ [ %xcnt ] ] $sqlite_fetch_single(%request)
49 //echo %title [ $+ [ %xcnt ] ]
50 }
51 inc %xcnt
52 }
53
54
55 sqlite_free %request
56 if ($queue(playqueue).len >= 5) {
57 msg %jukebox.chan There are $queue(playqueue).len Titles in the queue - The next 5 titles: 1.< $+ %title1 $+ > 2.< $+ %title2 $+ > 3.< $+ %title3 $+ > 4.< $+ %title4 $+ > 5.< $+ %title5 $+ >
58 }
59
60 elseif ($queue(playqueue).len >= 4) {
61 msg %jukebox.chan The next 4 titles: 1.< $+ %title1 $+ > 2.< $+ %title2 $+ > 3.< $+ %title3 $+ > 4.< $+ %title4 $+ >
62 }
63
64 elseif ($queue(playqueue).len >= 3) {
65 msg %jukebox.chan The next 3 titles: 1.< $+ %title1 $+ > 2.< $+ %title2 $+ > 3.< $+ %title3 $+ >
66 }
67
68 elseif ($queue(playqueue).len >= 2) {
69 msg %jukebox.chan The next 2 titles: 1.< $+ %title1 $+ > 2.< $+ %title2 $+ >
70 }
71
72 elseif ($queue(playqueue).len >= 1) {
73 msg %jukebox.chan The next 1 titles: 1.< $+ %title1 $+ >
74 }
75
76 elseif ($queue(playqueue).len >= 0) {
77 msg %jukebox.chan Random Play - Play Queue is empty, use !playq to add titles. | halt
78 }
79
80
81
82}
83
84alias playlistman {
85 if (!%jukebox_ctl_db) { return }
86 var %opts = $strip($1)
87 var %unick = $strip($2)
88 var %plist = $strip($3-)
89 var %ltitle = $opt
90
91 if (%opts == add) {
92 var %sql = SELECT title FROM curList WHERE queNum = ' $+ $queue(playqueue,[ $+ [ %xcnt ] ]) $+ '
93 }
94 elseif (%opts == del) {
95 }
96 elseif (%opts == rename) {
97 }
98 elseif (%opts == queue) {
99 }
100 elseif (%opts == list) {
101 var %sql = SELECT list FROM plists WHERE nick = ? AND ltitle = ?
102 var %result = $sqlite_query(%jukebox_ctl_db, %sql, %unick, %ltitle)
103 %cplist = $sqlite_fetch_single(%result)
104 var %theRendList = $plistRend(%cplist)
105 //echo 3 -a the list named ( $+ %ltitle $+ ) contains the following films: %theRendList
106 }
107
108 else {
109 }
110}
111
112alias plistRend {
113 if (!%jukebox_ctl_db) { return }
114 var %theNumbers = $1-
115 var %xcnt = 1
116 while ( %xcnt <= 5 ) {
117 ;//echo 3 -a SELECT title FROM curList WHERE queNum = ' $+ $gettok(%theNumbers,[ $+ [ %xcnt ] ],32) $+ '
118 var %sql = SELECT title FROM curList WHERE queNum = ' $+ $gettok(%theNumbers,[ $+ [ %xcnt ] ],32) $+ '
119 var %request = $sqlite_query(%jukebox_ctl_db, %sql)
120 if (!%request) {
121 echo 4 -a Error: %sqlite_errstr
122 return
123 }
124
125 if ($sqlite_num_rows(%request)) {
126 set %title [ $+ [ %xcnt ] ] $sqlite_fetch_single(%request)
127 //echo %title [ $+ [ %xcnt ] ]
128 }
129 inc %xcnt
130 }
131var %finRes = 1.< $+ %title1 $+ > 2.< $+ %title2 $+ > 3.< $+ %title3 $+ > 4.< $+ %title4 $+ > 5.< $+ %title5 $+ >
132//echo 7 -a %finRes
133return %finRes
134}