Query Blocker

By _Dean_ on Jan 28, 2011

This is a simple query Blocker
How it work:
-There is a check button with 3 states
Mode Permission
Mode Block
Mode Standby

Mode permission dont block any query
Mode Block Block all queries
Mode standby ask you first, if you wish to allow the query request

there is another option:
Nick exception
when you add a nick in this list
even if the Mode Block and Mode Standby is activated
the nick in nicklist exception will be allowed to send request to you without permission

;Query Blocker

dialog QB {
  title "Query Blocker"
  size -1 -1 194 112
  option dbu
  tab "Query Blocker", 1, 3 5 185 94
  check "Query State On/Off/Stand By", 2, 8 70 87 10, tab 1 3state
  text "Choose a State for the Query Blocker:", 3, 8 60 101 8, tab 1
  text "", 4, 8 86 107 8, tab 1
  edit "", 5, 8 32 109 10, autohs tab 1
  text "Choose a message to appear in Mode Block or Stand by:", 6, 8 22 138 8, tab 1
  text "Ex: Im not accepting any Query", 7, 8 43 111 8, tab 1
  button "Ok", 9, 119 31 25 12, tab 1
  tab "Choose a nick", 10, 3 5 185 94
  combo 11, 8 24 62 50, tab 10 drop size 
  list 12, 8 47 62 50, tab 10 size vsbar
  text "Choosing a nick will automatically allow this nick to query you", 13, 75 20 108 21, tab 10
  text "Choose nick:", 14, 8 38 48 8, tab 10
  list 15, 92 58 73 35, tab 10 size vsbar
  button "Add", 16, 71 70 17 12, tab 10
  button "Del",17, 166 81 19 12, tab 10
  text "Nicks allowed:", 18, 92 49 59 8, tab 10
}

alias QB { dialog $iif($dialog(QB), -v,-m) QB QB }

on *:dialog:QB:init:*:{
  did -b qb 5,6,7,8
  var %x = 1
  while (%x <= $chan(0)) {
    did -a QB 11 $chan(%x)
    inc %x
  }
  if (%Blocker == on) {
    did -ar qb 4 Mode Block is activated | did -e qb 5,6
  }
  if (%Permission == on) {
    did -ar qb 4 Mode Permission is activated
  } 
  if (%Standby == on) {
    did -ar qb 4 Mode Stand by is activated | did -e qb 5,6
  }
  did $iif(%state,%state,-u) qb 2
  $iif($isfile(qlist.txt), loadbuf -o qb 15 qlist.txt,write qlist.txt)
  if (%Queryreason) {
    did -a qb 5 %Queryreason
  }
} 
on *:dialog:QB:sclick:2:{
  if ( $did(2).state == 0 ) {   
    set %state $replace($did(2).state,0,-u,1,-c,2,-cu) | unset %standby | unset %Blocker | set %Permission On | did -ar qb 4 Mode permission is now activated | did -b qb 5,6
  }
  if ( $did(2).state == 1 ) {
    set %state $replace($did(2).state,0,-u,1,-c,2,-cu) | unset %Permission | unset %Standby | set %Blocker on | did -ar qb 4 Mode Block is now activated | did -e qb 5,6
  }
  if ( $did(2).state == 2 ) {
    set %state $replace($did(2).state,0,-u,1,-c,2,-cu) | unset %Blocker | unset %Permission | set %Standby on | did -ar qb 4 Mode Stand by is now activated | did -b qb 5,6
  }
}

on *:dialog:QB:sclick:*:{
  if ($did == 11) {
    var %x = 1
    did -r qb 12
    while (%x <= $nick($did(11).seltext,0)) {
      did -a QB 12 $nick($did(11).seltext,%x)
      inc %x
    }
  }
  if (($did == 16) && ($did(12).seltext)) { 
    write qlist.txt $did(12).seltext 
    did -r qb 15 | loadbuf -o qb 15 qlist.txt
  } 
  if (($did == 17) && ($did(15).seltext)) {
    write -ds $did(15).seltext qlist.txt
    did -r qb 15 | loadbuf -o qb 15 qlist.txt
  }
  if (($did == 9) && ($did(5) != $null)) { 
    set %Queryreason $did(5).text 
    did -ar qb 4 A message for Block mode has been set
  }
}

on *:open:?:{
  if ((%Blocker == on) && ($read(qlist.txt,w,* $+ $nick $+ *) != $nick)) {
    .closemsg $nick | .msg $nick $iif(%Queryreason, %Queryreason, Im not accepting Query Now. Your request have been blocked) | echo -a 5- *** - nick $nick tryed a Query with You - *** - | ignore -u20pn $nick 
  }
  if ((%Standby == on) && ($read(qlist.txt,w,* $+ $nick $+ *) != $nick)) {
    .msg $nick Wait a minute, Your request has been sent to $me 
    echo -a 5- *** - $nick - $1- 
    .timerstand -m 1 1 Qstand $nick
  }
}

alias Qstand {
  /notice $1 Your query request has been sent to $me
  var %query = $input(Nick $1 tryed a query with you. allow?,iy,Private) 
  if (%query == $false) { 
    .closemsg $1
    .notice $1 Warning: Your query request was rejected 
  }
}

Comments

Sign in to comment.
_Dean_   -  Oct 11, 2012

"on :dialog:QB:init::{
did -b qb 5,6,7,8"
You should remove the 8 or else the "Choose a nick" wont work :)

what are you talking about? $did(8) doesnt even exist in this script... it was an error, there is no ID 8

the fact of using a double warning, is:
if someone has a pm blocker too, it wont accept the query, so it will send a notice, of course ppl can remove it, and just have notice

 Respond  
Tuten   -  Oct 10, 2012

"on :dialog:QB:init::{
did -b qb 5,6,7,8"
You should remove the 8 or else the "Choose a nick" wont work :)

Also i dont see the point in contacting the other user twice in Standby Mode
.msg $nick Wait a minute, Your request has been sent to $me
/notice $1 Your query request has been sent to $me
only the Notice should suffice.

Finally and ignore counter would be a nice addition.. that said nice simple query blocker :)

 Respond  
_Dean_   -  Aug 13, 2012

@G4ME

if (($did == 9) && ($did(5) != $null)) { 
    set %Queryreason $did(5).text 
    did -ar qb 4 A message for Block mode has been set
 Respond  
G4ME   -  Jul 14, 2012

Hey, its me again. I have another question. What line fills the text box with the current query answer?

 Respond  
Abcdefmonkey   -  Apr 02, 2012

I know that, @Blackvenomm666.. It was just a more simplified way of achieving what was desired. I personally just use Menu Channel ... I have no use for nicklist and the likes for my scripts.

 Respond  
blackvenomm666   -  Apr 02, 2012

actually abcdefmonkey using menu is not a good way to do it using can interefere with other coding
you should just list em such as

Menu Channel,Nicklist,Menubar,Status,Query {
Query Blocker: { .qb }
}
 Respond  
Abcdefmonkey   -  Apr 02, 2012

If you want a right-click option @HacknSlash just put this in your remotes somewhere. I'd probably add it to the same section as this snippet, but that's me. :P

menu * {
Query Blocker:/qb
}

You can change "Query Blocker" to whatever pleases you.

 Respond  
blackvenomm666   -  Apr 02, 2012

hacknslash its not set up so you right click to get to it you have to use the alias
alias QB { dialog $iif($dialog(QB), -v,-m) QB QB }
just type /qb

 Respond  
HacknSlash   -  Apr 01, 2012

I don't know if this fault is on my end, but when I load this script, I cannot find the dialog anywhere. Why?

 Respond  
G4ME   -  Oct 26, 2011

Thank you man!

 Respond  
_Dean_   -  Oct 23, 2011

yes there is, search for this line on script

 edit "", 5, 8 32 109 10, tab 1

and then add the "autohs"

like this

 edit "", 5, 8 32 109 10, autohs tab 1

if you didnt find it
copy and paste the script again, cause i've updated it

 Respond  
G4ME   -  Oct 23, 2011

Is there a way to increase the allowed number of characters in the textbox?

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.