PtokaX forum

Archive => Archived 5.1 boards => Help with scripts => Topic started by: ZandPilooT on 20 December, 2007, 15:29:05

Title: Winamp
Post by: ZandPilooT on 20 December, 2007, 15:29:05
I downloaded a winamp script and it's real nice  :)
But when I terminate the script, the bot stays listed in the users list. Can that be fixed? If I knew more about lua I would try it myself.

Merry Christmas to all and here's the code from the script I downloaded:
-- Shoutcast interface through PtokaX script
-- Author: RabidWombat
-- Requirements: the winamp source of the shoutcast server
-- is running on the hub server where this script is AND
-- you have installed Clever (a GREAT utility)
-- This is the version I downloaded for testing purposes
-- http://www.jukkis.net/clever/clever_2_98.zip
-- This is site for all offered versions:
-- http://www.jukkis.net/
--//Modded By Madman
--//Added !sc.song
--//Guide Added
--//More Stuff Added
--//Even More On Ubikk's Request ;p
--//Further modded by Madman Quattro and Pothead
--//Added Myinfostring and some modifications... (thanks to Madman and Pothead)
--//Added A Switch For The Tag
--//Added AllowedProfiles
--//Removed AllowedProfiles
--//Request By Quattro
--//Added RoboCop Profiles Support, The Higer Profile, More Commands
--//Converted to lua 5 by Madman
--//Thanks Typhoon for help with file handling

-- Guide So You Can Add The Commands You Wish
--------------------------------------------------------------------------------------
-- os.execute(sCleverDir.."clever.exe prev"); --//Play Previous Song
-- os.execute(sCleverDir.."clever.exe alwaysontop"); --//Toggle Always On Top
-- os.execute(sCleverDir.."clever.exe pause"); --//Pauses
-- os.execute(sCleverDir.."clever.exe stop"); --//Stops
-- os.execute(sCleverDir.."clever.exe next"); --//Play Next Song
-- os.execute(sCleverDir.."clever.exe volup"); --//Increase The Volume
-- os.execute(sCleverDir.."clever.exe voldn"); --//Decrease The Volume
-- os.execute(sCleverDir.."clever.exe swshuffle"); --//Sets Shuffle On Off
-- os.execute(sCleverDir.."clever.exe swrepeat"); --//Sets Repet On Off
-- os.execute(sCleverDir.."clever.exe getshuffle > output.tmp"); --//Get Status on Shuffle
-- os.execute(sCleverDir.."clever.exe getrepeat > output.tmp"); --//Get Staus on Repeat
--------------------------------------------------------------------------------------
-- os.execute(sCleverDir.."clever.exe getinfo > output.tmp"); --//shows Info about the song
-- Example...
-- 44kHz      128kbps      Channels:2
--------------------------------------------------------------------------------------
-- os.execute(sCleverDir.."clever.exe GETINFO > output.tmp"); --//shows Info about the song
-- Example...
-- 044,128,2
--------------------------------------------------------------------------------------
-- os.execute(sCleverDir.."clever.exe prettyinfo > output.tmp"); --//Shows Pretty Info About The Song
-- Example..
-- Songname: Ramp - The Logical Song (Original Mix)
-- Time:    04:22 of 06:57 (02:35 left)
-- Status:  Playing
-- Shuffle: On
-- Repeat:  On
-- Playlist position 2 of 7 songs.
--------------------------------------------------------------------------------------
-- os.execute(sCleverDir.."clever.exe staus > output.tmp"); --//Shows Staus Of Winamp Ex. Play
-- os.execute(sCleverDir.."clever.exe songlength > output.tmp"); --//Total Length Of Song
-- os.execute(sCleverDir.."clever.exe timeleft > output.tmp"); --//Shows Timeleft
-- os.execute(sCleverDir.."clever.exe songtitle > output.tmp"); --//Shows The Song Title
-- os.execute(sCleverDir.."clever.exe visual"); --//Visualtion On Off
-- os.execute(sCleverDir.."clever.exe clear"); --//Clears The Playlist
-- os.execute(sCleverDir.."clever.exe playlist > output.tmp"); --//Show Playlist
-- os.execute(sCleverDir.."clever.exe play"); --//Start Play

sCleverDir = "D:\\Program\\clever\\";
--//If other then C:\CLEVER you have to create C:\CLEVER mannuly...
--It's for the settings file
--Also rember to run the clever.exe fil first... you need to configure it =)

sBotName = "-=Destruction=-"; --//The Bot Name
Wver = "2.91" --//What Version Of Winamp You Are Running
SendTag = 1 --//Should The Bot Have A Tag?

if SendTag == 1 then
BotEmail = "E-Mail?"
BotSpeed = "MusicFlys!"
BotDescr = "WinampScript!"
BotTag = "<Winamp V:"..Wver..",M:A,H:0/0/1,S:0>"
BotShare = 0
MyInfoString = "$MyINFO $ALL "..sBotName.." "..BotDescr.." "..BotTag.."$ $"..BotSpeed..string.char( 1 ).."$"..BotEmail.."$" ..BotShare.."$"
end

low = string.lower;

sHelpOutput = "Commands\r\n";
sOpHelpOutput = "Op Commands\r\n";
sModHelpOutput = "Moderator Commands\r\n";
sMasterHelpOutput = "Master Commands\r\n";
sFoundHelpOutput = "NetFounder Commands\r\n";

--For ShoutCastSong
Msg = "All People In Madman's Apartment Is Listening To" --Will show  "Msg songname"

function NewUserConnected(curUser)
if SendTag == 1 then
curUser:SendData(MyInfoString)
elseif SendTag == 0 then
end
end

OpConnected = NewUserConnected

function Main()
tCommands = {
--//Operator = 1
--//Moderator = 2
--//Master = 3
--//NetFounder = 4
--//All = 0
-- tCmd[1] tCmd[2] tCmd[3]
[low("!SC.next")] = { ShoutCastNext, 1, "Play next song in playlist" },
[low("!SC.prev")] = { ShoutCastPrev, 1, "Play prev song in playlist" },
[low("!SC.playlist")] = { ShoutCastPlayList, 0, "Display Playlist" },
[low("!SC.play")] = { ShoutCastPlay, 4, "Play" },
[low("!SC.pause")] = { ShoutCastPause, 4, "Pause" },
[low("!SC.stop")] = { ShoutCastStop, 4, "Stop" },
[low("!SC.status")] = { ShoutCastStatus, 0, "Display Status" },
[low("!SC.help")] = { ShoutCastHelp, 0, "Help Message" },
[low("!SC.song")] = { ShoutCastSong, 0, "SongTitle"},
[low("!SC.volup")] = { ShoutCastVolUp, 3, "Volume Up"},
[low("!SC.voldn")] = { ShoutCastVolDn, 3, "Volume Down"},
[low("!SC.playnr")] = { ShoutCastPlayNr, 3, "Play nr X track"},
[low("!SC.tracknr")] = { ShoutCastGetTrack, 2, "Get current song's track number"},
[low("!SC.vol")] = { ShoutCastVol, 2, "Set Volume 0-255"},
[low("!SC.volhelp")] = { ShoutCastVolHelp, 2, "Volume Help"},
[low("!SC.pretty")] = { ShoutCastPretty, 1, "Display Pretty info"},
-- [low("!SC.test")] = { ShoutCastTest, 1, "Test"},
-- [low("!SC.test2")] = { ShoutCastTest2, 1, "Test With Output.tmp"},
};

---------------Modded For Quattro
for sCmd, tCmd in tCommands do
if (tCmd[2] == 4) then
sFoundHelpOutput = sFoundHelpOutput..sCmd.."\t-\t"..tCmd[3].."\r\n";
elseif (tCmd[2] == 3)then
sMasterHelpOutput = sMasterHelpOutput..sCmd.."\t-\t"..tCmd[3].."\r\n";
elseif (tCmd[2] == 2) then
sModHelpOutput = sModHelpOutput..sCmd.."\t-\t"..tCmd[3].."\r\n";
elseif (tCmd[2] == 1) then
sOpHelpOutput = sOpHelpOutput..sCmd.."\t-\t"..tCmd[3].."\r\n";
elseif (tCmd[2] == 0) then
sHelpOutput = sHelpOutput..sCmd.."\t-\t"..tCmd[3].."\r\n";
end
end
---------------Modded For Quattro

frmHub:RegBot(sBotName);
if SendTag == 1 then
SendToAll(MyInfoString)
end
end

function ChatArrival(curUser, sData)
local s, e, cmd, args = string.find(sData, "%b<>%s+(%S+)%s*([^%|]*)%|$");
if(cmd == nil) then return 0; end
cmd = string.lower(cmd);
if(tCommands[cmd] and (tCommands[cmd][2] == 0 or curUser.bOperator )) then
curUser:SendData(sData);
tCommands[cmd][1](curUser, args);
return 1;
end
end

function ShoutCastPretty(curUser)
os.execute(sCleverDir.."clever.exe prettyinfo > output.tmp"); --//Shows Pretty Info About The Song
local file = io.input("output.tmp");
local line = io.read("*a");
if(line) then
line = string.gsub(line, "\n", "\r\n");
SendToAll(sBotName, "\r\n"..line);
end
file:read()
end

function ShoutCastVolUp(curUser)
os.execute(sCleverDir.."clever.exe volup"); --//Increase The Volume
curUser:SendData(sBotName, "Volume Increased")
end

function ShoutCastVol(curUser, args)
if(args and tonumber(args)) then
os.execute(sCleverDir.."clever.exe volume "..tonumber(args));
curUser:SendData(sBotName, "Volume Set To " ..args)
end
end

function ShoutCastVolDn(curUser)
os.execute(sCleverDir.."clever.exe voldn"); --//Decrease The Volume
curUser:SendData(sBotName, "Volume Decreased")
end

function ShoutCastVolHelp(curUser) --//Volume Help
if curUser.bOperator then
curUser:SendPM(sBotName,"\r\nVolume Help\r\n"..
"Write !sc.vol X\tX = Some Nr\n"..
"The Text Bellow Show What A Nr Is In Volume %\r\n"..
"10 = 3 %\r\n"..
"20 = 7 %\r\n"..
"30 = 11 %\r\n"..
"40 = 15 %\r\n"..
"50 = 19 %\r\n"..
"60 = 23 %\r\n"..
"70 = 27 %\r\n"..
"80 = 31 %\r\n"..
"90 = 35 %\r\n"..
"100 = 39 %\r\n"..
"110 = 43 %\r\n"..
"120 = 47 %\r\n"..
"130 = 50 %\r\n"..
"140 = 54 %\r\n"..
"150 = 58 %\r\n"..
"160 = 62 %\r\n"..
"170 = 66 %\r\n"..
"180 = 70 %\r\n"..
"190 = 74 %\r\n"..
"200 = 78 %\r\n"..
"210 = 82 %\r\n"..
"220 = 86 %\r\n"..
"230 = 90 %\r\n"..
"240 = 94 %\r\n"..
"250 = 98 %\r\n"..
"255 = 100 %\r\n");
end
end

function ShoutCastTest(curUser, args) --//For Testing
if(args and tonumber(args)) then
os.execute(sCleverDir.."clever.exe play "..tonumber(args));
end
end

function ShoutCastTest2(curUser) --//For Testing
os.execute(sCleverDir.."clever.exe -h > output.tmp");
local file = io.input("output.tmp");
local line = io.read("*a");
if(line) then
line = string.gsub(line, "\n", "\r\n");
curUser:SendData(sBotName, "\r\n"..line);
end
file:read()
end

function ShoutCastNext(curUser) --//Play Next Song
os.execute(sCleverDir.."clever.exe next");
end

function ShoutCastPrev()
os.execute(sCleverDir.."clever.exe prev"); --//Play Prev Song
end

function ShoutCastPlayNr(curUser, args)
if(args and tonumber(args)) then
os.execute(sCleverDir.."clever.exe play")
os.execute(sCleverDir.."clever.exe play "..tonumber(args));
os.execute(sCleverDir.."clever.exe songtitle > output.tmp");
local file = io.input("output.tmp");
local line = io.read("*a");
if(line) then
line = string.gsub(line, "\n", "");
SendToOps(sBotName, curUser.sName.." has selected track "..tonumber(args).." [ "..line.." ]");
end
file:read()
end
end

function ShoutCastPlayList(curUser) --//Show Playlist
os.execute(sCleverDir.."clever.exe playlist > output.tmp");
local file = io.input("output.tmp");
local line = io.read("*a");
if(line) then
line = string.gsub(line, "\n", "\r\n");
curUser:SendPM(sBotName, "\r\n"..line);
end
file:read()
end


function ShoutCastGetTrack(curUser) --//Get Track nr
os.execute(sCleverDir.."clever.exe getplpos > output.tmp");
local file = io.input("output.tmp");
local line = io.read("*a");
if(line) then
line = string.gsub(line, "\n", "");
curUser:SendData(sBotName, "Current song's track number is: [ "..line.." ]");
end
file:read()
end

function ShoutCastPlay()
os.execute(sCleverDir.."clever.exe play"); --//Play
end

function ShoutCastPause()
os.execute(sCleverDir.."clever.exe pause"); --//Pause
end

function ShoutCastStop()
os.execute(sCleverDir.."clever.exe stop"); --//Stop
end

function ShoutCastStatus(curUser)
os.execute(sCleverDir.."clever.exe status > output.tmp");
local file = io.input("output.tmp");
local line = io.read("*a");
if(line) then
line = string.gsub(line, "\n", "\r\n");
curUser:SendData(sBotName, "The status is: "..line);
end
file:read()
end

function ShoutCastSong(curUser) --//Playing Song
os.execute(sCleverDir.."clever.exe songtitle > output.tmp")
local file = io.input("output.tmp");
local line = io.read("*a");
if(line) then
SendToAll(sBotName, Msg.." "..line);
end
file:read()
end

function ShoutCastSongLength(curUser)
os.execute(sCleverDir.."clever.exe songlength > output.tmp"); --//Total Length Of Song
local file = io.input("output.tmp");
local line = io.read("*a");
if(line) then
line = string.gsub(line, "\n", "\r\n");
curUser:SendData(sBotName, "\r\n"..line);
end
file:read()
end

function ShoutCastTimeLeft(curUser)
os.execute(sCleverDir.."clever.exe timeleft > output.tmp"); --//Shows Timeleft
local file = io.input("output.tmp");
local line = io.read("*a");
if(line) then
line = string.gsub(line, "\n", "\r\n");
curUser:SendData(sBotName, "\r\n"..line);
end
file:read()
end

---------------Modded For Quattro
function ShoutCastHelp(curUser) --//Help
curUser:SendData(sBotName,
"\r\n"..sHelpOutput);
if curUser.iProfile == 5 then
curUser:SendData(sBotName,
"\r\n"..sFoundHelpOutput.."\r\n"..
"\r\n"..sMasterHelpOutput.."\r\n"..
"\r\n"..sModHelpOutput.."\r\n"..
"\r\n"..sOpHelpOutput);
elseif curUser.iProfile == 0 then
curUser:SendData(sBotName,
"\r\n"..sMasterHelpOutput.."\r\n"..
"\r\n"..sModHelpOutput.."\r\n"..
"\r\n"..sOpHelpOutput);
elseif curUser.iProfile == 4 then
curUser:SendData(sBotName,
"\r\n"..sModHelpOutput.."\r\n"..
"\r\n"..sOpHelpOutput);
elseif curUser.bOperator then
curUser:SendData(sBotName,
"\r\n"..sOpHelpOutput);
end
end
---------------Modded For Quattro