Does anyone have somekind of birthday bot that sends out a message (txt/Ascii Pic or we) in Main, say every 2 hours telling who's birthday it is?
This Idea came up in a PN session and i think this would be quit fun.
yeah I had that Idea too awhile back .. I just needed some motivation ;)
--- BirthdayMan v 1 --- request by Psycho_Chihuahua
--- by Herodes 21/8/2004
--- --- --- --- --- --- --- --- --- --- --- ---
--- You need a file named like the ' birthlog ' variable (see below...) in your scripts folder ...
--- --- --- --- --- --- --- --- --- --- --- ---
sec = 1000 ----- do not edit this
minutes = 1000*60 ----- do not edit this
hours = 1000*(60^2) ----- do not edit this
TxtSend = nil ----- do not edit this
bBot = "Surprise"
timecheck = 12*hours --- how much time before checking for birthdays ...
tProfiles = { ---- profile rights to commands ... 1 can use listcmd and addcmd, 2 can also use delcmd ...
["0"] = 2, --- Masters ( ["profile_number"] = value (0/1/2)
["1"] = 2, --- Operators
["2"] = 1, --- VIPs
["3"] = 1, --- Regs
["-1"] = 0, --- Unregs
}
addcmd = "!mybirthday" --- usage : !mybirthday dd/mm/yyyy dd = the number date , mm = the number month , yyyy = the number year .... Sets your birthday!!!!
delcmd = "!delbirthday" --- usage : !delbirthday is needed ... deletes 's birthday from the list ...
listcmd = "!birthdays" --- usage : !birthdays Lists the birthdays stored ...
birthdayfile = "cake.txt" --- The file that will be displayed on Birthday ...
oldestyear = 1900 --- This is so that situations like !mybirthday 0/0/0000 are avoided ... lol
allowedage = 6 --- This is so that situations like !mybirthday are avoided ... in years ...
birthlog = "birthdays.tbl" --- The file where we'll be storing the birthdays ... <<< has to be in your scripts folder ...
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
----------------------------- S c r i p t - S t a r t s -----------------------------
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
tBirthdays = {}
tCalendar = {
[1] = { 31, "January", },
[2] = { 28, "February", },
[3] = { 31, "March", },
[4] = { 30, "April", },
[5] = { 31, "May", },
[6] = { 30, "June", },
[7] = { 31, "July", },
[8] = { 30, "August", },
[9] = { 31, "September", },
[10] = { 30, "October", },
[11] = { 31, "November", },
[12] = { 30, "December", },
}
function Main()
LoadFile(birthlog)
tCalendar[2][1] = FixFebruary(tonumber(date("%Y")))
local hr = tonumber(date("%H"))*60*60*1000
local mins = 0
if tonumber(date("%M")) == 0 then
mins = 1
else
mins = tonumber(date("%M"))*60*1000
end
fixTime(hr+mins)
end
function OnTimer()
CheckBirthdays()
end
function CheckBirthdays()
for i, v in tBirthdays do
if tBirthdays[i][2] == tonumber(date("%m")) then
if tBirthdays[i][1] == tonumber(date("%d")) then
if GetItemByName(i) then
happy = GetItemByName(i)
DoHappyBirthday(happy)
end
end
end
end
end
function fixTime(now)
if now < timecheck then
now = timecheck-now
elseif now > timecheck then
now = now-timecheck
else
now = timecheck
end
SetTimer(now)
StartTimer()
end
function DataArrival(user, data)
if tProfiles[""..user.iProfile..""] ~= 0 then
if strsub(data, 1,1) == "<" then
data = strsub(data, 1, strlen(data)-1)
local s,e,cmd,args = strfind(data, "%b<>%s+(%S+)%s*(.*)")
if cmd == addcmd and tProfiles[""..user.iProfile..""] >= 1 then
if args ~= nil then
s,e,day,month,year = strfind(args, "(%d+)/(%d+)/(%d+)")
if month ~= nil and day ~= nil and year ~= nil and (tonumber(month) => 1) and (tonumber(month) <= 12) then
day = tonumber(day)
month = tonumber(month)
year = tonumber(year)
if year > oldestyear then
if year < (tonumber(date("%Y")) - allowedage) then
if month == 2 then
daylimit = FixFebruary(year)
else
daylimit = tCalendar[month][1]
end
if day <= daylimit and day >= 1 then
if tBirthdays[user.sName] then
month = tBirthdays[user.sName][2]
user:SendData(bBot, "I have your birthday already ... they are on "..tBirthdays[user.sName][1].." of "..tCalendar[month][2])
local profstr = ""
for i,v in tProfiles do
if tProfiles[i] == 2 then
profstr = GetProfileName(tonumber(i)).."s"
break
end
end
user:SendData(bBot, "If you dont think this is correct ... then talk to one of our "..profstr)
else
tBirthdays[user.sName] = {}
tBirthdays[user.sName][1] = day
tBirthdays[user.sName][2] = month
tBirthdays[user.sName][3] = year
SaveFile(tBirthdays , "tBirthdays", birthlog)
user:SendData(bBot, "Your birthday are on the "..tBirthdays[user.sName][1].." of "..tCalendar[month][2])
user:SendData(bBot, "I didnt know you were "..( tonumber(date("%Y"))-tBirthdays[user.sName][3] )..". I'll keep that in mind ;)")
end
end
else user:SendData(bBot, "Come ON! you cant be less than "..allowedage.." years old !!! LIAR >:(")
end
else user:SendData(bBot, "Come ON! you cant be more than "..(year-oldestyear).." years old !!! LIAR >:(")
end
else user:SendData(bBot, "The date you provided was not valid ... ( syntax example : 14/5/1981 )")
end
else user:SendData(bBot , "Please enter your birthday after the command ...")
end
return 1
elseif cmd == delcmd and tProfiles[""..user.iProfile..""] == 2 then
if args ~= nil then
if tBirthdays[args] then
if GetItemByName(args) then
nick = GetItemByName(args)
nick:SendPM(bBot, user.sName.." has deleted your birthday from my list .. ;(")
end
tBirthdays[args] = nil
user:SendData(bBot, "You deleted "..args.." bithday ...")
SaveFile(tBirthdays , "tBirthdays", birthlog)
else
user:SendData(bBot, args.." is not in my birthday list ...")
end
else user:SendData(bBot , "You need to give me a name ...")
end
return 1
elseif cmd == listcmd and tProfiles[""..user.iProfile..""] >= 1 then
local msg = "\r\n\t\tThe Birthday List of the users of this hub\r\n\t"
local c = 0
local status = ""
for i, v in tBirthdays do
if GetItemByName(i) then
status = "online"
else status = "offline"
end
c = c + 1
msg = msg..c..". - "..tBirthdays[i][1].."/"..tBirthdays[i][2].."/"..tBirthdays[i][3].." - \t"..i.."\t ( "..status.." )\r\n"
end
user:SendData(bBot , msg)
return 1
end
end
end
end
function FixFebruary(y)
local value = 0
if (tonumber(y)/4) - (floor(tonumber(y)/4)) == 0 then
value = 29
else
value = 28
end
return value
end
function HappyBirthday(nick)
if TxtSend == nil then
SendToAll(ReadTextFile(birthdayfile))
TxtSend = 1
end
SendToAll( bBot , " I think Mr"..nick.sName.." has his birthday today ... he should be turning "..( tonumber(date("%Y"))-tBirthdays[user.sName][3] ).." today ;D")
end
--- // --- Table Serialization ( part 1/3 ) ? creating input ? --- Thanks Ninghtlitch for providing this to me
function Serialize(savTable, sTableName, hFile, sTab)
assert(savTable, "savTable equals nil");
assert(sTableName, "sTableName equals nil");
assert(hFile, "hFile equals nil");
assert(type(savTable) == "table", "savTable must be a table!");
assert(type(sTableName) == "string", "sTableName must be a string!");
sTab = sTab or "";
write(hFile, sTab..sTableName.." = {\n" );
for key, value in savTable 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
--- // --- Table Serialization ( part 2/3 ) ? Loading from file ?
function LoadFile(file)
assert(readfrom(file),file.." is not found.")
dostring(read("*all"))
readfrom()
end
--- // --- Table Serialization ( part 3/3 ) ? Saving to file ?
function SaveFile(table , tablename, file)
local hFile = openfile(file, "w");
Serialize(table, tablename, hFile);
closefile(hFile);
end
function ReadTextFile(file)
local message = "\r\n"
readfrom(file, "r")
while 1 do
local line = read()
if ( line == nil ) then break
else message = message.."\t"..line.."\r\n"
end
end
readfrom()
return message
end
Try this .. I haven't tested thoroughly ...
Works fine sofar Herodes :) thnx a lot m8
Hey that's a very nice script, I'll try it out :) Thx Herodes, glad u got motivated :D
Herodes, another update crossed my mind...
If your still motivated :D could u adapt it so that Admin's can insert Users Birthdays as well?
as in !userbirthday dd/mm/yyyy or something like that.
glad it works and thx for your good words ...
I'll see if I can get that request ...
First thought would be that I built on the !birthdays cmd ....
like so ...
!birthdays --- gives list of nicks ...
!birthdays --- adds birthday of ...
Herodes You make me proud as a new script writer who has only been with this forum from March this year. I have never really got down to it and learned LUa Scripting, but you are definately an insperation to us all with your ideas put to scripting and showing us your great scripts that have come to ur mind and given motivation from opther great members here.
Keep up the good work & I hope you come out with more great ideas for scripts and I hope the insperation continues on this forum as you have become a good script writer like our other great script writers here....
hi Herodes
i made some small changes i hope you dont mind.
--- BirthdayMan v 1 --- request by Psycho_Chihuahua
--- by Herodes 21/8/2004
--- --- --- --- --- --- --- --- --- --- --- ---
--- You need a file named like the ' birthlog ' variable (see below...) in your scripts folder ...
--- --- --- --- --- --- --- --- --- --- --- ---
--- Update
--- by Millsy 21/8/2004
--- Added profiles for Moderator and NetFounder (To work with robocop)
--- Made the birthday list look better
--- Now shows the birthday list in pm
--- Changed a few messages and some small mistakes
--- 22/8/2004
--- 2 Small fixes
--- Made the birthday list look even better ;)
--- Added request from T?M??r?V?ll?R
--- To sends a message to all when a user adds his/her birthday
--- 23/8/2004
--- Changed some more messages
--- --- --- --- --- --- --- --- --- --- --- ---
sec = 1000 ----- do not edit this
minutes = 1000*60 ----- do not edit this
hours = 1000*(60^2) ----- do not edit this
TxtSend = nil ----- do not edit this
bBot = "Birthday-Bot"
timecheck = 12*hours --- how much time before checking for birthdays ...
tProfiles = { ---- profile rights to commands ... 1 can use listcmd and addcmd, 2 can also use delcmd ...
["0"] = 2, --- Masters ( ["profile_number"] = value (0/1/2)
["1"] = 1, --- Operators
["2"] = 1, --- VIPs
["3"] = 1, --- Regs
["4"] = 1, --- Moderator ---- Remove this line if you dont use robocop
["5"] = 2, --- NetFounder ---- Remove this line if you dont use robocop
["-1"] = 1, --- Unregs
}
addcmd = "!mybirthday" --- usage : !mybirthday dd/mm/yyyy dd = the number date , mm = the number month , yyyy = the number year .... Sets your birthday!!!!
delcmd = "!delbirthday" --- usage : !delbirthday is needed ... deletes 's birthday from the list ...
listcmd = "!birthdays" --- usage : !birthdays Lists the birthdays stored ...
birthdayfile = "cake.txt" --- The file that will be displayed on Birthday ...
oldestyear = 1900 --- This is so that situations like !mybirthday 0/0/0000 are avoided ... lol
allowedage = 6 --- This is so that situations like !mybirthday are avoided ... in years ...
birthlog = "birthdays.tbl" --- The file where we'll be storing the birthdays ... <<< has to be in your scripts folder ...
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
----------------------------- S c r i p t - S t a r t s -----------------------------
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
tBirthdays = {}
tCalendar = {
[1] = { 31, "January", },
[2] = { 28, "February", },
[3] = { 31, "March", },
[4] = { 30, "April", },
[5] = { 31, "May", },
[6] = { 30, "June", },
[7] = { 31, "July", },
[8] = { 31, "August", },
[9] = { 30, "September", },
[10] = { 30, "October", },
[11] = { 30, "November", },
[12] = { 31, "December", },
}
function Main()
frmHub:RegBot(bBot);
LoadFile(birthlog)
tCalendar[2][1] = FixFebruary(tonumber(date("%Y")))
local hr = tonumber(date("%H"))*60*60*1000
local mins = 0
if tonumber(date("%M")) == 0 then
mins = 1
else
mins = tonumber(date("%M"))*60*1000
end
fixTime(hr+mins)
end
function OnTimer()
CheckBirthdays()
end
function CheckBirthdays()
for i, v in tBirthdays do
if tBirthdays[i][2] == tonumber(date("%m")) then
if tBirthdays[i][1] == tonumber(date("%d")) then
if GetItemByName(i) then
happy = GetItemByName(i)
DoHappyBirthday(happy)
end
end
end
end
end
function fixTime(now)
if now < timecheck then
now = timecheck-now
elseif now > timecheck then
now = now-timecheck
else
now = timecheck
end
SetTimer(now)
StartTimer()
end
function DataArrival(user, data)
if tProfiles[""..user.iProfile..""] ~= 0 then
if strsub(data, 1,1) == "<" then
data = strsub(data, 1, strlen(data)-1)
local s,e,cmd,args = strfind(data, "%b<>%s+(%S+)%s*(.*)")
if cmd == addcmd and tProfiles[""..user.iProfile..""] >= 1 then
if args ~= nil then
s,e,day,month,year = strfind(args, "(%d+)/(%d+)/(%d+)")
if month ~= nil and day ~= nil and year ~= nil and (tonumber(month) > 1) and (tonumber(month) < 12) then
day = tonumber(day)
month = tonumber(month)
year = tonumber(year)
if year > oldestyear then
if year < (tonumber(date("%Y")) - allowedage) then
if month == 2 then
daylimit = FixFebruary(year)
else
daylimit = tCalendar[month][1]
end
if day <= daylimit and day >= 1 then
if tBirthdays[user.sName] then
month = tBirthdays[user.sName][2]
user:SendData(bBot, "I have your birthday already "..tBirthdays[user.sName][1].." of "..tCalendar[month][2])
local profstr = ""
for i,v in tProfiles do
if tProfiles[i] == 2 then
profstr = GetProfileName(tonumber(i)).."s"
break
end
end
user:SendData(bBot, "If this is not correct, then please talk one of our Operators")
else
tBirthdays[user.sName] = {}
tBirthdays[user.sName][1] = day
tBirthdays[user.sName][2] = month
tBirthdays[user.sName][3] = year
SaveFile(tBirthdays , "tBirthdays", birthlog)
user:SendData(bBot, "Your birthday is on the "..tBirthdays[user.sName][1].." of "..tCalendar[month][2])
user:SendData(bBot, "I didnt know you were "..( tonumber(date("%Y"))-tBirthdays[user.sName][3] )..". I'll keep that in mind ;)")
SendToAll(bBot," "..nick.sName.." has just added his/her birthday to the list.") ------ Message to all / can be removed.
end
end
else user:SendData(bBot, "Come ON! you cant be less than "..allowedage.." years old !!! LIAR :(")
end
else user:SendData(bBot, "Come ON! you cant be more than "..(year-oldestyear).." years old !!! LIAR :(")
end
else user:SendData(bBot, "The date you provided was not valid ... ( syntax example : 12/03/1984 )")
end
else user:SendData(bBot , "Please enter your birthday after the command ...")
end
return 1
elseif cmd == delcmd and tProfiles[""..user.iProfile..""] == 2 then
if args ~= nil then
if tBirthdays[args] then
if GetItemByName(args) then
nick = GetItemByName(args)
nick:SendPM(bBot, user.sName.." has deleted your birthday from my list .. ;(")
end
tBirthdays[args] = nil
user:SendData(bBot, "You have deleted "..args.." bithday from the list")
SaveFile(tBirthdays , "tBirthdays", birthlog)
else
user:SendData(bBot, args.." is not in my birthday list ...")
end
else user:SendData(bBot , "You need to give me a name ...")
end
return 1
elseif cmd == listcmd and tProfiles[""..user.iProfile..""] >= 1 then
local msg = "\r\n\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n\t\t\t The Birthday List\r\n\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n\t\t"
local c = 0
local status = ""
for i, v in tBirthdays do
if GetItemByName(i) then
status = "online"
else status = "offline"
end
c = c + 1
msg = msg..c..". "..i.." - "..tBirthdays[i][1].."/"..tBirthdays[i][2].."/"..tBirthdays[i][3].." - ( "..status.." )\r\n\t\t"
end
user:SendPM(bBot , msg)
return 1
end
end
end
end
function FixFebruary(y)
local value = 0
if (tonumber(y)/4) - (floor(tonumber(y)/4)) == 0 then
value = 29
else
value = 28
end
return value
end
function HappyBirthday(nick)
if TxtSend == nil then
SendToAll(ReadTextFile(birthdayfile))
TxtSend = 1
end
SendToAll( bBot , "Happy Birthday "..nick.sName.." who is turning "..( tonumber(date("%Y"))-tBirthdays[user.sName][3] ).." today. ;)") --- Massage to users
end
--- // --- Table Serialization ( part 1/3 ) ? creating input ? --- Thanks Ninghtlitch for providing this to me
function Serialize(savTable, sTableName, hFile, sTab)
assert(savTable, "savTable equals nil");
assert(sTableName, "sTableName equals nil");
assert(hFile, "hFile equals nil");
assert(type(savTable) == "table", "savTable must be a table!");
assert(type(sTableName) == "string", "sTableName must be a string!");
sTab = sTab or "";
write(hFile, sTab..sTableName.." = {\n" );
for key, value in savTable 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
--- // --- Table Serialization ( part 2/3 ) ? Loading from file ?
function LoadFile(file)
assert(readfrom(file),file.." is not found.")
dostring(read("*all"))
readfrom()
end
--- // --- Table Serialization ( part 3/3 ) ? Saving to file ?
function SaveFile(table , tablename, file)
local hFile = openfile(file, "w");
Serialize(table, tablename, hFile);
closefile(hFile);
end
function ReadTextFile(file)
local message = "\r\n"
readfrom(file, "r")
while 1 do
local line = read()
if ( line == nil ) then break
else message = message.."\t"..line.."\r\n"
end
end
readfrom()
return message
end
thanks for the support Flux ;)
milsy there is no prob whatsoever to do what ever you want with this keep it up ..
Running lates script posted here a user tryed to add his birthday 31/03/1975 31 dident worked 30 dit maby you can look into that
btw great script nice done
TiMe :D
Btw would me nice if it showed in main to all that a users added his birthday ;)
Change this part of the script end
if day < daylimit and day > 1 then
if tBirthdays[user.sName] then
month = tBirthdays[user.sName][2]
To this end
if day <= daylimit and day >= 1 then
if tBirthdays[user.sName] then
month = tBirthdays[user.sName][2]
Then it should work ... the script in my post is edited now ...
And [*note*] this bug applied if you tried to birthday a date like 23/1/2000 or 23/12/2000 ... in other words January and February ppl wouldnt be able to do that ...
Dit That
] The date you provided was not valid ... ( syntax example : 12/03/1984 ) After entering 01/27/1965
one more thing check days in months should be this
tCalendar = {
[1] = { 31, "January", },
[2] = { 28, "February", },
[3] = { 31, "March", },
[4] = { 30, "April", },
[5] = { 31, "May", },
[6] = { 30, "June", },
[7] = { 31, "July", },
[8] = { 31, "August", },
[9] = { 30, "September", },
[10] = { 31, "October", },
[11] = { 30, "November", },
[12] = { 31, "December", },
only feb is abit trikky now this year it is 29 days lol
TiMe
QuoteOriginally posted by T?M??r?V?ll?R
Dit That
] The date you provided was not valid ... ( syntax example : 12/03/1984 ) After entering 01/27/1965
one more thing check days in months should be this
tCalendar = {
[1] = { 31, "January", },
[2] = { 28, "February", },
[3] = { 31, "March", },
[4] = { 30, "April", },
[5] = { 31, "May", },
[6] = { 30, "June", },
[7] = { 31, "July", },
[8] = { 31, "August", },
[9] = { 30, "September", },
[10] = { 30, "October", },
[11] = { 30, "November", },
[12] = { 31, "December", },
only feb is abit trikky now this year it is 29 days lol
TiMe
shouldn't the date be like 27/01/1965 to work?
i have fixed my version for both mistakes
Later,
Millsy
youre right troubador stupit me dident see that user had it wrong way around
;(
small update again with the Request from T?M??r?V?ll?R
QuoteBtw would me nice if it showed in main to all that a users added his birthday ;)
Later,
Millsy
Thanks Millsy :D
Indeed a very usefull script !!! I'm sure , all users will love it.
One request , if i may:
-Can any message be delivered when the user enters the hub , say Happy Birthday , if it's the "b day" ???
Thanks again for this script !!!
QuoteCan any message be delivered when the user enters the hub , say Happy Birthday , if it's the "b day" ???
Nice idea i know it can be done but i dont know how im still a bit of a noob to this. so this 1 is up to Herodes or one of the others
Later,
Millsy
Hi update ..--- BirthdayMan v 2
--- by Herodes 21/8/2004
--- --- --- --- --- --- --- --- --- --- --- ---
--- You need a file named like the ' birthlog ' variable (see below...) in your scripts folder ...
-- v2
--- Fixed shamefull bug of days in Months (thx TimeTraveler)
--- Added more profile numbers to work with
--- Added !addbirth ( ' addbirthcmd ' variable )
--- added !bornon ( ' findcmd ' variable )
--- possible to add birthday of someone else now too
--- added random messages on birthday
--- displays main notification on new birthday entry
-- Last Update 24/8/2004
--- --- --- --- --- --- --- --- --- --- --- ---
sec = 1000 ----- do not edit this
minutes = 1000*60 ----- do not edit this
hours = 1000*(60^2) ----- do not edit this
TxtSend = nil ----- do not edit this
bBot = "Surprise"
timecheck = 12*hours --- how much time before checking for birthdays ...
tProfiles = { ---- profile rights to commands ... 0 cant use the bot at all, 1 can use listcmd and addcmd, 2 can also use delcmd and addbircmd...
["0"] = 2, --- Masters ( ["profile_number"] = value (0/1/2)
["1"] = 2, --- Operators
["2"] = 1, --- VIPs
["3"] = 1, --- Regs
["4"] = 0, --- CustomProf1
["5"] = 0,
["-1"] = 0, --- Unregs
}
addcmd = "!mybirthday" --- !mybirthday dd/mm/yyyy dd = the day , mm = the month , yyyy = the year .... Sets your birthday!
delcmd = "!delbirthday" --- !delbirthday is needed ... deletes 's birthday from the list
listcmd = "!birthdays" --- !birthdays Lists the birthdays stored
addbircmd = "!addbirth" --- !addbirth same as addcmd
findcmd = "!bornon" --- !bornon Shows a nice list of the ppl you share dates with ;)
birthdayfile = "cake.txt" --- The file that will be displayed on Birthday
oldestyear = 1900 --- !mybirthday 0/0/0000 situations are avoided ( lol )
allowedage = 6 --- !mybirthday situations are avoided (in years)
birthlog = "birthdays.tbl" --- The file where we'll be storing the birthdays ... << has to be in your scripts folder
--- // --- S c r i p t - S t a r t s
tBirthdays = {}
tCalendar = {
[1] = { 31, "January", },
[2] = { 28, "February", },
[3] = { 31, "March", },
[4] = { 30, "April", },
[5] = { 31, "May", },
[6] = { 30, "June", },
[7] = { 31, "July", },
[8] = { 31, "August", },
[9] = { 30, "September", },
[10] = { 31, "October", },
[11] = { 30, "November", },
[12] = { 31, "December", },
}
function Main()
LoadFile(birthlog)
tCalendar[2][1] = FixFebruary(tonumber(date("%Y")))
local hr = tonumber(date("%H"))*60*60*1000
local mins = 0
if tonumber(date("%M")) == 0 then
mins = 1
else
mins = tonumber(date("%M"))*60*1000
end
fixTime(hr+mins)
end
function OnTimer()
CheckBirthdays()
TxtSend = nil
end
function CheckBirthdays()
for i, v in tBirthdays do
if tBirthdays[i][2] == tonumber(date("%m")) then
if tBirthdays[i][1] == tonumber(date("%d")) then
if GetItemByName(i) then
happy = GetItemByName(i)
DoHappyBirthday(happy)
end
end
end
end
end
function FixFebruary(y)
local value = 0
if (tonumber(y)/4) - (floor(tonumber(y)/4)) == 0 then
value = 29
else
value = 28
end
return value
end
function fixTime(now)
if now < timecheck then
now = timecheck-now
elseif now > timecheck then
now = now-timecheck
else
now = timecheck
end
SetTimer(now)
StartTimer()
end
function DataArrival(user, data)
if tProfiles[""..user.iProfile..""] ~= 0 then
if strsub(data, 1,1) == "<" then
data = strsub(data, 1, strlen(data)-1)
local s,e,cmd,args = strfind(data, "%b<>%s+(%S+)%s*(.*)")
if cmd == addcmd or cmd == addbircmd and tProfiles[""..user.iProfile..""] >= 1 then
AddBirthDay(user, args)
return 1
elseif cmd == delcmd and tProfiles[""..user.iProfile..""] == 2 then
if args ~= nil then
if tBirthdays[args] then
if GetItemByName(args) then
nick = GetItemByName(args)
nick:SendPM(bBot, user.sName.." has deleted your birthday from my list .. ;(")
end
tBirthdays[args] = nil
user:SendData(bBot, "You deleted "..args.." bithday ...")
SaveFile(tBirthdays , "tBirthdays", birthlog)
else
user:SendData(bBot, args.." is not in my birthday list ...")
end
else user:SendData(bBot , "You need to give me a name ...")
end
return 1
elseif cmd == listcmd and tProfiles[""..user.iProfile..""] >= 1 then
local str = "The Birthday List of the users of "..frmHub:GetHubName()
local msg = "\r\n ..-*'~ "..str.." ~'*-..\r\n"..strrep("^", strlen(str)).."\r\n\t"
local c = 0
local status = ""
for i, v in tBirthdays do
if GetItemByName(i) then
status = "online"
else status = "offline"
end
c = c + 1
msg = msg..c..". - "..tBirthdays[i][1].."/"..tBirthdays[i][2].."/"..tBirthdays[i][3].." - \t"..i.."\t ( "..status.." )\r\n\t"
end
user:SendData(bBot , msg)
return 1
elseif cmd == findcmd then
if tBirthdays[user.sName] then
local msg = " These are the people that are born the same number-day as you\r\n"
msg = msg..FindSame(tBirthdays, tBirthdays[user.sName][1] , "day", user.sName).."\r\n"
msg = msg.." These are the people that are born the same month as you\r\n"
msg = msg..FindSame(tBirthdays, tBirthdays[user.sName][2] , "month", user.sName).."\r\n"
msg = msg.." These are the people that are born the same year as you\r\n"
msg = msg..FindSame(tBirthdays, tBirthdays[user.sName][3] , "year", user.sName).."\r\n"
msg = msg.." These are the people that are born the same month and day with you \r\n"
msg = msg..FindSame(tBirthdays, tBirthdays[user.sName][1].."/"..tBirthdays[user.sName][2] , "monthday", user.sName).."\r\n"
msg = msg.." These are the people that have the same birthday as yours\r\n"
msg = msg..FindSame(tBirthdays, tBirthdays[user.sName][1].."/"..tBirthdays[user.sName][2].." - "..tBirthdays[user.sName][3] , "all", user.sName).."\r\n"
user:SendData(bBot, msg)
end
end
end
end
end
function AddBirthDay(user, args)
local pers = ""
if args ~= nil then
local s,e,name,day,month,year = strfind(args, "(%S+)%s+(%d+)/(%d+)/(%d+)")
if name == nil then
name = user.sName
pers = "you"
s,e,day,month,year = strfind(args, "(%d+)/(%d+)/(%d+)")
else pers = name
end
if month ~= nil and day ~= nil and year ~= nil and (tonumber(month) >= 1) and (tonumber(month) <= 12) then
day = tonumber(day)
month = tonumber(month)
year = tonumber(year)
if year > oldestyear then
if year < (tonumber(date("%Y")) - allowedage) then
if month == 2 then
daylimit = FixFebruary(year)
else
daylimit = tCalendar[month][1]
end
if day <= daylimit and day >= 1 then
if tBirthdays[name] then
month = tBirthdays[name][2]
if user.sName == name then
user:SendData(bBot, "I have your birthday already ... its on the "..tBirthdays[name][1].." of "..tCalendar[month][2])
else
user:SendData(bBot, "I have "..name.."'s birthday already ... its on the "..tBirthdays[name][1].." of "..tCalendar[month][2])
end
local profstr = ""
for i,v in tProfiles do
if tProfiles[i] == 2 then
profstr = GetProfileName(tonumber(i)).."s"
break
end
end
user:SendData(bBot, "If you dont think this is correct ... then talk to one of our "..profstr)
else
tBirthdays[name] = {}
tBirthdays[name][1] = day
tBirthdays[name][2] = month
tBirthdays[name][3] = year
SaveFile(tBirthdays , "tBirthdays", birthlog)
if user.sName == name then
user:SendData(bBot, "Your birthday is on the "..tBirthdays[name][1].." of "..tCalendar[month][2])
user:SendData(bBot, "I didnt know you are "..( tonumber(date("%Y"))-tBirthdays[name][3] )..". I'll keep that in mind ;)")
else
user:SendData(bBot, name.."'s birthday is on the "..tBirthdays[name][1].." of "..tCalendar[month][2])
user:SendData(bBot, "I didnt know "..name.." is "..(( tonumber(date("%Y"))-tBirthdays[name][3] )-1)..". I'll keep that in mind ;)")
end
if user.sName == name then
SendToAll(bBot, "New birthday added by "..user.sName.." his is on the "..tBirthdays[name][1].." of "..tCalendar[month][2])
else
SendToAll(bBot, user.sName.." added "..name.."'s birthday, which is on the "..tBirthdays[name][1].." of "..tCalendar[month][2])
end
end
end
else user:SendData(bBot, "Come ON! "..pers.." cant be less than "..allowedage.." years old !!! LIAR >:(")
end
else user:SendData(bBot, "Come ON! "..pers.." cant be more than "..(year-oldestyear).." years old !!! LIAR >:(")
end
else user:SendData(bBot, "The date you provided was not valid ... ( syntax example : 14/5/1981 )")
end
else user:SendData(bBot , "Please enter your birthday after the command ...")
end
end
function FindSame(tTab, val , var, name)
local tTmp = {}
local msg = ""
if var == "day" then
for i, v in tTab do
if val == v[1] and i ~= name then
tTmp[i] = v[1].."/"..v[2].." - "..v[3]
end
end
elseif var == "month" then
for i, v in tTab do
if val == v[2] and i ~= name then
tTmp[i] = v[1].."/"..v[2].." - "..v[3]
end
end
elseif var == "year" then
for i, v in tTab do
if val == v[3] and i ~= name then
tTmp[i] = v[1].."/"..v[2].." - "..v[3]
end
end
elseif var == "monthday" then
for i, v in tTab do
if val == v[1].."/"..v[2] and i ~= name then
tTmp[i] = v[1].."/"..v[2].." - "..v[3]
end
end
elseif var == "all" then
for i, v in tTab do
if val == v[1].."/"..v[2].." - "..v[3] and i ~= name then
tTmp[i] = v[1].."/"..v[2].." - "..v[3]
end
end
end
for i,v in tTmp do
msg = msg.."\t - "..i.."\r\n"
end
if msg == "" then
msg = "\t - noone\r\n"
end
return msg
end
function DoHappyBirthday(nick)
if TxtSend == nil then
SendToAll(ReadTextFile(birthdayfile))
TxtSend = 1
end
local age = tonumber(date("%Y")) - tBirthdays[nick.sName][3]
local tSurpises = {
nick.sName.." is gonna have a PAAARTY, today he is turning "..age.." Happy Birthday !!!!",
"All of you spam "..nick.sName.." with Birthday messages ;), ...turning "..age.." today !!!",
"Who's turning "..age.." today ?? :D... The day AND the night belongs to "..nick.sName,
"Happy Birthday to you, Happy Birthday dear "..nick.sName..", we all wish you your "..age.." will be better than your "..(age-1).." !! :)",
" I think Mr"..nick.sName.." has his birthday today ... he should be turning "..age.." today ;D",
};
SendToAll( bBot , tSurpises[random(1, getn(tSurpises)) ] )
end
--- // --- Table Serialization --- Thanks NL
function Serialize(savTable, sTableName, hFile, sTab)
assert(savTable, "savTable equals nil");
assert(sTableName, "sTableName equals nil");
assert(hFile, "hFile equals nil");
assert(type(savTable) == "table", "savTable must be a table!");
assert(type(sTableName) == "string", "sTableName must be a string!");
sTab = sTab or "";
write(hFile, sTab..sTableName.." = {\n" );
for key, value in savTable 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 LoadFile(file)
assert(readfrom(file),file.." is not found.")
dostring(read("*all"))
readfrom()
end
function SaveFile(table , tablename, file)
local hFile = openfile(file, "w");
Serialize(table, tablename, hFile);
closefile(hFile);
end
function ReadTextFile(file)
local message = "\r\n"
readfrom(file, "r")
while 1 do
local line = read()
if ( line == nil ) then break
else message = message.."\t"..line.."\r\n"
end
end
readfrom()
return message
end
This one doesnt do what CableGuy requested yet ... ;)
Syntax error: `=' expected;
last token read: `==' at line 76 in file `...ngs\Administrator\Bureaublad\Hub Robo 9\scripts\BirthdayMan v 2.lua'
TiMe
oki fixed 1 = to many :))
function OnTimer()
CheckBirthdays()
TxtSend == nil <-- remove 1 =
When asking for birthdays list i get this
..-*'~ The Birthday List of the users of .::T?M?`?::?R?nC?: (?_?)b::S??C?::Fr??K?::. ~'*-..
――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
1. - 5/9/1966 - :T??:[NL]Empat ( offline )
2. - 25/8/1986 - TeaL ( online )
3. - 27/10/1975 - :T?? uhsveti ( offline )
4. - 30/3/1968 - :T?? NL)abyss ( offline )
5. - 26/4/1959 - :T??:[NL]Sm?K?? ( offline )
whats the part on top ?
Small thing most users are 1 year older that real age
<-=BirthdayMan=-> :T??:Wendy's birthday is on the 30 of September
[12:30:32] <-=BirthdayMan=-> I didnt know :T??:Wendy is 29. I'll keep that in mind
[12:30:32] <-=BirthdayMan=-> :T??:.T?M??r?V?ll?R added :T??:Wendy's birthday, which is on the 30 of September
wendy is now 28 year
TiMe
Btw me and users love this script
QuoteOriginally posted by T?M??r?V?ll?R
When asking for birthdays list i get this
..-*'~ The Birthday List of the users of .::T?M?`?::?R?nC?: (?_?)b::S??C?::Fr??K?::. ~'*-..
―[....]―――
1. - 5/9/1966 - :T??:[NL]Empat ( offline )
2. - 25/8/1986 - TeaL ( online )
3. - 27/10/1975 - :T?? uhsveti ( offline )
4. - 30/3/1968 - :T?? NL)abyss ( offline )
5. - 26/4/1959 - :T??:[NL]Sm?K?? ( offline )
whats the part on top ?
I dont really know ... can you pm me your birthdays.dat ?
I suppose it has to be something to do with one of those chars u use ... I dont know for sure ...
^^^^ I got the bugger ... stupid forum text fformater ... look how it handles a special char ..
local msg = "\r\n ..-*'~ "..str.." ~'*-..\r\n"..strrep("―", strlen(str)).."\r\n\t"
edit the "―" to anything you want timeT ... [*code edited*]
Thanks for the TextSend == nil .. copy/paste error ... :)[*code edited*]
Post above edited to display the true age .. ty TimeTraveler ;)[*code edited*]
PS: Can you edit your post so that ppl in Africa dont compain .. ? lol ... (The long part can be like ―[....]―――)
thx again TimeT ..
Yw :D
Hi there:
This "new version" worked with me:
[11:59]
..-*'~ The Birthday List of the users of TUDONOSSO - LINUX ~'*-..
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1. - 25/8/1950 - testing ( online )
2. - 25/8/1960 - testing2 ( online )
[12:00]
[12:00] All of you spam testing with Birthday messages ;), ...turning 54 today !!!
[12:00] All of you spam testing2 with Birthday messages ;), ...turning 44 today !!!
.
.
[12:04] Happy Birthday to you, Happy Birthday dear testing, we all wish you your 54 will be better than your 53 !! :)
[12:04] Who's turning 44 today ?? :D... The day AND the night belongs to testing2
Is it possible to check if the it's the user birthday and give a nice "welcome msg" when entering the hub ?
Great Job Herodes !!! Thanks m8.
Thanks CableGuy :)
I was wondering ... would it be possible to find a file that contains birthday of famous ppl ?
That would be nice to include .. ;) hehe
I will be doing the UserConnected requests from TimeTraveler and Cableguy ... all in good time ...
thx for the ideas guys ...
Ok folks ... thats it ..
The changelog has been severly cut due to max post chars
For anything else, gimme a shout ;)
--- BirthdayMan v 2.5
--- by Herodes -- Update 25/8/2004
--- --- --- --- --- ---
--- When Users are connected if there is a birthday it informs
--- When a Birhtday-User connect it plays surprise and informs the Hub
----- do not edit these four lines
sec = 1000
minutes = 1000*60
hours = 1000*(60^2)
TxtSend = nil
----- Edit at will
bBot = "Surprise"
timecheck = 12*hours --- how much time before checking for birthdays ...
tProfiles = { ---- profile rights to commands, 0 cant use the bot at all, 1 can use listcmd and addcmd, 2 can also use delcmd and addbircmd...
["-1"] = 0, --- Unregs
["0"] = 2, --- Masters
["1"] = 2, --- Operators
["2"] = 1, --- VIPs
["3"] = 1, --- Regs
["4"] = 0, --- CustomProf1
["5"] = 0, --- CustomProf2
} --- ( carry on typing your profiles in the right format : ["profile_number"] = value (0/1/2)
addcmd = "!mybirthday" --- !mybirthday dd/mm/yyyy dd = day , mm = month , yyyy = year .... Sets your birthday!
delcmd = "!delbirthday" --- !delbirthday is needed ... deletes 's birthday from the list
listcmd = "!birthdays" --- !birthdays Lists the birthdays stored
addbircmd = "!addbirth" --- !addbirth same as addcmd
findcmd = "!bornon" --- !bornon Shows a nice list of the ppl you share dates with ;)
birthdayfile = "cake.txt" --- The file that will be displayed on Birthday
oldestyear = 1900 --- !mybirthday 0/0/0000 situations are avoided ( lol )
allowedage = 6 --- !mybirthday situations are avoided (in years)
birthlog = "birthdays.tbl" --- The file where we'll be storing the birthdays ... << has to be in your scripts folder
--- // --- Script-Starts
tBirthdays = {}
tCalendar = {
[1] = { 31, "January", },
[2] = { 28, "February", },
[3] = { 31, "March", },
[4] = { 30, "April", },
[5] = { 31, "May", },
[6] = { 30, "June", },
[7] = { 31, "July", },
[8] = { 31, "August", },
[9] = { 30, "September", },
[10] = { 31, "October", },
[11] = { 30, "November", },
[12] = { 31, "December", },
}
function Main()
LoadFile(birthlog)
tCalendar[2][1] = FixFebruary(tonumber(date("%Y")))
local hr = tonumber(date("%H"))*60*60*1000
local mins = 0
if tonumber(date("%M")) == 0 then
mins = 1
else
mins = tonumber(date("%M"))*60*1000
end
fixTime(hr+mins)
end
function OnTimer()
CheckBirthdays()
TxtSend = nil
end
function NewUserConnected(user)
for i, v in tBirthdays do
if tBirthdays[i][2] == tonumber(date("%m")) and tBirthdays[i][1] == tonumber(date("%d")) then
if user.sName ~= i then
local msg = "Its "..i.."'s birhtday today .. ;D Turning "..(tonumber(date("%Y"))-tBirthdays[i][3] ).." today,... give a wish :)"
if GetItemByName(i) then
user:SendData(bBot, msg)
else user:SendData(bBot, msg.." when he comes online")
end
else
user:SendData(bBot, "Hey I know !!! YOU HAVE YOUR BIRTHDAY TODAY !!! HAPPIEST OF BIRTHDAYS !!!! ")
SendToAll(bBot, "Guys !! "..user.sName.." is here! What do we say ?? : )")
end
end
end
end
OpConnected = NewUserConnected
function CheckBirthdays()
for i, v in tBirthdays do
if tBirthdays[i][2] == tonumber(date("%m")) then
if tBirthdays[i][1] == tonumber(date("%d")) then
if GetItemByName(i) then
happy = GetItemByName(i)
DoHappyBirthday(happy)
end
end
end
end
end
function FixFebruary(y)
local value = 0
if (tonumber(y)/4) - (floor(tonumber(y)/4)) == 0 then
value = 29
else value = 28
end
return value
end
function fixTime(now)
if now < timecheck then
now = timecheck-now
elseif now > timecheck then
now = now-timecheck
else now = timecheck
end
SetTimer(now)
StartTimer()
end
function DataArrival(user, data)
if tProfiles[""..user.iProfile..""] ~= 0 then
if strsub(data, 1,1) == "<" then
data = strsub(data, 1, strlen(data)-1)
local s,e,cmd,args = strfind(data, "%b<>%s+(%S+)%s*(.*)")
if cmd == addcmd or cmd == addbircmd and tProfiles[""..user.iProfile..""] >= 1 then
CheckBirthdays()
AddBirthDay(user, args)
return 1
elseif cmd == delcmd and tProfiles[""..user.iProfile..""] == 2 then
if args ~= nil then
if tBirthdays[args] then
if GetItemByName(args) then
nick = GetItemByName(args)
nick:SendPM(bBot, user.sName.." has deleted your birthday from my list .. ;(")
end
tBirthdays[args] = nil
user:SendData(bBot, "You deleted "..args.." bithday ...")
SaveFile(tBirthdays , "tBirthdays", birthlog)
else user:SendData(bBot, args.." is not in my birthday list ...")
end
else user:SendData(bBot , "You need to give me a name ...")
end
return 1
elseif cmd == listcmd and tProfiles[""..user.iProfile..""] >= 1 then
local str = "The Birthday List of the users of "..frmHub:GetHubName()
local msg = "\r\n ..-*'~ "..str.." ~'*-..\r\n"..strrep("^", strlen(str)).."\r\n\t"
local c = 0
local status = ""
for i, v in tBirthdays do
if GetItemByName(i) then status = "online" else status = "offline" end
c = c + 1
msg = msg..c..". - "..tBirthdays[i][1].."/"..tBirthdays[i][2].."/"..tBirthdays[i][3].." - \t"..i.."\t ( "..status.." )\r\n\t"
end
user:SendData(bBot , msg)
return 1
elseif cmd == findcmd then
if tBirthdays[user.sName] then
local msg = " These are the people that are born the same number-day as you\r\n"
msg = msg..FindSame(tBirthdays, tBirthdays[user.sName][1] , "day", user.sName).."\r\n"
msg = msg.." These are the people that are born the same month as you\r\n"
msg = msg..FindSame(tBirthdays, tBirthdays[user.sName][2] , "month", user.sName).."\r\n"
msg = msg.." These are the people that are born the same year as you\r\n"
msg = msg..FindSame(tBirthdays, tBirthdays[user.sName][3] , "year", user.sName).."\r\n"
msg = msg.." These are the people that are born the same month and day with you \r\n"
msg = msg..FindSame(tBirthdays, tBirthdays[user.sName][1].."/"..tBirthdays[user.sName][2] , "monthday", user.sName).."\r\n"
msg = msg.." These are the people that have the same birthday as yours\r\n"
msg = msg..FindSame(tBirthdays, tBirthdays[user.sName][1].."/"..tBirthdays[user.sName][2].." - "..tBirthdays[user.sName][3] , "all", user.sName).."\r\n"
user:SendData(bBot, msg)
end
end
end
end
end
function AddBirthDay(user, args)
local pers = ""
if args ~= nil then
local s,e,name,day,month,year = strfind(args, "(%S+)%s+(%d+)/(%d+)/(%d+)")
if name == nil then
name = user.sName
pers = "you"
s,e,day,month,year = strfind(args, "(%d+)/(%d+)/(%d+)")
else pers = name
end
if month ~= nil and day ~= nil and year ~= nil and (tonumber(month) >= 1) and (tonumber(month) <= 12) then
day = tonumber(day)
month = tonumber(month)
year = tonumber(year)
if year > oldestyear then
if year < (tonumber(date("%Y")) - allowedage) then
if month == 2 then
daylimit = FixFebruary(year)
else daylimit = tCalendar[month][1]
end
if day <= daylimit and day >= 1 then
if tBirthdays[name] then
month = tBirthdays[name][2]
if user.sName == name then
user:SendData(bBot, "I have your birthday already ... its on the "..tBirthdays[name][1].." of "..tCalendar[month][2])
else user:SendData(bBot, "I have "..name.."'s birthday already ... its on the "..tBirthdays[name][1].." of "..tCalendar[month][2])
end
local profstr = ""
for i,v in tProfiles do
if tProfiles[i] == 2 then
profstr = GetProfileName(tonumber(i)).."s"
break
end
end
user:SendData(bBot, "If you dont think this is correct ... then talk to one of our "..profstr)
else tBirthdays[name] = {}
tBirthdays[name][1] = day
tBirthdays[name][2] = month
tBirthdays[name][3] = year
SaveFile(tBirthdays , "tBirthdays", birthlog)
if user.sName == name then
user:SendData(bBot, "Your birthday is on the "..tBirthdays[name][1].." of "..tCalendar[month][2])
user:SendData(bBot, "I didnt know you are "..(( tonumber(date("%Y"))-tBirthdays[name][3] )-1)..". I'll keep that in mind ;)")
else user:SendData(bBot, name.."'s birthday is on the "..tBirthdays[name][1].." of "..tCalendar[month][2])
user:SendData(bBot, "I didnt know "..name.." is "..(( tonumber(date("%Y"))-tBirthdays[name][3] )-1)..". I'll keep that in mind ;)")
end
if user.sName == name then
SendToAll(bBot, "New birthday added by "..user.sName.." his is on the "..tBirthdays[name][1].." of "..tCalendar[month][2])
else SendToAll(bBot, user.sName.." added "..name.."'s birthday, which is on the "..tBirthdays[name][1].." of "..tCalendar[month][2])
end
end
end
else user:SendData(bBot, "Come ON! "..pers.." cant be less than "..allowedage.." years old !!! LIAR >:(")
end
else user:SendData(bBot, "Come ON! "..pers.." cant be more than "..(year-oldestyear).." years old !!! LIAR >:(")
end
else user:SendData(bBot, "The date you provided was not valid ... ( syntax example : 14/5/1981 )")
end
else user:SendData(bBot , "Please enter your birthday after the command ...")
end
end
function FindSame(tTab, val , var, name)
local tTmp = {}
local msg = ""
if var == "day" then
for i, v in tTab do
if val == v[1] and i ~= name then
tTmp[i] = v[1].."/"..v[2].." - "..v[3]
end
end
elseif var == "month" then
for i, v in tTab do
if val == v[2] and i ~= name then
tTmp[i] = v[1].."/"..v[2].." - "..v[3]
end
end
elseif var == "year" then
for i, v in tTab do
if val == v[3] and i ~= name then
tTmp[i] = v[1].."/"..v[2].." - "..v[3]
end
end
elseif var == "monthday" then
for i, v in tTab do
if val == v[1].."/"..v[2] and i ~= name then
tTmp[i] = v[1].."/"..v[2].." - "..v[3]
end
end
elseif var == "all" then
for i, v in tTab do
if val == v[1].."/"..v[2].." - "..v[3] and i ~= name then
tTmp[i] = v[1].."/"..v[2].." - "..v[3]
end
end
end
for i,v in tTmp do
msg = msg.."\t - "..i.."\r\n"
end
if msg == "" then
msg = "\t - noone\r\n"
end
return msg
end
function DoHappyBirthday(nick)
if TxtSend == nil then
SendToAll(ReadTextFile(birthdayfile))
TxtSend = 1
end
local age = tonumber(date("%Y")) - tBirthdays[nick.sName][3]
local tSurpises = {
nick.sName.." is gonna have a PAAARTY, today he is turning "..age.." Happy Birthday !!!!",
"All of you spam "..nick.sName.." with Birthday messages ;), ...turning "..age.." today !!!",
"Who's turning "..age.." today ?? :D... The day AND the night belongs to "..nick.sName,
"Happy Birthday to you, Happy Birthday dear "..nick.sName..", we all wish you your "..age.." will be better than your "..(age-1).." !! :)",
" I think Mr"..nick.sName.." has his birthday today ... he should be turning "..age.." today ;D",
};
SendToAll( bBot , tSurpises[random(1, getn(tSurpises)) ] )
end
--- // --- Table Serialization --- Thanks NL
function Serialize(savTable, sTableName, hFile, sTab)
assert(savTable, "savTable equals nil");
assert(sTableName, "sTableName equals nil");
assert(hFile, "hFile equals nil");
assert(type(savTable) == "table", "savTable must be a table!");
assert(type(sTableName) == "string", "sTableName must be a string!");
sTab = sTab or "";
write(hFile, sTab..sTableName.." = {\n" );
for key, value in savTable 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 LoadFile(file)
assert(readfrom(file),file.." is not found.")
dostring(read("*all"))
readfrom()
end
function SaveFile(table , tablename, file)
local hFile = openfile(file, "w");
Serialize(table, tablename, hFile);
closefile(hFile);
end
function ReadTextFile(file)
local message = "\r\n"
readfrom(file, "r")
while 1 do
local line = read()
if ( line == nil ) then break
else message = message.."\t"..line.."\r\n"
end
end
readfrom()
return message
end
just one problem, it says to enter birthday as dd/mm/yyyy. thats just fine except in the usa we use mm/dd/yyyy format, can this be changed??
thanks in advance
Unfortunately I can see that there has to be a rewrite/restructuring for the script to work as u say ...
If someone is willing to do it I dont have a problem for him to go ahead ...
Anyhow, since it is only USA that does this I think it is a minor thing to do :)
QuoteOriginally posted by Herodes
Anyhow, since it is only USA that does this I think it is a minor thing to do :)
gee thanks!
;)
-BH
Sorry but ppl in most parts of the world are dd/mm/yyyy ...
furthermore, I just cant bother to do a rewrite of this script because Americans or any1 other is using the mm/dd/yyyy of which the functionality I have never understood ...
Nevertheless any1 is free to modify this script to suit his needs ... I hope I am clear on this and that I didnt inspire any suspicious feelings, as that was not my intention...
nice attitude :(
all i was asking was for help to change it for usa users.
i am not a scripter nor did i claim to be, all i asked was for help changing it!!!
!mybirthday 23/03/1980
[15:00:07] Your birthday is on the 23 of March
[15:00:07] I didnt know you are 23. I'll keep that in mind ;)
[15:00:08] New birthday added by DJDelta?? his is on the 23 of March
That's weird cause i'm 24 now :] How do i change it ?
Greetz !
thanx for mentioning that one DJDelta!! i noticed that also, it says im 30 and im 31.
upon furthur testing the bot only shows the wrong age (1 year less) if the birthday you enter is after the current date when you add the birthday. i had 2 people so far who have birthdays in october and december and just added their birthdays today.
Will
Uhm ... think about this ..
Say my Birthday is 08 - 05 - 1981
2004 - 1981 = 23 years
So the bot says the truth ... although ..
The problem doesn't lie in a bug or error ... it is a common misconception...
I am 23 years old .... but I am on the 24th year of my life ...
Thats what is by math logic ...
-------- As for the attitude displayed I dont think there are any valid grounds for beeing sad or dissappointed ,
because I dont have the time or will to do something that I will never use ... It is quite clear no?..
kool i can understand that.
still no reason to bash the usa. :(
other than that awesome script my hubberz have taken to it right away!!!
Will
good,.. thanks for understanding ..
and I am glad users like it ;)
Well the problem with the birthday is that the script doesn't check the actual date (i.e. todays date) when entering a new birthday.
I'll explain...
Let's say someone has a birthday on 11-11-1911. This mean that on 11-11-2004 this person is 93 years old.
Well, if i enter this birthday into the bot it tells me the age is 93. But this is NOT true, because it isn't 11-11-2004 yet.
So, what the script STILL needs to determine is whether the entered birthday has already been or is still to come this year.
I am not much of a scripter but i formulated this:
*****************************
If [currentdatemonth] > [birthdaydatemonth] THEN
age = (currentdateyear - birthdaydateyear) <--- *1
ELSEIF [currentdatemonth] = [birthdaydatemonth] THEN <--- *2
IF [currentdateday] >= [birthdaydateday] THEN <--- *3
age = (currentdateyear - birthdaydateyear)
ELSE age = ((currentdateyear - birthdaydateyear)-1) <--- *4
END
ELSEIF [currentdatemonth] < [birthdaydatemonth] THEN age = ((currentdateyear - birthdaydateyear)-1)<--- *5
END
*1: Because the birthday took place before the birthday was entered, we just need to subtract the years.
*2: The birthday takes place in the same month the birthday was added.
*3: The birthday was entered in the SAME month but AFTER (or on the same day) it took place.
*4: The birthday was entered in the SAME month but before it will take place.
*5: The birthday was entered in a month before it will take place.
Hi ,... this was a morning brain-teaser in a bad day :)
I hope its long gone now ...
grab it from here pls (http://www.plop.nl/ptokaxbots/Herodes.php)
** if u cant find it, it should be because the page
** isnt updated yet , try again a bit later ...
well all good work Herodes i dled youre update of the birthdayman but i still got the smae prob like the old version. when i enter a birthday like 12/03/1977 it tell's me that im 26. X(
im not a script writer but is there not something that the bot has to get what date it is and then detirmine if the date/birthday inserted has to come or has already be??? so that if somebody has birthday on 10/09 that the script see that the date is already passed because it is 22/09??
Greetz DeLights
Owner and Founder of TSH
QuoteOriginally posted by Herodes
... would it be possible to find a file that contains birthday of famous ppl ?
Read this crazy ideia , please. :]
I have found this website:
http://www.celebrity-link.com/ (http://www.celebrity-link.com/)
When you search for a date it will show , something like this:
http://www.celebrity-link.com/birthday_day-23_month-9.html
My point is to use some of the features of the googlebot and
kit this Birthday script !!!
What do you guys think ? ;)
btw: here is the google bot:
function Main()
Botname = "Googlebot"
frmHub:RegBot(Botname)
end
function DataArrival(user,data)
data=strsub(data,1,strlen(data)-1)
s,e,cmd,arg = strfind( data, "%b<>%s+(%S+)%s+(.+)" )
if (cmd == "google") then
arg = gsub(arg, "%s+", "%+");
SendToAll(Botname, "http://www.google.pt/search?q="..arg.."&ie=UTF-8&oe=UTF-8&hl=pt&lr=")
elseif (cmd == "googlepic") then
arg = gsub(arg, "%s+", "%+");
SendToAll (Botname, "http://images.google.pt/images?q="..arg.."&ie=UTF-8&oe=UTF-8&hl=pt")
end
end
basically I was wondering if we could grab all they're pages and add the birthdays automatically .. :)
A one-of-script would do the job nicely ... then we could disturbute the script in a .rar so that ppl may have their celebirthday ready .. :)
but I cant script while online .. over here that could create a phone bill to kill for ...
I never liked the idea of being dead .. :)
So if anyone can make that (web --> script --> tablefile) ... I'll be gratefull ..
everything works fine in this script. but i want the commands gonna be in the bot, when you write !commands in the bot you gonna se a list in the bot to show the commands in the bot and the day the person have his birthday it gonna show it in the topic just for that day and it is okey if it is some funny lines on the topic to :)) i am very thank fully if someone can do that
QuoteOriginally posted by Sunnis
everything works fine in this script. but i want the commands gonna be in the bot, when you write !commands in the bot you gonna se a list in the bot to show the commands in the bot and the day the person have his birthday it gonna show it in the topic just for that day and it is okey if it is some funny lines on the topic to :)) i am very thank fully if someone can do that
yeah these are all doable :)
[/QUOTE]
yeah these are all doable :)
[/QUOTE]
ok where can i fixed so i can use it in the bot???? ?( Herodes???
I am working on these ...
while I am at that can u tell me smths pls ...
how many characters would you want to have in the topic ?
and what would happen if, for example, 15 ppl had their birthday on the same day ? which of those nicks should go in the topic ?
furthermore atm I am working on getting a new function to work ...
how do you like this cmd : !myage
:)
btw there is nothing else wrong with the bot and I was wondering y u cant use it ....
take how many letters you want in the topic. the command you fix is ok to :o). if there is "20" birthday at the same day it will random one of the user to send to the topic :). i want the Commands like !myage work in the bot :) or it will work in the bot and mainchat is ok to :) but it is not working in the bot like send a pm to the bot with !myage to add a new birthday. thats what i mean with a bot. if you don't understand what i mean :P it is ok my english suxx :D .
By now the topic thingie has been sorted ...
the !myage cmd is working properly ...
BUT that about the bot working in pm too I need some more time to fix ... I'll start working on it 2morrow .. .
Another (problem) I am facing is that I made this script below to grab the birthdays of celebrities from //www.celebrity-link.com as [PT]CableGuy suggested for all 366 days :) But(no2) I cant do that because of my connection ... a poor 56k modem ( dont laugh )
Iwas wondering if someone could help me ... pm me pls so we can get the celebrities in there as well .. lol
QuoteOriginally posted by Herodes
BUT that about the bot working in pm too I need some more time to fix ... I'll start working on it 2morrow .. .
ok take your time i'am not in a rush :P but i hope you fix the celebration you wanted :))
Hello BirthdayMan v3 is out ...
-- v 3
--- ability to display the Birthday nicks in the topic of the hub ... ( all of them ... the Offline ones are in parentheses like (Herodes))
--- added agecmd to get exact age
--- added bhelpcmd
--- added display of birthdays in the findcmd
--- added ability for pm or main cmds .. ;)
--- added in list birthdays cmd the signaling of the ppl who have their birthday the present day ..
grab it from here pls (http://www.plop.nl/ptokaxbots/Herodes.php)
** if u cant find it, it should be because the page
** isnt updated yet , try again a bit later ...
In Topic nice one
Nice job m8
QuoteOriginally posted by T?M??r?V?ll?R
In Topic nice one
Nice job m8
thx timetraveler
the next ver will be in a rarred archive,... and will prolly have the birthdays of many celebrities ... it will also have a switch option for the title because ppl may not want that ;)
really nice ..
i have done some adding of (dead) celbs... now it would be nicest (i think) to have a seperate Memorial.txt file .. or table ..
so that they don't get announced in the hub all the time being 106 today ... even nicer would be a possibility to show a ? and calculate the time from death to now ?
like:
? -=Sergeant_Pepper=- ? passed away 20 years ago today :0(
hmm maybe change the bot name ? .. ;0)
possible ?
The celebrities in the tBirthdays table will have a ":+-" prefix ...
so that the script sees it and doesnt announce .. I am in the process of getting //www.celebrity-link.com tabled ;)
uhm ... I managed to have approximately 4 1/2 thousand celebrity birthdays and the mem of the script climbs to about 2Mb when that table is loaded ... so I'll add a switch for it ..
About the deaths of those I am not sure ... I dont think it is similar to what this script is doing ...
The new ver will also have signs of the Zodiac circle intergrated ... hehehe
way 2 go herodes, looking forward to that one ^^
Thx for ur good words Psycho_Chihuahua
What u have been looking forward to is here .. ;)
BirthdayMan v3.5 is out ...
-- v3.5
--- added integration of zodiac signs in various parts of the script
--- added celebrities birthdays with a switch to load or not the file
--- added celebcmd ,... works like findcmd but for celebrities
--- added switch for displaying birthday in topic
grab it from here pls (http://www.plop.nl/ptokaxbots/Herodes.php)
** if u cant find it, it should be because the page
** isnt updated yet , try again a bit later ...
QuoteOriginally posted by Herodes
Hello BirthdayMan v3 is out ...
-- v 3
--- ability to display the Birthday nicks in the topic of the hub ... ( all of them ... the Offline ones are in parentheses like (Herodes))
--- added agecmd to get exact age
--- added bhelpcmd
--- added display of birthdays in the findcmd
--- added ability for pm or main cmds .. ;)
--- added in list birthdays cmd the signaling of the ppl who have their birthday the present day ..
grab it from here pls (http://www.plop.nl/ptokaxbots/Herodes.php)
** if u cant find it, it should be because the page
** isnt updated yet , try again a bit later ...
thanks is working fine :D
hmm doesn't seem to load the celeb file :(
yeah I made that on purpose not to scare away any1 ( mem issues )
look for this ..
loadcelebs = 0
and change it to loadcelebs = 1
btw I think the explanations given after each of the settings is enough ... if not pls post back with recommendations ..
Duh should of seen that lol
But still 1 thing
when i give in !birthdays, the celebs shouldnt show as well i guess... but only when the !celebs cmd is used.... would make it a lot easier when more then 2 or 3 Users to it at the same time...
Hope u understand what i'm blabbering about :D
Not sure if anione see this but when in version 3 i have topic turned on this happens
? Hub Name : .::T?M?`?::?R?nC?: (?_?)b::S??C?::Fr??K?::. - Today is the birthday of the following user (:T??:Exorcist) - Today is the birthday of the following user (:T??:Exorcist) - Today is the birthday of the following user (:T??:Gianni) - Today is the birthday of the following user :T??:Gianni - Today is the birthday of the following user (:T??:Gianni) - Today is the birthday of the following user (:T??:Gianni) - Today is the birthday of the following user (:T??:Gianni) - Today is the birthday of the following user :T??:Gianni
this is from 2 days to get rit of it i had to tun it off and changed the hubname back
had not noticed that as i dont use the Topic feature 8o
Psycho_Chihuahua : I am gonna get some more testing on the usability of that table ..
Timetraveler : I am terribly sorry about that ... I am gonna rectify as soon as possible ...
[*note*] the offline users who have their birthday appear in parentheses ' (username) ' in topic if it is enabled ... Would anyone think that it would be more appropriate to eliminate those,... or should that be kept as is ? or maybe add another switch for that ...
PS: I apologise and admit that this ver may not have been thouroughly tested .. next ver will resolve bugs too ..
any more suggestions are more than welcome .. pls post :)
QuoteOriginally posted by Herodes
Psycho_Chihuahua : I am gonna get some more testing on the usability of that table ..
Timetraveler : I am terribly sorry about that ... I am gonna rectify as soon as possible ...
[*note*] the offline users who have their birthday appear in parentheses ' (username) ' in topic if it is enabled ... Would anyone think that it would be more appropriate to eliminate those,... or should that be kept as is ? or maybe add another switch for that ...
PS: I apologise and admit that this ver may not have been thouroughly tested .. next ver will resolve bugs too ..
any more suggestions are more than welcome .. pls post :)
Np m8 i dont mind testing, as long as you dont mind me pitching in my 5 cents worth ^^
just tryin 2 help you :D
QuoteOriginally posted by Psycho_Chihuahua
Np m8 i dont mind testing, as long as you dont mind me pitching in my 5 cents worth ^^
just tryin 2 help you :D
Its all good Psycho ,..
any input is more than welcome, many many thanks .. ;D
Dont mind a bug thats what whe are here for to find those ;)
QuoteOriginally posted by T?M?†r?V?ll?R
Not sure if anione see this but when in version 3 i have topic turned on this happens
• Hub Name : .::T?M?`?::†R?nC€: (?_?)b::S??C?::Fr€?K?::. - Today is the birthday of the following user (:T?†:Exorcist) - Today is the birthday of the following user (:T?†:Exorcist) - Today is the birthday of the following user (:T?†:Gianni) - Today is the birthday of the following user :T?†:Gianni - Today is the birthday of the following user (:T?†:Gianni) - Today is the birthday of the following user (:T?†:Gianni) - Today is the birthday of the following user (:T?†:Gianni) - Today is the birthday of the following user :T?†:Gianni
this is from 2 days to get rit of it i had to tun it off and changed the hubname back
i got the same thing on the topic psycho when some one get his birthday, i have been away for i while so my answer is coming now :P but i gonna see if i can find it and fixit the topic thing, but just now i fix my server to have my own hub and other stuff.
Theres also a Topic Change script whizzing round somewhere in here, very easy to change the topic whenever you like ^^
I for my sake turned off the Topic function in the script and also the celeb function cause it was showing something like 4000 celeb birthdays to everyones birthday and as soon as 2 users used it the hub stood still for a couple of seconds
in 3.8 the topic bug is fixed and the celebs are displayed in a much more functional way and not in every bday ...
also added a biorythym readout ...
coming soon .. ;)
mmm my birthday is in 22 december but the script is showing that i am sagittarius but i am capricorn...
Dec 22 is considered a cusp date. it depends on the year you were born to determine which sign the sun is in. You may be Sagitarious, you may be Capricorn or you may be a true cusp and be both if your birth time falls within a spacific 12 hour gap.
I couldnt have know that terribly detailed info ;)
thx g00fus ...
@mazmaajinsh :
sorry but I dont think I can put any effort in that bug ... minor as it is.. :/
may I request commands of this script ?
They should come up when you type : !bhelp
if nothing happens then try opening the .lua file with Notepad.exe and reading the comments inside it ..
Thanks for your bot, we use it in the hub (duh :D )
Any chance there will be a lua5 version of it soonish?
QuoteOriginally posted by Jorgo
Thanks for your bot, we use it in the hub (duh :D )
Any chance there will be a lua5 version of it soonish?
Having a lot to do that dont relate to scirpting in any conceptional way lately. I hope that I'll find time for making it into L5 but no promises since I just have 2 months for submiting myself to the obligatory military service we have here in Greece. In the meantime if any1 wants to occupy his/her time with making this script usable with the latest Ptx do so by all means ...
Thanks for the heads up! :-)