Originally Posted By: Tomao
Originally Posted By: Jeroi
to do some kind of OP checking system that checks if pm sender is OP in same channel than I am thus automatically grants pm access to Operators.
There is no $chan in the PM, so we need to loop through the common channels to check if that person who sends you a PM is an OP or not. What I have done here is that non-ops who send you a PM will be closed:
Code:
on *:open:?:*:{
  var %pm $comchan($nick,0)
  while (%pm) {
    if ($nick !isop $comchan($nick,%pm)) { close -m $nick }
    else {
      if ($hget(pmusers) != $null) {
        if ($nick != $hget(pmusers, $nick)) {
          .notice $me $nick just tried to sen PM with stareting word: $1
          .notice $nick Sorry, unknown PM messages are not allowed and not received. Please ask privlidges in main chat.
        }
        else { msg $nick Hello, I got your message and will try to respond to you ASAP. }
      }
    }
    dec %pm
  }
}


Nice, that helped alot. I added also save hash to txt file on exit and when script is loaded it opens txt file.

Anyways the PM acces rights databse script is more likely complete now.

Here is the code:
Code:
alias selected {
  var %counter = 1  
  var %count = $snick($chan,0)
  var %first = $snick($chan, 1)
  var %boolean = $hfind(pmusers, %first)

  while (%counter <= %count) { 
    var %nick = $snick($chan, %counter)

    if (%boolean != %first) {
      hadd pmusers %nick %nick
      if (%count == 1 ) {
        .notice $me %nick added to PM access database.
      }
      if (%counter == %count && %count > 1) {
        .notice $me Selected group added to PM access database.
      }        
    }
    if (%boolean == %first ) {      
      hdel -w pmusers %nick
      if (%count == 1) {
        .notice $me Removed %nick from PM access database.
      }
      if (%counter == %count && %count > 1) {
        .notice $me Removed selected group from PM access database.
      }
    }
    inc %counter
  }
}
menu nicklist {
  $iif($hget(pmusers) == $null, PM rights)
  . Create access rights database {
    hmake pmusers 100
    .notice $me PM access database created.
  }
  $iif($hget(pmusers) != $null, PM rights)
  . $iif($hfind(pmusers, $snick($chan,1)) != $snick($chan,1), Give, Remove): selected 
  .-
  . Remove access database {
    hfree -w pmusers
    .notice $me PM access database destroyed.
  }
}
on *:LOAD: {
  hmake pmusers 100
  hload pmusers pmusers.txt
} 
on *:EXIT: {
  hsave pmusers pmusers.txt
}
on ^*:open:?:*:{
  var %pm $comchan($nick,0)
  while (%pm) {
    if ($nick !isop $comchan($nick,%pm)) { close -m $nick }
    else {
      if ($hget(pmusers) != $null) {
        if ($nick != $hget(pmusers, $nick)) {
          .notice $me $nick just tried to send PM with starting word: $1
          .notice $nick Sorry, unknown PM messages are not allowed and not received. Please ask privlidges in main chat.
          return
        }
        else { msg $nick Hello, I got your message and will try to respond to you ASAP. }
      }
    }
    dec %pm
  }
}


What do you guys think?

I belive it needs tho send pm script if I am sending to someone pm the skript gives acces rights to that person automatically.


Tomao found bug in your script:
Originally Posted By: Tomao
Code:
on *:open:?:*:{
  var %pm $comchan($nick,0)
  while (%pm) {
    if ($nick !isop $comchan($nick,%pm)) { close -m $nick }
    else {
      if ($hget(pmusers) != $null) {
        if ($nick != $hget(pmusers, $nick)) {
          .notice $me $nick just tried to sen PM with stareting word: $1
          .notice $nick Sorry, unknown PM messages are not allowed and not received. Please ask privlidges in main chat.
          return
        }
        else { msg $nick Hello, I got your message and will try to respond to you ASAP. }
      }
    }
    dec %pm
  }
}


It prevented weradly some users and some users it allowed and I fixed your code to work properly. It now checks if user isop on same channel than you and addas boolean variable to 1. Then the acces list cheker checks also if boolean == 0 it blocks PM else gives welcome text.

Code:
on ^*:OPEN:?:*:{
  if ($hget(pmusers) != $null) {
    var %pm $comchan($nick,0)
    var %boolean 0
    while (%pm) {
      if ($nick isop $comchan($nick,%pm)) { 
        inc %boolean
        return
      }
      dec %pm
    }
    if ($nick != $hget(pmusers, $nick) && %boolean == 0) {
      .notice $me $nick just tried to sen PM with starting word: $1
      .notice $nick Sorry, unknown PM messages are not allowed and not received. Please ask privlidges in main chat.
      halt
    }
    else { 
      msg $nick Hello, I got your message and will try to respond to you ASAP. 
    }
  }
}



The main problem was also that you were looping all the time incoming messages. If user deletes database then the script is always looping when incoming messages are coming even tho there is no database from what to check. Now I added the while loop and variables inside databse check and made the while loop only increasy boolean if user is found as op in same channel. Also you changed halt to return which do not work in this case because halt prevents pm window to open and your skript opened window anyway.

Last edited by Jeroi; 17/04/11 09:56 PM.