Author Topic: Adding a time stamp  (Read 1422 times)

0 Members and 1 Guest are viewing this topic.

Offline FunkyFender55

  • Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
Adding a time stamp
« on: 19 November, 2003, 02:21:56 »
I'm modifying the Request Bot into a Message board. I would like to add a timestamp to the messages so people can tell when they were posted. Here's the script:

Code: [Select]
--//Request Board Bot
--//(Mr420)
--//A Simple Request Board For The Hub
--//Version 3.0

botname = "Beta_Board"
bot_email = "mr420smail@yahoo.com"
bot_speed = "More than j00"
bot_descr = "Type !help In PM To Me."
bot_share_size = 666.01
my_info_string = "$MyINFO $ALL "..botname.." "..bot_descr.."$ $"..bot_speed..strchar( 1 ).."$"..bot_email
TimeSpanInMinutes = 6000   --//You May Change This

function Main()
frmHub:RegBot(botname)
my_info_string = "$MyINFO $ALL "..botname.." "..bot_descr.."$ $"..bot_speed..strchar( 1 ).."$"..bot_email..
"$"..bot_share_size.."$"
SetTimer(TimeSpanInMinutes*33000)
StartTimer()
end

function NewUserConnected(curUser)
curUser:SendData( my_info_string )
end

function OpConnected(curUser)
curUser:SendData( my_info_string )
end

function OnTimer()

--//Note that a "|" denotes a break in the line

SendToAll("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
SendToAll("    HI THERE!!!!, This is the 404 Hub Message Board.")
SendToAll("    Need to send a message to everyone? Need a certain file?")
SendToAll("    POST IT HERE!!!")
SendToAll("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
SendToAll("  To make a post, Simply Send !help As A Private Message")
SendToAll("  To Message_Board.  Please Be As Specific As You Can For Requests.")
SendToAll("  Remember To Check Back To See If Someone Has Replied.")
SendToAll("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")

end

function tokenize (inString,token)
_WORDS = {}
local matcher = "([^?"..token.."]+)"
gsub(inString, matcher, function (w) tinsert(_WORDS,w) end)
return _WORDS
end

function GetArgs(data)
s,e,whoTo,from,cmd,arg,arg2 = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)%s+(.*)")
return arg,arg2
end

function DataArrival(user, data)
if(strsub(data, 1, 4) == "$To:") then
data=strsub(data,1,strlen(data)-1)
s,e,whoTo = strfind(data,"$To:%s+(%S+)")
if (whoTo == botname) then
s,e,whoTo,from,cmd = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)")

if (cmd=="!help") then
user:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
user:SendPM(botname,"    This is the Message_Board!")
user:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
user:SendPM(botname," Type !help To View This Help Menu.")
user:SendPM(botname," Type !post To Make A Post.")
user:SendPM(botname," Type !view To View The Posts/Requests/Updates.")
user:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
user:SendPM(botname," Please Be As Specific As You Can.")
user:SendPM(botname," Please keeps your posts to a minimum.")
user:SendPM(botname," Spam in here will result in my permanent departure.")
user:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
end

if (cmd=="!post") then
SendToAll("***New Post Added***")
arg= GetArgs(data)
local handle=openfile("request.dat","a")
write(handle,""..user.sName.." posted : "..arg.."?")
user:SendPM(botname,"Post saved ....")
closefile(handle)
end

if (cmd=="!view") then
handle2=openfile("request.dat","r")
if (handle2==nil) then
else
line = read(handle2,"*a")
line=strsub(line,1,strlen(line)-1)
linearray=tokenize(line,"?")
for i=1,linearray.n do
user:SendPM(botname,linearray[i])
end
closefile(handle2)
end

end
end
end
end

PtokaX forum

Adding a time stamp
« on: 19 November, 2003, 02:21:56 »

Offline plop

  • Forum God
  • ****
  • Posts: 2 464
  • Karma: +37/-0
(No subject)
« Reply #1 on: 19 November, 2003, 12:47:18 »
try changing this line.
Code: [Select]
write(handle,""..user.sName.." posted : "..arg.."?")
for this 1.
Code: [Select]
write(handle,""..user.sName.." posted on "..date("%m-%d-%Y -- %X").." : "..arg.."?")
plop
« Last Edit: 19 November, 2003, 12:47:37 by plop »
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Offline FunkyFender55

  • Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
(No subject)
« Reply #2 on: 20 November, 2003, 02:11:48 »
It work. Thanks man.

Offline plop

  • Forum God
  • ****
  • Posts: 2 464
  • Karma: +37/-0
(No subject)
« Reply #3 on: 20 November, 2003, 12:18:20 »
yw

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

PtokaX forum

(No subject)
« Reply #3 on: 20 November, 2003, 12:18:20 »