A Very Usefull Bot which are not in LUA as far as i know.
Sorry if it doesnt get listed right, it was pasted me in a PM, hope someone can make a LUA one.
what it does is to convert these:
' Supported conversations so far is:
'
' C temp Centigrade -> Farenheit
' F temp Farenheit -> Centigrade
' CM length Centimeter -> Inches
' IN length Inches -> Centimeter
' KM length Kilometers -> Miles
' MILES length Miles -> Kilometers
' LBS weight LBS --> KG
' KG weight KG --> LBS
' M3 volume M3 -> Cubic Ft
' CFT volume Cubic Ft -> M3
' EUR amount
' USD amount
' GBP amount
' SEK amount
' DKK amount
Roy
' The script is free to use and distibute in any form, modified or "as is".
'
' Story was that our hub have users from both side of the atlantic... and a friend
' of mine was sick, having fever.... well 102?F... wtf is that in ?C ???
' So... being the nice person i am, i found out the conversion formula for F -> C and
' vice versa and added that to our main bot script.
'
' Idea came right away to make this a little conversation utility and.... here it is.
'
' I guess i will add more functions in the future... if you add something usefull
' and care to contribute it to me, please send a mail to
'
' Supported conversations so far is:
'
' C temp Centigrade -> Farenheit
' F temp Farenheit -> Centigrade
' CM length Centimeter -> Inches
' IN length Inches -> Centimeter
' KM length Kilometers -> Miles
' MILES length Miles -> Kilometers
' LBS weight LBS --> KG
' KG weight KG --> LBS
' M3 volume M3 -> Cubic Ft
' CFT volume Cubic Ft -> M3
' EUR amount
' USD amount
' GBP amount
' SEK amount
' DKK amount
'
'
'------------------------------------------------------------------------------------------------
'
' Rates from http://www.forex.se
' Monetary.... Euro allways = 1, the rest is 1 euro = x.xxxx other currency
'
RateDate = "(Rates @ 2003-June-27)"
EUR = 1
USD = 1.1126
GBP = 0.6674
SEK = 9.0587
DKK = 7.2423
Dim sBotName
'
'
' Initiate script
'
Sub Main()
sBotName = "Convert" ' Bots Name (Showed in main msg)
frmHub.RegisterBotName(CStr(sBotName)) ' Reg the bot so it shows
End Sub
'
'
'
'
Sub DataArival(index,sCurData)
'
'
' Add a bot description, connection type and share amount
'
sReqdUsername = Split(sCurData, " ", 3)(1)
If CStr(sReqdUsername) = CStr(sBotName) Then
index.SendData CStr("$MyINFO $ALL " & sBotName & " -= Try 'Convert HELP' for commands =-$ $Bad" & Chr(1) & "$$1$|" )
End if
'
'
'
'
If isCommand(sCurData) Then
Exit Sub
End If
sCurData = UCase(sCurData)
sCurData = AfterFirst(sCurData,"> ")
If Left(sCurData,Len(sBotName)) = UCase(sBotName) Then
sCurData=AfterFirst(sCurData,UCase(sBotName))
sCurdata=Trim(sCurData)
If InStr(ScurData," ") Then
First = beforefirst(sCurData," ")
Last = afterfirst(sCurData," ")
if len(last) > 10 Then
msg sBotName,"Ease off will ya!!!"
exit sub
end if
ElseIf sCurData="?" or sCurdata="HELP" Then
msg sBotName,"Welcome to 'ConverterBot' !"
msg sBotName,"Supported conversions are......."
msg sBotName,CStr(sbotName)+" C "+vbTab+"Show temperature in Farenheit"
msg sBotName,CStr(sbotName)+" F "+vbTab+"Show temperature in Centigrade"
msg sBotName,CStr(sbotName)+" CM "+vbTab+"Show length in Inches."
msg sBotName,CStr(sbotName)+" IN "+vbTab+"Show length in Centimeters."
msg sBotName,CStr(sbotName)+" KM "+vbTab+"Show length in Miles."
msg sBotName,CStr(sbotName)+" MILES "+vbTab+"Show length in Kilometer."
msg sBotName,CStr(sbotName)+" LBS "+vbTab+"Show weight in Kilos."
msg sBotName,CStr(sbotName)+" KG "+vbTab+"Show weight in Lbs."
msg sBotName,CStr(sbotName)+" EUR "+vbTab+"Calculate currency from Euro."
msg sBotName,CStr(sbotName)+" SEK "+vbTab+"Calculate currency from Swedish Krona."
msg sBotName,CStr(sbotName)+" GBP "+vbTab+"Calculate currency from GB Pound."
msg sBotName,CStr(sbotName)+" USD "+vbTab+"Calculate currency from US Dollar."
msg sBotName,CStr(sbotName)+" DKK "+vbTab+"Calculate currency from Danish Krona."
Exit Sub
End If
'
'
'
'
Select Case First
'
'
' m3 --> Cubic Feet
'
Case "M3"
Result = (Last * 35.31)
msg sBotName,CStr(Last)+" M? equals "+Shape1(Result)+" FT?"
'
'
' Cubic Feet -> m3
'
Case "FT3"
Result = (Last * 0.02832)
msg sBotName,CStr(Last)+" FT? equals "+ Shape1(Result) +" M?"
'
' Monetary...
' DKK
'
Case "DKK"
Result1 = Last / DKK
Result2 = (Last / DKK) * USD
Result3 = (Last / DKK) * GBP
Result4 = (Last / DKK) * SEK
msg sBotName,CStr(Last)+" DKK equals "+Shape2(Result1)+" Euro, "+Shape2(Result2)+" USD, "+Shape2(Result3)+" GBP, "+Shape2(Result4)+" SEK. "+RateDate
'
' Monetary...
' SEK
'
Case "SEK"
Result1 = Last / SEK
Result2 = (Last / SEK) * USD
Result3 = (Last / SEK) * GBP
Result4 = (Last / SEK) * DKK
msg sBotName,CStr(Last)+" SEK equals "+Shape2(Result1)+" Euro, "+Shape2(Result2)+" USD, "+Shape2(Result3)+" GBP, "+Shape2(Result4)+" DKK. "+RateDate
'
' Monetary...
' USD
'
Case "USD"
Result1 = Last / USD
Result2 = (Last / USD) * SEK
Result3 = (Last / USD) * GBP
Result4 = (Last / USD) * DKK
msg sBotName,CStr(Last)+" USD equals "+Shape2(Result1)+" Euro, "+Shape2(Result2)+" SEK, "+Shape2(Result3)+" GBP, "+Shape2(Result4)+" DKK. "+RateDate
'
' Monetary...
' GBP
'
Case "GBP"
Result1 = Last / GBP
Result2 = (Last / GBP) * SEK
Result3 = (Last / GBP) * USD
Result4 = (Last / GBP) * DKK
msg sBotName,CStr(Last)+" GBP equals "+Shape2(Result1)+" Euro, "+Shape2(Result2)+" SEK, "+Shape2(Result3)+" USD, "+Shape2(Result4)+" DKK. "+RateDate
'
' Monetary...
' EUR
'
Case "EUR"
Result1 = Last * GBP
Result2 = Last * SEK
Result3 = Last * USD
Result4 = Last * DKK
msg sBotName,CStr(Last)+" EUR equals "+Shape2(Result1)+" GBP, "+Shape2(Result2)+" SEK, "+Shape2(Result3)+" USD, "+Shape2(Result4)+" DKK. "+RateDate
'
'
' LBS --> Kg
'
Case "LBS"
Result = Last * 0.4536
msg sBotName,CStr(Last)+" Lbs equals "+Shape1(Result)+" Kilos"
'
'
' Kg --> LBS
'
Case "KG"
Result = Last * 2.205
msg sBotName,CStr(Last)+" Kilos equals "+Shape1(Result)+" Lbs"
'
'
' miles --> km
'
Case "MILES"
Result = Last * 1.6093
msg sBotName,CStr(Last)+" miles equals "+Shape1(Result)+" kilometers"
'
'
' km --> miles
'
Case "KM"
Result = Last / 1.6093
msg sBotName,CStr(Last)+" kilometers equals "+Shape1(Result)+" miles"
'
'
' cm --> foot
'
Case "CM"
Result = (Last / 2.54)/12
If Result < 12 Then
msg sBotName,CStr(Last)+" centimeters equals "+Shape1(Result*12)+" inch"
Else
msg sBotName,CStr(Last)+" centimeters equals "+Shaep2(Result)+" foot"
End If
'
'
' inches --> cm
'
Case "IN"
Result = Last * 2.54
msg sBotName,CStr(Last)+" inches equals "+Shape1(Result)+" centimeters"
'
' Convert from C --> F
'
Case "C"
Result = Last * (9/5) + 32
msg sBotName,CStr(Last)+"?C equals "+Shape1(Result)+"?F"
'
' Convert from F --> C
'
Case "F"
Result = (Last-32) * (5 / 9)
msg sBotName,CStr(Last)+"?F equals "+Shape1(Result)+"?C"
Case Else
msg sBotname,"Sorry, don't know that one or a parameter is missing...."
msg sBotname,"Type "+CStr(sBotName)+" ? to get a list of available commands."
End Select
End If
End Sub
'
'
' Formatera med 1 decimal
'
Function Shape1(Result)
N = CStr(Result+0.05)
If InStr(N, ".") Then 'If decimals
N2 = AfterFirst(N,".")
If Len(N2) > 1 Then '1 decimal
N = BeforeFirst(N,".") + "." + Left(N2,1)
End If
Else
N = N + ".0"
End If
Shape1 = N
End Function
'
'
' Formatera med 2 decimaler
'
Function Shape2(Result)
N = CStr(Result)+0.000001
If InStr(N, ".") Then 'If decimals
N2 = AfterFirst(N,".")
If Len(N2) > 2 Then '2 decimaler
N = BeforeFirst(N,".") + "." + Left(N2,2)
End If
End If
Shape2 = N
End Function
'
'
' Just send sMessage to main chat
'
SUB Debug(sMessage)
colUsers.SendChatToAll Cstr("Debug---"),cStr(sMessage)
End SUB
'
' Send a mMessage from sFrom to main chat
'
SUB Msg(sFrom,sMessage)
colUsers.SendChatToAll Cstr(sFrom),cStr(sMessage)
End SUB
Function isCommand(sData)
isCommand=(Left(sData,1)="$")
End Function
Function BeforeFirst(sIn,sFirst)
BeforeFirst=Left(sIn,InStr(1,sIn,sFirst)-1)
End Function
Function AfterFirst(sIn,sFirst)
AfterFirst=Right(sIn,Len(sIn)-InStr(1,sIn,sFirst)-(Len(sFirst)-1))
End Function
Function mbOrGb(iShare)
If iShare < 1024^4 then
mbOrGb=CStr(CCur(iShare/1024^3))+" GB"
Else
mbOrGb=CStr(CCur(iShare/1024^4))+" TB"
End If
End Function
Is this bot possible to make in LUA or not ?(
Would be nice with a yes/no answer
Thanks in advance
Roy
:)
If you give me all i need i can make one for you...
i will need to know how to calculate from C to F for instance :)
Bot = "lol"
function DataArrival(user, data)
if strsub(data,1,1) == "<" or strsub(data,1,4) == "$To:" then
data=strsub(data,1,strlen(data)-1)
s,e,cmd,celcius = strfind(data,"%b<>%s+(%S+)%s+(%d+)")
if user.iProfile == 0 or user.iProfile == 1 then
result = celcius * 9 / 5 +32 --- From C to F
if cmd=="+calc" then
SendData(Bot, ""..celcius.." Celcius = "..result.." Fahrenheit") return 1
end
end
end
end
This is just a test, and it works, But, after a while i get a syntax error...
I found a way to calculate From Celcius to Fahrenheit
on internet..
So it's not to hard
all the answers are in that script wich roy posted.
i'll give some hints, remove the pm part for a while and move the calculation 2 the senddata line.
and i think everybody has the right 2 use the bot. lol
you can remove the level check.
plop
:) Im glad you exist Plop :D
I will work on it a lill bit tomorow, too tired now!
Just a little update :)
Bot = "lol" -<---- BotName here
function DataArrival(user, data)
if (strsub(data,1,1) == "<") then
data=strsub(data,1,strlen(data)-1)
s,e,cmd,celcius = strfind(data,"%b<>%s+(%S+)%s+(%d+)")
if (cmd=="?f") then
user:SendData(Bot, ""..format("%0.2f", celcius * 9 / 5 +32)) return 1
elseif cmd=="?km" then
user:SendData(Bot, ""..format("%0.2f", celcius * 1.6093)) return 1
elseif cmd=="?miles" then
user:SendData(Bot, ""..format("%0.2f", celcius / 1.6093)) return 1
elseif cmd=="?lbs" then
user:SendData(Bot, ""..format("%0.2f", celcius * 2.205)) return 1
elseif cmd=="?kg" then
user:SendData(Bot, ""..format("%0.2f", celcius * 0.4536)) return 1
elseif cmd=="?cm" then
user:SendData(Bot, ""..format("%0.2f", celcius * 2.54)) return 1
elseif cmd=="?foot" then
user:SendData(Bot, ""..format("%0.2f", celcius / 2.54 / 12)) return 1
elseif (cmd=="?help") then
user:SendData("\tWelcome to The Converter bot!")
user:SendData("You want to convert C to Farenheit? No Problem...")
user:SendData("Available commands:")
user:SendData("?f\t\t \t(Will convert From C To Farenheit)")
user:SendData("?km\t \t(Will convert From Miles To Kilometer/s)")
user:SendData("?miles\t \t(Will convert From Kilometer/s To Mile/s)")
user:SendData("?lbs\t \t(Will convert From Kilos To LBS)")
user:SendData("?kg\t \t(Will convert From LBS To Kilo/s)")
user:SendData("?cm\t \t(Will convert From Inch To CentiMeter/s)")
user:SendData("?foot\t \t(Will convert From Cm To Foot/s)")
user:SendData("Enjoy") return 1
end
end
end
gogogogogo kepp, looking good.
just a couple remarks.
%s means 1 space
%s+ means 1 or more spaces
%s* means 0 or more spaces (returns "" if 0 are found)
this should help you inprove the search string for the command/value.
might be an idea 2 rename celcius 2 something like arg or value, makes it easyer for you later or other ppl now 2 see what your doing.
you must agree that celcius looks a bit funny on calculating KG's 2 LBS. lol
finaly just a hint 2 make it look nicer.
give output like this.
2KG = xLBS
plop
cool to see you on it, I wanted to do it also.. but guess I'm too late.. well not quite .. unless.. you wann try to get current rates from the net like once a day.
I will leave that too you :P
QuoteOriginally posted by c h i l l a
cool to see you on it, I wanted to do it also.. but guess I'm too late.. well not quite .. unless.. you wann try to get current rates from the net like once a day.
cool idea, working 2gether can only make it better.
maby kepp can use a config file with the value's for the conversions.
you can then write a seperate script 2 update that config 1x a day.
and in the end fix those 2 2gether.
this way you won't get mixed up on eighothers updates aslong as kepp infroms you of new added value's.
just a quik idea maby you 2 can find a better/easyer way.
plop
--# Convertor Bot made by kepp
--# Once again, thanks Plop for great help
--# Enjoy..
--# And Enjoy
Bot = "lol" ----- BotName here
function GetArg(data)
s,e,cmd,arg = strfind(data,"%b<>%s(%S+)%s(%d+)")
return arg
end
function DataArrival(user, data)
if (strsub(data,1,1) == "<") then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"%b<>%s(%S+)")
if (cmd=="?f") then
arg = GetArg(data)
user:SendData(Bot, arg.." Celcius = "..format("%0.2f", arg * 9 / 5 +32).." Farenheit") return 1
elseif cmd=="?km" then
arg = GetArg(data)
user:SendData(Bot, arg.." Miles = "..format("%0.2f", arg * 1.6093).." Kilometers") return 1
elseif cmd=="?miles" then
arg = GetArg(data)
user:SendData(Bot, arg.." Kilometer/s = "..format("%0.2f", arg / 1.6093).." Mile/s") return 1
elseif cmd=="?lbs" then
arg = GetArg(data)
user:SendData(Bot, arg.." Kilos = "..format("%0.2f", arg * 2.205).." LBS") return 1
elseif cmd=="?kg" then
arg = GetArg(data)
user:SendData(Bot, arg.." LBS = "..format("%0.2f", arg * 0.4536).." Kilos") return 1
elseif cmd=="?cm" then
arg = GetArg(data)
user:SendData(Bot, arg.." Inch = "..format("%0.2f", arg * 2.54).." Centimeters") return 1
elseif cmd=="?foot" then
arg = GetArg(data)
user:SendData(Bot, arg.." Centimeters = "..format("%0.2f", arg / 2.54 / 12).." Foot") return 1
elseif (cmd=="?help") then
user:SendData("\tWelcome to The Converter bot!")
user:SendData("You want to convert C to Farenheit? No Problem...")
user:SendData("Available commands:")
user:SendData("?f\t\t \t(Will convert From C To Farenheit)")
user:SendData("?km\t \t(Will convert From Miles To Kilometer/s)")
user:SendData("?miles\t \t(Will convert From Kilometer/s To Mile/s)")
user:SendData("?lbs\t \t(Will convert From Kilos To LBS)")
user:SendData("?kg\t \t(Will convert From LBS To Kilo/s)")
user:SendData("?cm\t \t(Will convert From Inch To CentiMeter/s)")
user:SendData("?foot\t \t(Will convert From Cm To Foot/s)")
user:SendData("Enjoy") return 1
end
end
end
Output added,
Im not so sure if improved my string ?
Found a bug and and had to call the arg from GetArg(data)
*Edit*
:D
nearly there.
s,e,cmd = strfind(data,"%b<>%s*(%S+)")
between the and the text is always 1 space (unless ofcourse the user types in the useless extra space), so no need 2 search for 0-unbelievable much.
s,e,cmd,arg = strfind(data,"%b<>%s*(%S+)%s*(%d+)")
same goes here.
plus %S means everything but a space so searching for 0 spaces after it is not needed (it stops if it finds 1 space).
same change can be done here.
cmd can be removed totaly from the search as you allready know that 1 and don't return it from the function.
output looks good, great job on that.
plop
As you said, it will search for 0 or more spaces with %s*
Now it only looks for 1 space
%s
Oh ya, if i remove cmd and it's string
i will get a syntax error when im doing the commands.
atempt to arithmetic arg/ or something..
so kepp what do you think of a little work together?
see I got the part with the currency actually the biggest part is done ::)), but its not to good looking, cause I needed to it via http.. dunno maybe someone knows a server where to get the currency, by simple socket connection...
well here is my part till now
--Exchange Test
GETHTML = "GET /d/EUR/table.html HTTP/1.1\r\nHost: [URL]www.x-rates.com\r\nUser-Agent:[/URL] Mozilla/4.0 (compatible; LUA 4.0; LUA 4.0)\r\n"
--10 USD to EUR = 10/USD-EUR == EUR
MainCurrency = "EUR"
FindRates = {
{ "American Dollar ","USD" },
{ "Australian Dollar ","AUD" },
{ "Botswana Pula ","BWP" },
{ "Brazilian Real ","BRL" },
{ "British Pound ","GBP" },
{ "Canadian Dollar ","CAD" },
{ "Chinese Yuan ","CNY" },
{ "Danish Krone ","DKK" },
{ "Hong Kong Dollar ","HKD" },
{ "Hungarian Forint ","HUF" },
{ "Indian Rupee ","INR" },
{ "Japanese Yen ","JPY" },
{ "Malaysian Ringgit ","MYR" },
{ "Mexican Peso ","MXN" },
{ "New Zealand Dollar ","NZD" },
{ "Norwegian Kroner ","NOK" },
{ "Singapore Dollar ","SGD" },
{ "South African Rand ","ZAR" },
{ "South Korean Won ","KRW" },
{ "Sri Lanka Rupee ","LKR" },
{ "Swedish Krona ","SEK" },
{ "Swiss Franc ","CHF" },
{ "Taiwan Dollar ","TWD" },
{ "Thai Baht ","THB" },
{ "Venezuelan Bolivar ","VEB" },
}
curRates = {}
function GetRates()
socket, e = connect("www.x-rates.com", 80)
if not e then
local line = ""
socket:timeout(2)
socket:send(GETHTML..strchar(13,10))
while not e do
line1,e = socket:receive("*l")
foreachi(FindRates, function(a,b)
if strfind(line1, b[1]) then
for i = 1,2 do
line2,e = socket:receive("*l")
local _,_,num = strfind(line2,">(%S+)")
if i == 1 then
curRates[b[2].."-"..MainCurrency] = tonumber(num)
elseif i == 2 then
curRates[MainCurrency.."-"..b[2]] = tonumber(num)
end
end
end
end)
end
socket:close()
print(e)
for i,v in curRates do
print(i.." "..v)
end
end
end
GetRates()
Hi there,
Looks good.. how long do i have to wait 4 the final script ?? :D
I'd like to test it.....
Greez Event_Horizon
hmm dunno... well then I'll just try to merge em'.
I have no idea what to do....
:)
i had to do it my way :)
--Exchange-Converter V.1 by kepp, chill others
GETHTML = "GET /d/EUR/table.html HTTP/1.1\r\nHost: [URL]www.x-rates.com\r\nUser-Agent:[/URL] Mozilla/4.0 (compatible; LUA 4.0; LUA 4.0)\r\n"
--10 USD to EUR = 10/USD-EUR == EUR
bot1 = "Converter"
EPrefix = "%!%+%-%?"
MainCurrency = "EUR"
cmd1 = "changehelp"
cmd2 = "change"
cmd3 = "converthelp"
cmd4 = "convert"
Converters = {
["?F-?C"] = "([x]-32)*5/9",
["?C-?F"] = "[x]*5/9+32",
["IN-CM"] = "[x]*2.54",
["CM-IN"] = "[x]/2.54",
["FT-CM"] = "[x]*2.54*12",
["CM-FT"] = "[x]/(2.54*12)",
["MI-CM"] = "[x]*1.6093*1000*100",
["CM-MI"] = "[x]/(1.6093*1000*100)",
["KM-CM"] = "[x]*1000*100",
["CM-KM"] = "[x]/(1000*100)",
["M-CM"] = "[x]*100",
["CM-M"] = "[x]/100",
["LBS-KG"] = "[x]*0.4536",
["KG-LBS"] = "[x]/0.4536",
}
convhelp = "\tMiles = MI\r\n"..
"\tFoot = FT\r\n"..
"\tInch = IN\r\n"..
"\tCentimeter = CM\r\n"..
"\tMeter = M\r\n"..
"\tKilometer = KM\r\n"..
"\tPound = LBS\r\n"..
"\tKilogramms = KG\r\n"..
"\tFahrenheit = ?F\r\n"..
"\tCelsius = ?C\r\n"
FindRates = {
{ "American Dollar ","USD" },
{ "Australian Dollar ","AUD" },
{ "Botswana Pula ","BWP" },
{ "Brazilian Real ","BRL" },
{ "British Pound ","GBP" },
{ "Canadian Dollar ","CAD" },
{ "Chinese Yuan ","CNY" },
{ "Danish Krone ","DKK" },
{ "Hong Kong Dollar ","HKD" },
{ "Hungarian Forint ","HUF" },
{ "Indian Rupee ","INR" },
{ "Japanese Yen ","JPY" },
{ "Malaysian Ringgit ","MYR" },
{ "Mexican Peso ","MXN" },
{ "New Zealand Dollar ","NZD" },
{ "Norwegian Kroner ","NOK" },
{ "Singapore Dollar ","SGD" },
{ "South African Rand ","ZAR" },
{ "South Korean Won ","KRW" },
{ "Sri Lanka Rupee ","LKR" },
{ "Swedish Krona ","SEK" },
{ "Swiss Franc ","CHF" },
{ "Taiwan Dollar ","TWD" },
{ "Thai Baht ","THB" },
{ "Venezuelan Bolivar ","VEB" },
}
curday = 0
curRates = {}
dofile("txt/curRates.txt")
hour = 1000*60*60
function Main()
SetTimer(hour)
StartTimer()
local var = 0
for i,_ in curRates do
var = var + 1
if var == 1 then
break
end
end
if var == 0 then
GetRates()
end
end
function DataArrival(curUser,data)
if (strsub(data,1,1) == "<") then
data = strsub(data,1,strlen(data)-1)
local _,_,cmd = strfind( data, "%b<>%s["..EPrefix.."](%S+)" )
if not cmd then
return 0
end
if (strlower(cmd) == strlower(cmd1)) then
local curhelp = ""
for i,_ in FindRates do
curhelp = curhelp.."\tCurrency: "..strsub(FindRates[i][1],1,strlen(FindRates[i][1])-5).." Shorten: "..FindRates[i][2].."\r\n"
end
curUser:SendData(bot1,"Prefixa = + - ! ?\r\n\r\n"..
"\tSyntax: \""..cmd2.."\" [Amount] [CurrentCurrency] [WantedCurrrency]\r\n\r\n"..
"\tAvailable Currencies =\r\n\r\n"..curhelp)
return 1
elseif (strlower(cmd) == strlower(cmd2)) then
local _,_,str1,str2,str3 = strfind(data,"%b<>%s+%S+%s+(%S+)%s+(%S+)%s+(%S+)")
if tonumber(str1) then
str2, str3 = strupper(str2),strupper(str3)
if curRates[str2.."-"..str3] then
local change = format("%0.2f",tonumber(str1)/curRates[str2.."-"..str3])
curUser:SendData(bot1,str1.." "..str2.." = "..change.." "..str3)
elseif tonumber(str1) and curRates[str2.."-"..MainCurrency] and curRates[MainCurrency.."-"..str3] then
local change = format("%0.2f",tonumber(str1)/(curRates[str2.."-"..MainCurrency]*curRates[MainCurrency.."-"..str3]))
curUser:SendData(bot1,str1.." "..str2.." = "..change.." "..str3)
end
else
curUser:SendData(bot1,"Syntax: Prefixa \""..cmd2.."\" [Amount] [CurrentCurrency] [WantedCurrrency], Prefixa = + - ! ?")
end
return 1
elseif (strlower(cmd) == strlower(cmd3)) then
curUser:SendData(bot1,"Syntax: Prefixa \""..cmd4.."\" [Number] [CurrentValue] [WantedValue], Prefixa = + - ! ?\r\n\r\n"..convhelp)
elseif (strlower(cmd) == strlower(cmd4)) then
local _,_,str1,str2,str3 = strfind(data,"%b<>%s+%S+%s+(%S+)%s+(%S+)%s+(%S+)")
if tonumber(str1) then
str2, str3 = strupper(str2),strupper(str3)
conv = ""
if Converters[str2.."-"..str3] then
local x = gsub(Converters[str2.."-"..str3],"%b[]",str1)
dostring("conv="..x)
curUser:SendData(bot1,str1.." "..str2.." = "..conv.." "..str3)
elseif tonumber(str1) and Converters[str2.."-CM"] and Converters["CM-"..str3] then
local x1 = gsub(Converters[str2.."-CM"],"%b[]",str1)
dostring("conv="..x1)
local x2 = gsub(Converters["CM-"..str3],"%b[]",conv)
dostring("conv="..x2)
curUser:SendData(bot1,str1.." "..str2.." = "..conv.." "..str3)
end
else
curUser:SendData(bot1,"Syntax: Prefixa \""..cmd4.."\" [Number] [CurrentValue] [WantedValue], Prefixa = + - ! ?")
end
return 1
end
end
end
----------------------------------------------------------------------------------------------------------------------------------------------
function OnTimer()
if tonumber(date("%d")) ~= curday then
curday = tonumber(date("%d"))
GetRates()
end
end
----------------------------------------------------------------------------------------------------------------------------------------------
function WriteFile(table,tablename,file)
local handle = openfile("txt/"..file,"w")
Serialize(table,tablename,handle)
if table == curRates then
write(handle,"\r\ncurday = "..curday)
end
closefile(handle)
end
----------------------------------------------------------------------------------------------------------------------------------------------
function Serialize(tTable,sTableName,hFile,sTab)
sTab = sTab or "";
write(hFile,sTab..sTableName.." = {\n");
for key,value in tTable do
local sKey = (type(key) == "string") and format("[%q]",key) or format("[%d]",key);
if(type(value) == "table") then
Serialize(value,sKey,hFile,sTab.."\t");
else
local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
write(hFile,sTab.."\t"..sKey.." = "..sValue);
end
write(hFile,",\n");
end
write(hFile,sTab.."}");
end
----------------------------------------------------------------------------------------------------------------------------------------------
function GetRates()
curRates = {}
socket, e = connect("www.x-rates.com", 80)
if not e then
local line = ""
socket:timeout(2)
socket:send(GETHTML..strchar(13,10))
while not e do
line1,e = socket:receive("*l")
foreachi(FindRates, function(a,b)
if strfind(line1, b[1]) then
for i = 1,2 do
line2,e = socket:receive("*l")
local _,_,num = strfind(line2,">(%S+)")
if i == 1 and tonumber(num) then
curRates[b[2].."-"..MainCurrency] = tonumber(num)
elseif i == 2 and tonumber(num) then
curRates[MainCurrency.."-"..b[2]] = tonumber(num)
end
end
end
end)
end
socket:close()
WriteFile(curRates,"curRates","curRates.txt")
end
end
Mucho Nice :O
It's allways nice to see your work being appreciated, but you could have added some creds to little old me ;)
The original script is here: http://kotten.ath.cx
Some other old stuff there as well...
The hub is no more, so no reason to try and logon there.
'
' Converter script
'
' Author: Kotten, 2002-December-19
' HUB: dchub://wazoo.mine.nu [200GB min share]
' MSN: nospam@wazoo_hub@hotmail.com
'
' The script is free to use and distibute in any form, modified or "as is".
/Kotten
Hi Kotten,
Please check the Finished Scripts section :) Non here takes anyones credit.. Your name is mentioned there :)
Bye,
BlazeX
Hi there,
I'm not a scripter but i think the script from Kotten is a VB script....... ?(
Greez Event_Horizon
*****EDIT
I've checked the merged lua script & I get an error...
No syntax errors in script file H:\TEMP\DC tests\PtokaX HUB\scripts\converter.LUA
Syntax Error: bad argument #1 to `write' (string expected, got nil)
HELP !!!! 8o
Did you try C H I L L A S's?
Yes I tried CHILLAs Scrtipt.....
any ideas for solving ??
Greez Event_Horizon