PtokaX forum

Archive => DiXBoT => AllInOne Scripts => Archived 5.1 boards => DiXBoT - Custom modules => Topic started by: Snooze on 08 June, 2007, 20:16:41

Title: Greeting - Time
Post by: Snooze on 08 June, 2007, 20:16:41
By request, a small mod of this script by Mutor (http://forum.ptokax.org/index.php?topic=7140#new)..


--[[

TOD LoginMsg 1.0 LUA 5.0/5.1

By Mutor 05/17/07

Requested by butch

Greets connection by time of day with UTC timezone


Example:

<Mutor's Archive 5.1.1>

Good Afternoon Mutor

Today is Thursday 17 May 2007 and the current time is 17 02 -5 UTC


[DXB]: Converted to DiXBoT on request - 7:46 PM 6/8/2007 by Snooze

]]

TimeGreet = {

["NewUserConnected"] = {
doTimeGreet = function(user, data)
local h,g = tonumber(os.date("%H")),""
local Tab = {
[1] = {12,"Good Morning"},
[2] = {18,"Good Afternoon"},
[3] = {24,"Good Evening"},
}
for i,v in ipairs(Tab) do
if h < v[1] then g = v[2] break end
end
local msg = "\r\n\r\n\t"..g.." "..user.sName.."\r\n\r\n"..
"\tToday is "..os.date("%A %d %B %Y").." and the current time is "..
os.date("%H %M").." "..TimeGreet.Func.doTimeZone().."\r\n\r\n"
user:SendData(frmHub:GetHubName(),msg)
end,
},
["OpConnected"] = {
doTimeGreet = function(user, data)
local h,g = tonumber(os.date("%H")),""
local Tab = {
[1] = {12,"Good Morning"},
[2] = {18,"Good Afternoon"},
[3] = {24,"Good Evening"},
}
for i,v in ipairs(Tab) do
if h < v[1] then g = v[2] break end
end
local msg = "\r\n\r\n\t"..g.." "..user.sName.."\r\n\r\n"..
"\tToday is "..os.date("%A %d %B %Y").." and the current time is "..
os.date("%H %M").." "..TimeGreet.Func.doTimeZone().."\r\n\r\n"
user:SendData(frmHub:GetHubName(),msg)
end,
},

["Func"] = {
doTimeZone = function()
--TimeGreet.Func.doTimeZone = function()
local h,m = math.modf((os.time()-os.time(os.date"!*t"))/ 3600)
return string.format("%+d UTC",(h + (60 * m)))
end,
},
}
DxbModule = TimeGreet


Simply copy to a textfile --> save as TimeGreet.lua  --> copy to the "scripts/DiXBoT/CoreSystem/" folder and restart scripts (a guide will be displayed in mainchat on how to activate this module)


All credits goes to Mutor for this script..

Can be downloaded from the DiXBoT Download Section - MODs.]DiXBoT Download Section - MODs. (http://www.dixbot.com)

-Snooze