PtokaX forum

Archive => Archived 4.0 boards => Help with Lua 4 scripts => Topic started by: [T-G-T]M@sto on 05 November, 2003, 08:58:25

Title: Date
Post by: [T-G-T]M@sto on 05 November, 2003, 08:58:25
Has this part anything to do with the Date in the script:
-- The timezone for your country (How many hours is the dirrerence from GMT)
gmt = "(+1 GMT)"

 textArray = {}
 QWarray = {}
 antall = 0

??????
I use FunBoTz by JenZen? but want the date to be danish like: Mandag, Tirsdag e.t.c.
Title:
Post by: Skrollster on 05 November, 2003, 11:25:24
No, that ins't the right place to look..

look for date("some textstring")

if you find it, post it here

//Skrollster
Title:
Post by: [T-G-T]M@sto on 05 November, 2003, 12:24:16
QuoteOriginally posted by Skrollster
No, that ins't the right place to look..

look for date("some textstring")

if you find it, post it here

//Skrollster
-- zFuNBoTz by JenZen?.
-- Everything in this script file is ? Copyrightet by JenZen? 2003

-- This release was meant for [DK]Burger-Banden - burger-banden.kyed.com


-- Defines the name of the bot
Bot = "[Guard]"

-- The timezone for your country (How many hours is the dirrerence from GMT)
gmt = "(+1 GMT)"

 textArray = {}
 QWarray = {}
 antall = 0


function Main()

  frmHub:RegBot(Bot)
loadText()
getLine()
SetTimer(1*60000)
StartTimer()

end

function OnTimer()
     getLine()
end


-- Triggers that will be send in the mainchat. This is triggers that are loaded from textfiles.
triggertext = {
      ["+shootafaker"]="zFuNBoTz/shootafaker.txt",
      ["+gun"]="zFuNBoTz/gun.txt",
      ["+hey"]="zFuNBoTz/hey.txt",
      ["+kaffe"]="zFuNBoTz/kaffe.txt",
      ["+weed"]="zFuNBoTz/weed.txt",
      ["+love"]="zFuNBoTz/love.txt",
      ["+morgen"]="zFuNBoTz/morgen.txt",
      ["+sleep"]="zFuNBoTz/sleep.txt",
      ["+smoke"]="zFuNBoTz/smoke.txt",
      ["+vel"]="zFuNBoTz/vel.txt",
      ["+warning"]="zFuNBoTz/warning.txt",
      ["+lol"]="zFuNBoTz/lol.txt",
      ["+delfin"]="zFuNBoTz/delfin.txt",
   }

-- Triggers that will be send in main chat. This is the triggers which have the reason text here.
Trigger = {
      ["+morgen"]=date("Good morning, [USER], today is %A the %d/%m %Y... did you know the time is %T "..gmt.."?"),
      ["+nat"]="[USER] siger godnat og sov godt! Vi ses i morgen her p? Blue Lagoon",
      ["+bed"]="[USER] siger godnat og sov godt! Vi ses i morgen her p? Blue Lagoon",
      ["+sleep"]="[USER] says good night and sleep well! See you all tomorrow at Blue Lagoon",
      ["+hey"]="Well hello hello [USER]!",
      ["+away"]="The user [USER] is going away and can not answer anymore Messages",
      ["-away"]="[USER] is back from away mode! Nice to have you back!",
      brb="Hurry up [USER] we miss you allready!",
      fuck="Heyy [USER] don't say that word!",
      ["+bye"]="See you later [USER] ( I hope )",
      lol="Loooool sq!",
      haha="Det er sq sjovt! Hehehe!",
      ["+tillykke"]="Du ?nskes TilLykke Med Dagen af [USER]! H?ber du m? f? en god dag!",
      cola="Cola?? F?j da [USER]! Hvad er det for en gang spr?jt at servere n?r man stadig kan k?be ?l!",
      wb="Welcome back!"
      
   }

-- These triggers will be sent in pm to the user. Loaded from text files
TriggerPrivate =    {
         ["+newbie"]="zFuNBoTz/newbie.txt",
         ["+nybe"]="zFuNBoTz/nybe.txt",
         ["+divx"]="zFuNBoTz/divx.txt",
         ["+adr"]="zFuNBoTz/adr.txt",
         ["+country"]="zFuNBoTz/country.txt",
         ["+gamekey"]="zFuNBoTz/gamekey.txt",
         ["+smiley"]="zFuNBoTz/forkortsmiley.txt",
         ["+moresmiley"]="zFuNBoTz/moresmiley.txt",
         ["+routerhelp"]="zFuNBoTz/routerhelp.txt",
         ["+kopiregler"]="zFuNBoTz/reglerkopiering.txt",

      }

function DataArrival(curUser, sData)

   if( strsub(sData, 1, 1) == "<" ) then
      -- get the msg only using regular expression
      s,e,msg = strfind(sData, "%b<> ([ -z]*)")
      if (msg == "+bed") then
            local text1 = ""
            readfrom("zFuNBoTz/bed1.txt")
            while 1 do
               local line = read()
               if (line == nil) then
                  break
               else
                  text1 = text1..line.."\r\n"
               end
            end
            readfrom()
            local text2 = ""
            readfrom("zFuNBoTz/bed2.txt")
            while 1 do
               local line = read()
               if (line == nil) then
                  break
               else
                  text2 = text2..line.."\r\n"
               end
            end
            readfrom()

            hey = random(1,2)
            if hey == 1 then
            SendToAll("[zFuNBoTz] - from "..curUser.sName,text1)
            elseif hey == 2 then
            SendToAll("[zFuNBoTz] - from "..curUser.sName,text2)
            end
         end



      -- look in the table
      for key, value in triggertext do
         if( strfind( strlower(msg), key) ) then
      answer, x = gsub(value, "%b[]", curUser.sName)
            local text = ""
            readfrom(answer)
            while 1 do
               local line = read()
               if (line == nil) then
                  break
               else
                  text = text..line.."\r\n"
               end
            end
            SendToAll("[zFuNBoTz] - from "..curUser.sName, text)
         end   
         readfrom()   
      end
      

      for key, value in Trigger do
         if( strfind( strlower(msg), key) ) then
            answer, x = gsub(value, "%b[]", curUser.sName)
            SendToAll( Bot, answer ) -- send bot's answer

         end
         
      end
   end
   if( strsub(sData, 1, 1) == "<" ) or ( strsub(sData, 1, 4) == "$To:") then
      s,e,msg = strfind(sData, "%b<> ([ -z]*)")
      for key, value in TriggerPrivate do
         if( strfind( strlower(msg), key) ) then
      answer, x = gsub(value, "%b[]", curUser.sName)
            local text = ""
            readfrom(answer)
            while 1 do
               local line = read()
               if (line == nil) then
                  break
               else
                  text = text..line.."\r\n"
               end
            end
            SendPmToNick(curUser.sName, Bot, text)
            
         end   
         readfrom()   
      end

end

data = strsub(sData,1,strlen(sData)-1)
s,e,cmd = strfind( data, "%b<>%s+(%S+)" )

      if (cmd=="+joke" or cmd=="!joke" or cmd=="+joke" or cmd=="-joke") then
         curUser:SendPM("[zFuNBoTz] - Joke from "..curUser.sName, txt2)
      return 1;
      end
      


      if (cmd=="!fun" or cmd=="!fun" or cmd=="+fun" or cmd=="-fun" or cmd=="+funbot" or cmd=="-funbot" or cmd=="!funbot") then
         SendPmToNick(curUser.sName, Bot, "\r\n\r\n       Current Fun commands on this hub:".."\r\n      +divx      -   Shows the DivX faq".."\r\n      +shootafaker   -    '44 Magnum Meets A Faker".."\r\n      +gun      -   BLAOW! Another Faker Bites The Dust!".."\r\n      +hey      -   Say Hello In Main Chat".."\r\n      +kaffe      -   Kaffetid!".."\r\n      +weed      -   Cheech & Chong Party Time!".."\r\n      +love      -   Groovy Kind Of Love".."\r\n      +morgen      -   Godmorgen I Hubben".."\r\n      +newbie      -   Direct Connect FAQ In English".."\r\n      +nybe      -   Direct Connect FAQ P? Dansk".."\r\n      +bed      -   Goin' To Bed".."\r\n      +smoke      -   Smokin'".."\r\n      +vel      -   Velkommen".."\r\n      +warning      -   Official Warning".."\r\n      +lol      -   Laugh Out Loud".."\r\n      +adr      -   Show Network Info".."\r\n      +away      -   Away Besked".."\r\n      -away      -   Tilbage p? hubben".."\r\n      +bye      -   Ses Senere".."\r\n      +tillykke      -   Tillykke Med Dagen".."\r\n      +nat      -   God Nat p? hubben".."\r\n      +country      -   Shows a list of all countrycodes".."\r\n      +gamekey   -   Shows keys and serials for the most popular games".."\r\n      +smiley      -   Shows some smileys and shortenings".."\r\n      +moresmiley   -   More smileys".."\r\n      +kopiregler   -   Viser de g?ldende regler for kopiering af digitale medier i DK".."\r\n      +routerhelp   -   Shows how u use active mode when you have a router or firewall".."\r\n")
               return 1;
      end


end

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

function loadText()
handle = openfile("zFuNBoTz/joke.txt", "r")
if (handle) then
local line = read(handle)
   while line do
      if ((line ~= "") and (strfind(line, "*", 1, plain))) then
      tinsert(textArray, line)
      antall = antall + 1
   end
   line = read(handle)
   end
closefile(handle)
end
end

function getLine()
 lngWord = random(1, antall)
 QWarray = tokenize(textArray[lngWord], "*")
 txt1 = QWarray[1]
 txt2 = QWarray[2]
end
Title: Anyone
Post by: [T-G-T]M@sto on 06 November, 2003, 19:57:22
Can't Anyone help me with this script ?
Title:
Post by: Skrollster on 06 November, 2003, 20:07:14
the intresting line is this one:

QuoteTrigger = {
["+morgen"]=date("Good morning, [USER], today is %A the %d/%m %Y... did you know the time is %T "..gmt.."?"),
["+nat"]="[USER] siger godnat og sov godt! Vi ses i morgen her p? Blue Lagoon",

i will see if i can get som additional information on how to use date() as you might now i'm not using my regular computer right now so i don't have all my bookmarks as i'm used to..

w8, i'll be back shortly
Title:
Post by: Skrollster on 06 November, 2003, 20:18:33
I'm back and i have now found the page i was looking for:
Microsofts strftime (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt_strftime.2c_.wcsftime.asp)

If you have a look here and download lua.exe (http://develop.svamberk.net/ptokax/site/download.php?file=lua_commandline.zip)

then you can start lua.exe in cmd and try out what results print(date("%A")) will give and so on...

i can't find any good and easy way to get it print the days in danish... :/

//skrollster
Title:
Post by: [T-G-T]M@sto on 06 November, 2003, 21:30:39
QuoteOriginally posted by Skrollster
I'm back and i have now found the page i was looking for:
Microsofts strftime (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt_strftime.2c_.wcsftime.asp)

If you have a look here and download lua.exe (http://develop.svamberk.net/ptokax/site/download.php?file=lua_commandline.zip)

then you can start lua.exe in cmd and try out what results print(date("%A")) will give and so on...

i can't find any good and easy way to get it print the days in danish... :/

//skrollster
Thanks but i dont understand all the english word. the print(date("%A")) give me the dayname in english and i can't find any help do it on the danish part  :(  I hope someone help me out
Title:
Post by: Skrollster on 06 November, 2003, 21:48:01
I'm not sure but try to specify it like this:

setlocale("den","time")
-- Triggers that will be send in main chat. This is the triggers which have the reason text here.
Trigger = {
["+morgen"]=date("Good morning, [USER], today is %A the %d/%m %Y... did you know the time is %T "..gmt.."?"),
["+nat"]="[USER] siger godnat og sov godt! Vi ses i morgen her p? Blue Lagoon",
["+bed"]="[USER] siger godnat og sov godt! Vi ses i morgen her p? Blue Lagoon",
["+sleep"]="[USER] says good night and sleep well! See you all tomorrow at Blue Lagoon",
["+hey"]="Well hello hello [USER]!",
["+away"]="The user [USER] is going away and can not answer anymore Messages",
["-away"]="[USER] is back from away mode! Nice to have you back!",
brb="Hurry up [USER] we miss you allready!",
fuck="Heyy [USER] don't say that word!",
["+bye"]="See you later [USER] ( I hope )",
lol="Loooool sq!",
haha="Det er sq sjovt! Hehehe!",
["+tillykke"]="Du ?nskes TilLykke Med Dagen af [USER]! H?ber du m? f? en god dag!",
cola="Cola?? F?j da [USER]! Hvad er det for en gang spr?jt at servere n?r man stadig kan k?be ?l!",
wb="Welcome back!"
}
Title:
Post by: [T-G-T]M@sto on 06 November, 2003, 22:00:23
QuoteOriginally posted by Skrollster
I'm not sure but try to specify it like this:

setlocale("den","time")
-- Triggers that will be send in main chat. This is the triggers which have the reason text here.
Trigger = {
["+morgen"]=date("Good morning, [USER], today is %A the %d/%m %Y... did you know the time is %T "..gmt.."?"),
["+nat"]="[USER] siger godnat og sov godt! Vi ses i morgen her p? Blue Lagoon",
["+bed"]="[USER] siger godnat og sov godt! Vi ses i morgen her p? Blue Lagoon",
["+sleep"]="[USER] says good night and sleep well! See you all tomorrow at Blue Lagoon",
["+hey"]="Well hello hello [USER]!",
["+away"]="The user [USER] is going away and can not answer anymore Messages",
["-away"]="[USER] is back from away mode! Nice to have you back!",
brb="Hurry up [USER] we miss you allready!",
fuck="Heyy [USER] don't say that word!",
["+bye"]="See you later [USER] ( I hope )",
lol="Loooool sq!",
haha="Det er sq sjovt! Hehehe!",
["+tillykke"]="Du ?nskes TilLykke Med Dagen af [USER]! H?ber du m? f? en god dag!",
cola="Cola?? F?j da [USER]! Hvad er det for en gang spr?jt at servere n?r man stadig kan k?be ?l!",
wb="Welcome back!"
}
Nope that dosent help  :(  but thanks for trying
The hub crash when i add the line
Title:
Post by: Skrollster on 06 November, 2003, 22:14:42
crash, that isn't too good..

try to put the line in Main()

i'v only tried it with lua.exe and it works..

//skrollster
Title:
Post by: [T-G-T]M@sto on 06 November, 2003, 22:19:02
QuoteOriginally posted by Skrollster
crash, that isn't too good..

try to put the line in Main()

i'v only tried it with lua.exe and it works..

//skrollster
Like function Main(setlocale("dan","time")  ?
Title:
Post by: Skrollster on 06 November, 2003, 22:28:12
no like:

function Main()
frmHub:RegBot(Bot)
loadText()
getLine()
SetTimer(1*60000)
StartTimer()
setlocale("dan","time")
end
Title:
Post by: [T-G-T]M@sto on 06 November, 2003, 22:40:30
QuoteOriginally posted by Skrollster
no like:

function Main()
frmHub:RegBot(Bot)
loadText()
getLine()
SetTimer(1*60000)
StartTimer()
setlocale("dan","time")
end
Nope  :(  The hub crach
Ig i only use setlocale("dan") nothing happens at all
Title:
Post by: Skrollster on 06 November, 2003, 22:43:20
try setlocale("dan", "all")

i'm just guessing now
Title:
Post by: [T-G-T]M@sto on 06 November, 2003, 22:45:10
QuoteOriginally posted by Skrollster
try setlocale("dan", "all")

i'm just guessing now
Thanks But i found the answer It WAS setlocale("dan") i just made 1 space to many  :D  Thank you M8  ;)
Title:
Post by: Skrollster on 06 November, 2003, 22:50:22
ok, so ptokax doesn't accept that we just set the time local to be our own, we have to set it all.... thanks..
Title:
Post by: [T-G-T]M@sto on 06 November, 2003, 22:53:10
QuoteOriginally posted by Skrollster
ok, so ptokax doesn't accept that we just set the time local to be our own, we have to set it all.... thanks..
AND the script need to "restart script" twice before it works and i dont know Why
Title:
Post by: Skrollster on 06 November, 2003, 22:59:16
sure?
did you save the first time??
sounds strange other...
Title:
Post by: [T-G-T]M@sto on 06 November, 2003, 23:01:49
QuoteOriginally posted by Skrollster
sure?
did you save the first time??
sounds strange other...
Yep i'm sure Try it and see - Strange but true
Title:
Post by: Skrollster on 06 November, 2003, 23:02:44
Ok, i belive you, seen strange things before..
Title: next problems
Post by: [T-G-T]M@sto on 08 November, 2003, 09:33:52
Now this date problems was solved - now we take the next step  :D
When my hub runs 24 hours and i use the trigger +morgen the script still tell me the day before. i try explain in my pure english

Friday: i use +morgen and the triggers tell me it's friday

Satrday: i use +morgen and the script tell me it's Friday  X(  

I need to "Restart script" before it's change day-
How can i make the script automatic update the date / time ?
Title:
Post by: Skrollster on 08 November, 2003, 15:22:39
change this:
["+morgen"]=date("Good morning, [USER], today is %A the %d/%m %Y... did you know the time is %T "..gmt.."?"),

to:

["+morgen"]=function() return date("Good morning, [USER], today is %A the %d/%m %Y... did you know the time is %T "..gmt.."?") end,

*edit* or maybe don't.. hmm..

i have to think for a while now..