me ... again
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

me ... again

Started by EXNET OWNER, 12 August, 2004, 14:35:50

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

EXNET OWNER

I also would like a bot which displays the time on request insted of by a timer when i use the command

+time

I cant do it i have been workin on it but cant seem to make it work, it has no errors but will not display the time and date

monnie

#1
Greetings

I have this one working fine...
The Autor is Malukito Jr..

Bot = "Rel?gio"

function Main()
   frmHub:RegBot(Bot)
end

function DataArrival(user, data)
   if (strsub(data,1,1)=="<") or (strsub(data,1,5+strlen(Bot))=="$To: "..Bot) then
   data=strsub(data,1,strlen(data)-1)
   s,e,cmd = strfind(data,"%b<>%s+(%S+)")
      if (cmd=="+horas") then
         horas = date("%H")
         minutos = date("%M")
         user:SendPM(Bot, "S?o "..horas..":"..minutos)
         return 1
      end
   end
end


If you rather like it in english...

Bot = "Clock"

function Main()
   frmHub:RegBot(Bot)
end

function DataArrival(user, data)
   if (strsub(data,1,1)=="<") or (strsub(data,1,5+strlen(Bot))=="$To: "..Bot) then
   data=strsub(data,1,strlen(data)-1)
   s,e,cmd = strfind(data,"%b<>%s+(%S+)")
      if (cmd=="+time") then
         hours = date("%H")
         minutes = date("%M")
         user:SendPM(Bot, "It's "..hours..":"..minutes)
         return 1
      end
   end
end


Hope you've got served...


                                           monnie

plop

no need 2 waste 3 globals on that.
beside using hours and minutes on seperate calls can cause faulty results.
Bot = "Clock"

function Main()
   frmHub:RegBot(Bot)
end

function DataArrival(user, data)
   if (strsub(data,1,1)=="<") or (strsub(data,1,5+strlen(Bot))=="$To: "..Bot) then
      data=strsub(data,1,strlen(data)-1)
      local s,e,cmd = strfind(data,"%b<>%s+(%S+)")
      if (cmd=="+time") then
         user:SendPM(Bot, "It's "..date("%X").."|")
         return 1
      end
   end
end
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 <----<<

BottledHate

a little spin on plops for more customization in the time/date output....

Bot = "Clock"

function Main()
   frmHub:RegBot(Bot)
end

function GetTime()
	a = date("%a")
	I = date("%I")
	M = date("%M")
	S = date("%S")
	b = date("%b")
	d = date("%d")
	z = date("%z")
	y = date("%y")
	p = date("%p")
	Date = a..", "..I..":"..M..":"..S.." "..p..", "..b.."/"..d.."/"..y.." "..z
	return Date
end

function DataArrival(user, data)
   if (strsub(data,1,1)=="<") or (strsub(data,1,5+strlen(Bot))=="$To: "..Bot) then
      data=strsub(data,1,strlen(data)-1)
      local s,e,cmd = strfind(data,"%b<>%s+(%S+)")
      if (cmd=="+time") then
         user:SendPM(Bot, "It's "..GetTime().."|")
         return 1
      end
   end
end


more codes:
| %a   abbreviated weekday name   "Mon"...
| %A   full weekday name      "Monday"...
| %b   abbreviated month name      "Jan"...
| %B   full month name         "January"...
| %c   locale-specific date and time
| %d   day of the month as integer   01-31
| %H   hour (24-hour clock)      00-23
| %I   hour (12-hour clock)      01-12
| %j   day of the year as integer   001-366
| %m   month as integer      01-12
| %M   minute as integer      00-59
| %p   locale AM/PM designation
| %S   second as integer      00-61 (allow for up to 2 leap seconds)
| %U   week number of the year      00-53 (week number 1 has 1st sunday)
| %w   weekday as integer      (0-6, sunday=0)
| %W   week number of the year      00-53 (week number 1 has 1st monday)
| %x   locale specific date
| %X   locale specific time
| %y   year without century      00-99
| %Y   year with century      1900...
| %z   time zone name


-BH
Homepage: www.bottledhate.webhop.org

Compiling  Lua scripts is LAME!!!!!

??????Hawk??????

hi EXNET OWNER

   click on my sig for another time script   :))

plop

@BottledHate: re-read my previous post really carefully.
you make the same mistake which i fixed on the script monnie posted.
never do multiple calls 2 the date, use 1 and splitt it when needed with a strfind.

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 <----<<

BottledHate

#6
thanks plop!

Bot = "Clock"

function Main()
   frmHub:RegBot(Bot)
end

function GetTime()
   local _,_,a, A, b, B, c, d, H, I, j, m, M, p, S, U, w, W, x, y, Y, z = strfind(date(
      "|%a|%A|%b|%B|%c|%d|%H|%I|%j|%m|%M|%p|%S|%U|%w|%W|%x|%y|%Y|%z|"), 
      "|(.-)|(.-)|(.-)|(.-)|(.-)|(.-)|(.-)|(.-)|(.-)|(.-)|(.-)|(.-)|(.-)|(.-)|(.-)|(.-)|(.-)|(.-)|(.-)|(.-)|")
   local Date = a..", "..I..":"..M..":"..S.." "..p..", "..b.."/"..d.."/"..y.." "..z --Example formating... output: Thu, 04:05:23 PM, Aug/12/04 Pacific Daylight Time
   return Date
end

function DataArrival(user, data)
   if (strsub(data,1,1)=="<") or (strsub(data,1,5+strlen(Bot))=="$To: "..Bot) then
      data=strsub(data,1,strlen(data)-1)
      local s,e,cmd = strfind(data,"%b<>%s+(%S+)")
      if (cmd=="+time") then
         user:SendPM(Bot, "It's "..GetTime().."|")
         return 1
      end
   end
end

plop rules.. if it wasn't for him i'd wouldn't have learned shit!

-BH
Homepage: www.bottledhate.webhop.org

Compiling  Lua scripts is LAME!!!!!

plop

the best way is 2 use 1 call, date().
the resulting string can be splitted and processed into the format you want it 2 show.
a good example is hidden away in a.i..
[06:45]  !time
[06:45] <-Bure-> It is quarter before seven on Friday the thirthteenth of August twothousend and four (hubtime/date, not your local time/date)
it uses 1 single call 2 date() without arguments and it's fully formatted as you can see.

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 <----<<

SMF spam blocked by CleanTalk