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.

Detecting dynamic bans expiry [not yet solved]

Help for those learning Tcl or writing their own scripts.
Post Reply
e
exezic
Voice
Posts: 3
Joined: Wed Jan 31, 2007 8:07 am
Location: Norway

Detecting dynamic bans expiry [not yet solved]

Post by exezic »

Code: Select all

[13:06] No longer banning *!*@exezic.users.quakenet.org on #dota.no (expired)
Is there any way to detect when this happens?

My intension is to make a web-based banlist, and I therefore need it to be updated whenever a dynamic ban expires.

I am aware of the possibility of using a timer to check a list up against the current banlist. But I would prefer to just update the list whenever it is changed, instead of having a timer running in the background all the time.

I appreciate all and any responses.
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Re: Detecting dynamic bans expiry [not yet solved]

Post by user »

exezic wrote:Is there any way to detect when this happens?
No. (you'd have to keep a copy of the list and compare it to the internal one to do that...but then you might as well create the html all over again)
Have you ever read "The Manual"?
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

If you have a botnet, you can bind to the botnet message.

Oh, and if you can compile your bot yourself, you can also consider to call something in src/mod/irc.mod/irc.c function check_expired_chanstuff() which seems to handle ban expires.
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
e
exezic
Voice
Posts: 3
Joined: Wed Jan 31, 2007 8:07 am
Location: Norway

Post by exezic »

Ok, thanks, I might try your advice De Kus.
e
exezic
Voice
Posts: 3
Joined: Wed Jan 31, 2007 8:07 am
Location: Norway

Post by exezic »

I cant seem to figure out what to bind to, I tried using:

Code: Select all

BOT

bind bot <flags> <command> <proc>
proc-name <from-bot> <command> <text>

Description: triggered by a message coming from another bot in the botnet. The first word is the command and the rest becomes the text argument; flags are ignored.

Module: core
But the bot didnt return anything with this code:

Code: Select all

bind bot - * randomprocname

proc randomprocname { from cmd text } {
  putlog "FROM: $from CMD: $cmd TEXT: $text"
}

Code: Select all

[17:14] BotA: cancel ban *!*@exezic.users.quakenet.org on #dota.no
which I received on another bot in the botnet (BotB), which was running the script...

Any ideas?

Maybe it's something about the bind I'm missing, considering it's not stackable... Maybe it should be bound to something. But I'm not sure what the <command> is...



On a sidenote; I have access to compiling the bot myself. So if you could point out what I would need to do to make the bot detect whenever a ban expire, that would do aswell :)


Ok, so I figured out it wasn't actually in src/mod/irc.mod/irc.c function. It was actually in src/mod/channels.mod/userchan.c

I also found my way to the code:

Code: Select all

/* Check for expired timed-bans.
 */
static void check_expired_bans(void)
{
  maskrec *u, *u2;
  struct chanset_t *chan;
  masklist *b;

  for (u = global_bans; u; u = u2) {
    u2 = u->next;
    if (!(u->flags & MASKREC_PERM) && (now >= u->expire)) {
      putlog(LOG_MISC, "*", "%s %s (%s)", BANS_NOLONGER, u->mask, MISC_EXPIRED);
      for (chan = chanset; chan; chan = chan->next)
        for (b = chan->channel.ban; b->mask[0]; b = b->next)
          if (!rfc_casecmp(b->mask, u->mask) &&
              expired_mask(chan, b->who) && b->timer != now) {
            add_mode(chan, '-', 'b', u->mask);
            b->timer = now;
          }
      u_delban(NULL, u->mask, 1);
    }
  }
  /* Check for specific channel-domain bans expiring */
  for (chan = chanset; chan; chan = chan->next) {
    for (u = chan->bans; u; u = u2) {
      u2 = u->next;
      if (!(u->flags & MASKREC_PERM) && (now >= u->expire)) {
        putlog(LOG_MISC, "*", "%s %s %s %s (%s)", BANS_NOLONGER,
               u->mask, MISC_ONLOCALE, chan->dname, MISC_EXPIRED);
        for (b = chan->channel.ban; b->mask[0]; b = b->next)
          if (!rfc_casecmp(b->mask, u->mask) &&
              expired_mask(chan, b->who) && b->timer != now) {
            add_mode(chan, '-', 'b', u->mask);
            b->timer = now;
          }
        u_delban(chan, u->mask, 1);
      }
    }
  }
}
I hope someone here can speak in c :)

Basically, I think I need some sort of bind which will react whenever a function is run. For instance, if I had put a function named event_expireban underneath

Code: Select all

       putlog(LOG_MISC, "*", "%s %s %s %s (%s)", BANS_NOLONGER,
               u->mask, MISC_ONLOCALE, chan->dname, MISC_EXPIRED);
like so:

Code: Select all

  /* Check for specific channel-domain bans expiring */
  for (chan = chanset; chan; chan = chan->next) {
    for (u = chan->bans; u; u = u2) {
      u2 = u->next;
      if (!(u->flags & MASKREC_PERM) && (now >= u->expire)) {
        putlog(LOG_MISC, "*", "%s %s %s %s (%s)", BANS_NOLONGER,
               u->mask, MISC_ONLOCALE, chan->dname, MISC_EXPIRED);
        -->event_expireban();<--
        for (b = chan->channel.ban; b->mask[0]; b = b->next)
          if (!rfc_casecmp(b->mask, u->mask) &&
              expired_mask(chan, b->who) && b->timer != now) {
            add_mode(chan, '-', 'b', u->mask);
            b->timer = now;
          }
        u_delban(chan, u->mask, 1);
      }
    }

and if the event_expireban() function would somehow be detected by

Code: Select all

bind evnt - expireban procedurename
in the same way rehash is detected by

Code: Select all

bind evnt - rehash procedurename
Then that would solve my problem, only problem is... I don't know how to do this :\

Any help will be greatly appreciated!
Post Reply