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.

Count ban time

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
B
BigToe
Halfop
Posts: 99
Joined: Thu Dec 30, 2010 4:49 pm

Count ban time

Post by BigToe »

Hi,

Looking for a script that will log channel (#channel1) bans as in: when they were set, by who, what is the ban and announce in #channel2 every 30 mins how long its been since those bans added.

ie:

#channel1:

[14:03] * johnny sets mode: +b *!*@sphex.users.quakenet.org
[14:15] * johnny sets mode: +b *!*@tony.users.quakenet.org

[17:33] * johnny sets mode: -b *!*@tony.users.quakenet.org

#channel2:

[14:33] <Bot> *!*@sphex.users.quakenet.org is still banned in #channel1, the ban was set 30 minutes ago by johnny
[14:45] <Bot> *!*@tony.users.quakenet.org is still banned in #channel1, the ban was set 30 minutes ago by johnny


[18:03] <Bot> *!*@sphex.users.quakenet.org is still banned in #channel1, the ban was set 240 minutes ago by johnny

This applies only to bans that are still listed as bans in #channel1, not those that have been removed in the meantime
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Something like this should do the trick... Code is untested though.

Code: Select all

namespace eval BanReport {
  variable SourceChannel "#channel1"
  variable DestinationChannel "#channel2"

  proc reportBans {minute hour day month weekday} {
    variable SourceChannel
    variable DestinationChannel
    foreach ban [chanbans $SourceChannel] {
      puthelp "PRIVMSG $DestinationChannel :[lindex $ban 0] is still banned in ${SourceChannel}, the ban was set [expr [lindex $ban 2] / 60] minutes ago by [lindex $ban 1]"
    }
  }
  bind cron - "*/30" [namespace code reportBans]
}
NML_375
B
BigToe
Halfop
Posts: 99
Joined: Thu Dec 30, 2010 4:49 pm

Post by BigToe »

Hi, thanks for the script!

It seems to be working pretty good, one thing though, it doesn't calculate the bans' time correctly.. I mean, it doesn't look at the banlist and check when the ban was aded right? because when I restarted the bot, 30 mins later when announcing the bans it said all the bans were added 30 mins ago and that wasn't the case
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

The script checks the banlist in the channel, not the bot's internal banlist. If a ban is already present when the bot joins the channel, it will use it's own time of joining the channel as the ban creation time.
NML_375
User avatar
Get_A_Fix
Master
Posts: 206
Joined: Sat May 07, 2005 6:11 pm
Location: New Zealand

Post by Get_A_Fix »

you could alternatively have the bot match the raw numeric for bans, to match when they were really set on channel.

For example, /mode #channel1 b

This would return a list of banmasks, in the order they were banned (latest at the top, with older bans below). You could match the (time it was set) and either keep the ( ) in output, or parse them off.

It's an idea, but personally, the code that nml375 posted is perfect and would only require minimal tweaking to work on a raw bind.
We explore.. and you call us criminals. We seek after knowledge.. and you call us criminals. We exist without skin color, without nationality, without religious bias.. and you call us criminals.
Post Reply