This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Math problem with regexp

Old posts that have not been replied to for several years.
Locked
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Math problem with regexp

Post by Alchera »

Hi,

The following nippet of code is giving me headaches
if {![regexp -- {^([0-9]*[dhm])([0-9]*[dhm])?([0-9]*[dhm])?$} $expire]} {
set expire -1
set index 2
} else {
set e $expire
if {![regexp -- {([0-9]*)m} $e -> min] || ($min == "")} {set min 0}
if {![regexp -- {([0-9]*)h} $e -> hour] || ($hour == "")} {set hour 0}
if {![regexp -- {([0-9]*)d} $e -> day] || ($day == "")} {set day 0}
set expire [expr ($min)+($hour*60)+($day*1440)]
set index 3
}
-----
newchanban $channel $target_hostmask $nick $reason $expire none
Typing "ban *!*stardust@* 2d Test" in the channel, for instance, gives me a ban of 1 day and not the 2 days I want and a ban of 5d gives me 4.

Any help will definitely be appreciated. :)
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

Add a putlog after your expr of the value of expire....
Should let you know if the problem is happening there, or somewhere after expire is set...
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Hello again :)
Add a putlog after your expr of the value of expire....
Done, and the math seems to be OK.

In channel: ban *!*stardust@* 5d Test

Results in DCC:
[03:37] <Barry> [03:37] <<Alchera@#aussie-aussie>> !Alchera! ban *!*stardust@* 5d Test
[03:37] <Barry> [03:37] Day = 5 Hour = 0 Min = 0 Expire = 7200
[03:38] <Barry> Channel bans for #aussie-aussie: (* = not placed by bot)
[03:38] <Barry> [ 1] *!*stardust@* (expires in 4 days)
[03:38] <Barry> Alchera: Test
[03:38] <Barry> Created 03:37
Am I misreading what eggdrop is telling me in DCC?
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

Perhaps eggdrop doesn't count the current day as one of the days...
This would most likely be the case...
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Hi,
Perhaps eggdrop doesn't count the current day as one of the days...
Would appear that is the case and it's a minor thing anyway. I'm just glad it wasn't what I'd written. LOL

Thanks for the help :)
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Well, considering as soon as you place the ban, the countdown starts, it only takes one second to pass before it turns to 4 days, 23 hours, 59 mins and 59 sec.

Eggdrop shortens it to the days only.

I will need to check on that in the source though.
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Interestingly enough, setting a ban of 1 day results in the following:

[20:49] <Barry> Channel bans for #aussie-aussie: (* = not placed by bot)
[20:49] <Barry> [ 1] *!*hutch@* (expires at 20:49)
[20:49] <Barry> Alcheri: Test
[20:49] <Barry> Created 20:49

Now I'm assuming that's 20:49 the next day as the ban remained.
A ban of 5 days (that shows 4) would be counted 24 hours after the ban is set and would be a total of 5 days all up?

The way eggdrop handles this has now got my curiosity up. :)
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
Locked