Q flag check

Release your script here.
State:
- Author
- What it does
- Perhaps a little guide.
- Also, if the snippet is of any use to the community, it has a chance of getting posted on the main page, so don't hesitate to submit/ask!

Q flag check

Postby cks » Thu Dec 25, 2008 11:31 pm

A similar script have been released here. http://sp00fed.org/viewtopic.php?f=14&t=210

I made another one, this one is using the Q command 'whoami'
So no multiple request to Q.

The script should start on start, if not, start the script by using /checktimer

It will check if it has flags on the channels its on (10 minute interval ($interval)), if not, strike one, and so on up to 3 (totalstrike), and the bot will part the channel.

If you encounter any bugs or errors please post them here.

Have fun

Change:
    inifile
    developmentchannel
    totalstrike
    excludechannels
    interval

Code: Select all
alias -l inifile { return file.ini }
alias -l developmentchannel { return #secret_channel }
alias -l totalstrike { return 3 }
alias -l excludechannels { return #channel1 #channel2 #channel3 }
alias -l interval { return 600 }

on *:START: checktimer

alias checktimer {
  .timer.checkflag 1 $interval checktimer
  .remini $inifile flags
  .msg Q whoami
}


alias checkflags {
  var %x = $comchan($me,0)
  while (%x) {
    var %c = $comchan($me,%x)
    if (!$readini($inifile,react,%c)) { .writeini -n $inifile react %c 0 }
    if (!$istok($excludechannels,%c,32)) {
      if (!$readini($inifile,flags,%c)) {
        var %r = $readini($inifile,react,%c)
        var %s = $calc(%r + 1)
        .writeini -n $inifile react %c %s
        .msg $developmentchannel Channel %c Strike %s out of $totalstrike

      }
      if ($readini($inifile,react,%c) == $totalstrike) {
        .msg $developmentchannel Channel: %c Strike out $totalstrike
        .remini $inifile react

        if ($me ison %c) {
          .part %c
        }
      }
    }
    dec %x
  }
}

on *:NOTICE:*:?: {
  if ($nick == Q) {
    if ($left($1,1) == $chr(35)) {
      .writeini -n $inifile flags $1 $2
    }
    if (*End of list* iswm $1-) {
      checkflags
    }
  }
}
cks
super poster
super poster
 
Posts: 264
Joined: Sun Nov 04, 2007 3:02 pm
Location: Denmark
Authnick: Sumsar

Re: Q flag check

Postby Mirora » Sat Jan 10, 2009 11:39 pm

Heey again Sumsar.. Think this would be better as tcl for my botservice :P


Cause this checks automatically riight ? :d
Mirora @ Evilcoders.eu
Mirora
newb
newb
 
Posts: 15
Joined: Mon Dec 08, 2008 4:00 am
Authnick: Mirora

Re: Q flag check

Postby SilverRain » Sat Jan 17, 2009 1:14 pm

Nice script, although it could be faster by using hash tables. :)
SilverRain
newb
newb
 
Posts: 16
Joined: Sun Apr 27, 2008 8:47 am

Re: Q flag check

Postby cks » Sun Jan 18, 2009 3:47 pm

Thanks :)

Thats true hash tables is faster, but I went with ini-files, so one are able to see what output it gives, and speed is not needed in this case.
Converting it to hash tables would be an improvement.
cks
super poster
super poster
 
Posts: 264
Joined: Sun Nov 04, 2007 3:02 pm
Location: Denmark
Authnick: Sumsar

Re: Q flag check

Postby PuNkTuReD » Fri Feb 20, 2009 9:25 am

i was gnna just convert Sumsar's code to hash but i ended up addin a little in there.


Checks once every ten minutes for flag "o" on a channel

If three checks are done and you have the "o" flag on said channel, you will part the channel

Uses hash tables

Since you cant use the Whoami command until your authed i added the auth in there on connect to quakenet

It also starts "on connect" rather than "on start" ( you dont want it starting on other servers that dont use Q )

I also stopped it showing the Q whois, no need to fill your bot screen up with spam.

Code: Select all
: EDIT THESE TWO ALIASES

; This one is your "report/main" channel
alias -l mainchan { return #your_channel }

; This one is your bots auth
alias -l myauth { return Bots_Auth }

on *:CONNECT: { 
  if ($network == QuakeNet) { .msg Q@CServe.quakenet.org auth $me $myauth | .timer 0 600 qwai }
}
on ^*:NOTICE:*:?: {
  if (%sqn) {
    if ($nick == Q) && ($left($1,1) == $chr(35)) {
      if (o isin $2) { hadd -m fc chans $1 $hget(fc,chans) }
    }
    elseif (*End of list* iswm $1-) { cf }
  }
  haltdef
}
alias -l cf {
  var %z = $comchan($me,0)
  while (%z) {
    if ($comchan($me,%z) isin $hget(fc,chans)) { dec %z }
    else { 
      inc $+(%,fc,$comchan($me,%z)) 1
      msg $mainchan -[ Flag Checking ]- Strike: $(,$($+(%,fc,$comchan($me,%z)),2),) for $(,$comchan($me,%z),)
      if ($($+(%,fc,$comchan($me,%z)),2) >= 3) { msg $mainchan Parting $+(,$comchan($me,%z),) - No Flags | unset $($+(%,fc,$comchan($me,%z)),1) | part $comchan($me,%z) No-Flags | dec %z }
      else { dec %z }
    }
  }
  hfree fc chans
}
alias -l qwai { set -u2 %sqn 2 | msg Q whoami }
Sin And Sacrifice Scriptorz
http://www.SassIRC.com
PuNkTuReD
newb
newb
 
Posts: 40
Joined: Sun Jan 04, 2009 9:06 am
Authnick: PuNkTuReD

Re: Q flag check

Postby cks » Sun Feb 22, 2009 6:38 pm

Yea my bad, it should have been on connect and making sure its the right network.

;)
PuNkTuReD wrote:If three checks are done and you have the "o" flag on said channel, you will part the channel


This will only work if your authname is the same as your nickname.
PuNkTuReD wrote:.msg Q@CServe.quakenet.org auth $me $myauth


Nice work mate.
cks
super poster
super poster
 
Posts: 264
Joined: Sun Nov 04, 2007 3:02 pm
Location: Denmark
Authnick: Sumsar

Re: Q flag check

Postby nsm » Mon Apr 13, 2009 1:06 am

PuNkTuReD wrote:i was gnna just convert Sumsar's code to hash but i ended up addin a little in there.


Checks once every ten minutes for flag "o" on a channel

If three checks are done and you have the "o" flag on said channel, you will part the channel

Uses hash tables

Since you cant use the Whoami command until your authed i added the auth in there on connect to quakenet

It also starts "on connect" rather than "on start" ( you dont want it starting on other servers that dont use Q )

I also stopped it showing the Q whois, no need to fill your bot screen up with spam.

Code: Select all
: EDIT THESE TWO ALIASES

; This one is your "report/main" channel
alias -l mainchan { return #your_channel }

; This one is your bots auth
alias -l myauth { return Bots_Auth }

on *:CONNECT: { 
  if ($network == QuakeNet) { .msg Q@CServe.quakenet.org auth $me $myauth | .timer 0 600 qwai }
}
on ^*:NOTICE:*:?: {
  if (%sqn) {
    if ($nick == Q) && ($left($1,1) == $chr(35)) {
      if (o isin $2) { hadd -m fc chans $1 $hget(fc,chans) }
    }
    elseif (*End of list* iswm $1-) { cf }
  }
  haltdef
}
alias -l cf {
  var %z = $comchan($me,0)
  while (%z) {
    if ($comchan($me,%z) isin $hget(fc,chans)) { dec %z }
    else { 
      inc $+(%,fc,$comchan($me,%z)) 1
      msg $mainchan -[ Flag Checking ]- Strike: $(,$($+(%,fc,$comchan($me,%z)),2),) for $(,$comchan($me,%z),)
      if ($($+(%,fc,$comchan($me,%z)),2) >= 3) { msg $mainchan Parting $+(,$comchan($me,%z),) - No Flags | unset $($+(%,fc,$comchan($me,%z)),1) | part $comchan($me,%z) No-Flags | dec %z }
      else { dec %z }
    }
  }
  hfree fc chans
}
alias -l qwai { set -u2 %sqn 2 | msg Q whoami }



Code: Select all
: EDIT THESE TWO ALIASES

; This one is your "report/main" channel
alias -l mainchan { return #your_channel }

; This one is your bots auth
alias -l myauthnick { return Bots_Auth }
alias -l myauthpass { return Bots_pass }

on *:CONNECT: { 
  if ($network == QuakeNet) { .msg Q@CServe.quakenet.org auth $myauthnick $myauthpass | .timer 0 600 qwai }
}
on ^*:NOTICE:*:?: {
  if (%sqn) {
    if ($nick == Q) && ($left($1,1) == $chr(35)) {
      if (o isin $2) { hadd -m fc chans $1 $hget(fc,chans) }
    }
    elseif (*End of list* iswm $1-) { cf }
  }
  haltdef
}
alias -l cf {
  var %z = $comchan($me,0)
  while (%z) {
    if ($comchan($me,%z) isin $hget(fc,chans)) { dec %z }
    else { 
      inc $+(%,fc,$comchan($me,%z)) 1
      msg $mainchan -[ Flag Checking ]- Strike: $(,$($+(%,fc,$comchan($me,%z)),2),) for $(,$comchan($me,%z),)
      if ($($+(%,fc,$comchan($me,%z)),2) >= 3) { msg $mainchan Parting $+(,$comchan($me,%z),) - No Flags | unset $($+(%,fc,$comchan($me,%z)),1) | part $comchan($me,%z) No-Flags | dec %z }
      else { dec %z }
    }
  }
  hfree fc chans
}
alias -l qwai { set -u2 %sqn 2 | msg Q whoami }

[/quote]
fixed the $myauthnick , so you can use it on what bot you want ,and what auth you want!
nsm
newb
newb
 
Posts: 6
Joined: Mon Apr 13, 2009 1:02 am
Authnick: nsm

Re: Q flag check

Postby cks » Mon Apr 13, 2009 1:34 am

Hi nsm and welcome to sp00fed

Thanks for the corrections
cks
super poster
super poster
 
Posts: 264
Joined: Sun Nov 04, 2007 3:02 pm
Location: Denmark
Authnick: Sumsar

Re: Q flag check

Postby nsm » Mon Apr 13, 2009 9:32 am

Sumsar wrote:Hi nsm and welcome to sp00fed

Thanks for the corrections


Thanks
nsm
newb
newb
 
Posts: 6
Joined: Mon Apr 13, 2009 1:02 am
Authnick: nsm


Return to Mirc Scripting Release

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest