mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Dec 2002
Posts: 111
E
Vogon poet
OP Offline
Vogon poet
E
Joined: Dec 2002
Posts: 111
Im tryin to code a quick auto-op feature into MessageBot. This is how users are added into it:

/msg messagebot aop #channel add nickname

and it writes it to an ini file lookin like this:

[#pointblank]
801018178463=EviL_SmUrF


Code for how it adds it is:
Code:

  if ($1 == aop) {
    set %regnickreplace1 $replace($4,[,$)
    set %regnickreplace2 $replace(%regnickreplace1,],$)
    set %chanreplace1 $replace($2,[,$)
    set %chanreplace2 $replace(%chanreplace1,],$)
    if ($nick == %ownernick) { goto 62 }
    set %checkregnick $read(rootadminlist.db, w, $nick)
    if (%checkregnick == $nick) {
      goto 62
    }
    else {
      set %checkregnick $read(adminlist.db, w, $nick)
      if (%checkregnick == $nick) {
        if (%aopadmin == 0) {
          .notice $nick You are not authorized to use this command.
          halt
        }
        goto 62
      }
      else {
        .notice $nick You are not authorized to use this command.
        halt
      }
    }
    :62
    set %hostchk $gettok($hget(nicks,$nick),2,32)
    if (%hostchk != $fulladdress) {
      .notice $nick You are not authorized to use this command.
      halt
    }
    if ($2 == $null) {
      .notice $nick Syntax: /msg $me aop [channel] [add/del/list] [nickname/entry number].
      .notice $nick For more help on maintaining the Auto-Op list, use /msg $me help aop.
      halt
    }
    if ($3 == $null) {
      .notice $nick Syntax: /msg $me aop [channel] [add/del/list] [nickname/entry number].
      .notice $nick For more help on maintaining the Auto-Op list, use /msg $me help aop.
      halt
    }
    if ($3 == add) {
      set %checkregnick $read(registerlist.db, w, $4)
      if (%checkregnick == $null) {
        .notice $nick The nickname $4 is not registered.
        halt
      }
      if ($4 == $null) {
        .notice $nick Syntax: /msg $me aop [channel] [add/del/list] [nickname/entry number].
        .notice $nick For more help on maintaining the Auto-Op list, use /msg $me help aop.
        halt
      }

      .notice $nick The nickname $4 has been added to the Auto-Op list of $2 $+ .
      write log.txt ( $+ $adate $+ )( $+ $time $+ ) ###ADMIN COMMAND### $nick added $4 to the auto-op list of $2 $+ .
      set %randnum $rand(0,9999999999999)
      writeini chanaoplist.db %chanreplace2 %randnum %regnickreplace2
      write chanlist.db $4
      halt
    }
  }



Now my question is is it possible to check to see if the nickname is in the ini list under the specified channel on join?

like:
Code:
on join:#: {
  if ($nick == $ini(chanaoplist.db, $nick, 0)    
  mode $chan +o $nick
}


i know thats horribly wrong but i just wrote somethin resembling what im hoping can be done.

Any help is greatly appreciated thanks!


[[Moderator's note: I merely added [[/b]code] and [[b]/code] tags where appropriate to show his indentation and make his post more readable. -Hammer]]

Last edited by Hammer; 27/12/02 04:03 AM.
Joined: Dec 2002
Posts: 40
L
Ameglian cow
Offline
Ameglian cow
L
Joined: Dec 2002
Posts: 40
Well I'm not going to read all that long code [censored] so I'm not sure how the format of saving the nick is but something like this will point you in the right direction
Code:
on *:join:#:{
var %i = 1
while (%i <= $ini(chanaoplist.db,0)) {
if ($readini(chanaoplist.db,%i) == $nick) mode $chan +o $nick
inc %i
}
}

hope that helps

Joined: Dec 2002
Posts: 1,321
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
First question: Is there any particular reason you're using the random number as the item (as opposed to the nick as the item and the random number as the value)?
Code:

  [#channel]
  Nickname=RandomNumber

Next question: Is there any particular reason you are using a random number? None is obvious from the code provided. (Why not $ctime or something else meaningful?)

Next to the last question: Since you are already using hashtables (which are more efficient than .ini files for many reasons), why are you using .ini files at all?

Last question: Why not use the value portion as a tokenized string of info about that nick? For example:
Code:

  [#channel]
  Nickname=EncodedPassword,validmask1,validmask2,validmask3,validmask4

Using either of the above formats would allow you to use:
Code:

on @*:JOIN:#: if ($readini(chanaoplist.db, $chan, $nick)) mode $chan +o $nick


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C

Link Copied to Clipboard