ircmirc

Stuck trying to write script to register username with tilte


Working on a bot script to lookup a username on join and see if it's be regiester with a title for the channel I run. Like if my name is Ravenna. I want the bot to check if I've registered the title Mistress with the username Ravenna.

I'm extremely stuck on how to go about this, researching things haven't brought me closer to a solution

so far all I've figured out I want is

on *:JOIN:#channel {
.msg $chan $nick take time to register with me; a pm will be sent to you soon
}

Any help or a source where I can figure out how to write and read files or the snippet code I need would be appericated


Solution

  • I think it's the best to use ini files for this. You should have a look at this: http://en.wikichip.org/wiki/mirc/ini_files and for more on http://en.wikichip.org/wiki/mirc.

    For example you have a title called Mistress, your titles.ini file would look like this:

    [mistress]
    Ravenna=true
    
    [mister]
    Denny=true
    

    To read a value you can use: $readini(titles.ini,n,mistress,$nick)

    And to check the value you can do:

    on *:join:#channel: {
      if ($readini(titles.ini,n,mistress,$nick)) {
        ; code here for mistress
      }
      elseif ($readini(titles.ini,n,mister,$nick)) {
        ; code here for mister
      }
      elseif ($readini(titles.ini,n,TITLE,$nick)) {
        ; code here for another title
      }
      else {
        ; code here when no title
      }
    }
    

    This way you must manually add a title in your titles.ini file. So if you want to add another title you should add [TITLE] on a new line in your ini file. If you have more questions you can ask here.

    If you want to register someone with a title you could make a simple on text event and add a name to the ini file with writeini titles.ini TITLE $nick true