; botlogin.mrc v1.3 (22 April 2002)
; Copyright 2002 by slennox
; slennox's eggdrop page - http://www.egghelp.org/
; botlogin.mrc v1.3 (22 April 2002)
; Copyright 2002 by slennox
; slennox's eggdrop page - http://www.egghelp.org/
Reading the TCL, one would simply use the information located in botlogin.ini in the main directory of mIRC.TCL_no_TK wrote:I've been hoping to creat a few popups for working with bots. I have limited know-how with scripting for mIRC and since i was using botlogin.mrc i was woundering if there was a way to use the information from this script to do things like give a password for the bot if its in an account, check that the bot has an account, get the handle for the bot. I know its all stored in an .ini file and stuff, but like i said I have limited know-how with mIRC scripting so thats about as much as i know on it.
Code: Select all
; Instructions:
;
; 1. Place this script in your mIRC directory.
;
; 2. In mIRC, type /load -rs botlogin.mrc
;
; 3. On the main menubar, select 'Commands' > 'Bot Login' > 'Add Account'
;    and enter the following information when prompted:
;       Account name (e.g. '#FarmChat Bots')
;       Your handle (e.g. 'Farmer')
;       Your password (e.g. 'pigsmightfly')
;       A list of bots (e.g. 'Windmill CowBot Rooster')
;
; 4. Test it out by right clicking on a bot in the nickname list and
;    selecting 'DCC Login' or 'Telnet Login'. There are also some popups
;    accessible under 'Bot Login' in DCC chat windows.
;
; 5. If you wish to remove this script, type /unload -rs botlogin.mrc and
;    delete botlogin.ini (if it exists) in your mIRC folder.
; The script will only send your nickname or password if you initiate the
; login using the 'DCC Login' or 'Telnet Login' commands, and only if the
; bot responds within 60 seconds. To minimise maintenance, there is no
; hostmask-based checking, but the nick-based system should be fine as long
; you're careful not to login to an imposter (as you probably are whether
; you use this script or not).
; Original script from slennox
; Message command popups added by DragnLord
;"Notes" requires notes2.tcl to be loaded
;"Auth" command is for people using the toolz.tcl script
alias getinfo {
  var %i = 1
  var %acctdots
  var %botlist
  while ($ini(botlogin.ini,%i) != $null) {
    %acctdots = $ini(botlogin.ini,%i)
    %botlist = $readini(botlogin.ini,%acctdots,botlist)
    if ((%botlist != $null) && $istokcs(%botlist,$$1,32)) {
      if ($$2 == acctnum) return %i
      else return $readini(botlogin.ini,%acctdots,$$2)
    }
    inc %i
  }
}
alias converttok {
  var %old = $$1
  var %new
  while (%old != $null) {
    %new = $addtok(%new,$gettok(%old,1,$$2),$$3)
    %old = $deltok(%old,1,$$2)
  }
  return %new
}
alias menubar_addacct {
  var %acctname = $input(Enter a name for the new account.,1,Add Account)
  if (%acctname == $null) return $input(Cancelled addition of new account.,4,Add Account)
  var %acctdots = $converttok(%acctname,32,46)
  if (($ini(botlogin.ini,%acctdots) != $null) && ($ini(botlogin.ini,%acctdots) != 0)) return $input(Account ' $+ %acctname $+ ' already exists.,4,Add Account)
  var %accthand = $input(Account: $chr(160) $+ %acctname $+ $crlf $+ $crlf $+ Enter a handle for this account.,1,Add Account)
  if (%accthand == $null) return $input(Cancelled addition of new account.,4,Add Account)
  var %acctpass = $input(Account: $chr(160) $+ %acctname $+ $crlf $+ Handle: $chr(160) $+ %accthand $+ $crlf $+ $crlf $+ Enter a password for this account.,1,Add Account)
  if (%acctpass == $null) return $input(Cancelled addition of new account.,4,Add Account)
  var %acctbots = $input(Account: $chr(160) $+ %acctname $+ $crlf $+ Handle: $chr(160) $+ %accthand $+ $crlf $+ Password: $chr(160) $+ %acctpass $+ $crlf $+ $crlf $+ Enter a list of bots (case sensitive, separate with spaces) for this account. You may leave this empty if you'd prefer to add bots directly from the nick list.,1,Add Account)
  writeini botlogin.ini %acctdots handle %accthand
  writeini botlogin.ini %acctdots password %acctpass
  if (%acctbots != $null) {
    %acctbots = $sorttok(%acctbots,32)
    writeini botlogin.ini %acctdots botlist %acctbots
  }
  else %acctbots = (no bots added)
  return $input(Account addition completed. $+ $crlf $+ $crlf $+ Account: $chr(160) $+ %acctname $crlf Handle: $chr(160) $+ %accthand $+ $crlf $+ Password: $chr(160) $+ %acctpass $+ $crlf $+ Bots: $chr(160) $+ %acctbots,4,Add Account)
}
alias menubar_delacct {
  if ($1 == begin) return
  if ($1 == end) return
  return $converttok($ini(botlogin.ini,$1),46,32) $+ :delacct $1
}
alias delacct {
  var %delacct = $input(Delete account ' $+ $converttok($ini(botlogin.ini,$1),46,32) $+ '?,8,Delete Account)
  if (%delacct == $null) return
  remini botlogin.ini $ini(botlogin.ini,$1)
}
alias menubar_chghand {
  if ($1 == begin) return
  if ($1 == end) return
  return $converttok($ini(botlogin.ini,$1),46,32) $+ :chghand $1
}
alias chghand {
  var %acctdots = $ini(botlogin.ini,$1)
  var %accthand = $input(Enter a handle for account ' $+ $converttok(%acctdots,46,32) $+ '.,1,Change Handle,$readini(botlogin.ini,%acctdots,handle))
  if (%accthand == $null) return
  writeini botlogin.ini %acctdots handle %accthand
}
alias menubar_chgpass {
  if ($1 == begin) return
  if ($1 == end) return
  return $converttok($ini(botlogin.ini,$1),46,32) $+ :chgpass $1
}
alias chgpass {
  var %acctdots = $ini(botlogin.ini,$1)
  var %acctpass = $input(Enter a password for account ' $+ $converttok(%acctdots,46,32) $+ '.,1,Change Password,$readini(botlogin.ini,%acctdots,password))
  if (%acctpass == $null) return
  writeini botlogin.ini %acctdots password %acctpass
}
alias menubar_editbot {
  if ($1 == begin) return
  if ($1 == end) return
  return $converttok($ini(botlogin.ini,$1),46,32) $+ :editbot $1
}
alias editbot {
  var %acctdots = $ini(botlogin.ini,$1)
  var %acctbots = $input(Enter a list of bots (case sensitive, separated by spaces) for account ' $+ $converttok(%acctdots,46,32) $+ '.,1,Edit Bot List,$readini(botlogin.ini,%acctdots,botlist))
  if (%acctbots == $null) return
  writeini botlogin.ini %acctdots botlist $sorttok(%acctbots,32)
}
alias nicklistmenu_addbot {
  if ($1 == begin) return
  if ($1 == end) return
  return $converttok($ini(botlogin.ini,$1),46,32) $+ :nicklist_addbot $1
}
alias nicklist_addbot {
  var %acctdots = $ini(botlogin.ini,$1)
  var %acctbots = $readini(botlogin.ini,%acctdots,botlist)
  var %i = 1
  var %addbot
  var %addbots
  while ($snick(#,%i) != $null) {
    %addbot = $snick(#,%i)
    if ($findtokcs(%acctbots,%addbot,1,32) == $null) {
      %addbots = $addtok(%addbots,%addbot,32)
    }
    inc %i
  }
  if (%addbots == $null) return $input(All selected nicks are already in bot list for account ' $+ $converttok(%acctdots,46,32) $+ '.,4,Edit Bot List)
  %acctbots = $input(Enter a list of bots (separated by spaces) for account ' $+ $converttok(%acctdots,46,32) $+ '.,1,Edit Bot List,%acctbots %addbots)
  if (%acctbots == $null) return
  writeini botlogin.ini %acctdots botlist $sorttok(%acctbots,32)
}
alias query_chgpass {
  if ($getinfo($nick,handle) == $null) return $input(Nickname ' $+ $nick $+ ' does not exist in the bot list for any account.,4,Change Password)
  var %acctdots = $ini(botlogin.ini,$getinfo($nick,acctnum))
  var %acctpass = $input(Enter a password for account ' $+ $converttok(%acctdots,46,32) $+ '. $+ $crlf $+ $crlf $+ This will also send a .newpass to the bot.,1,Change Password,$readini(botlogin.ini,%acctdots,password))
  if (%acctpass == $null) return
  writeini botlogin.ini %acctdots password %acctpass
  msg =$nick .newpass %acctpass
}
alias querymenu_addbot {
  if ($1 == begin) return
  if ($1 == end) return
  return $converttok($ini(botlogin.ini,$1),46,32) $+ :query_addbot $1
}
alias query_addbot {
  var %acctdots = $ini(botlogin.ini,$1)
  var %acctbots = $readini(botlogin.ini,%acctdots,botlist)
  %acctbots = $input(Enter a list of bots (separated by spaces) for account ' $+ $converttok(%acctdots,46,32) $+ '.,1,Edit Bot List,%acctbots $gettok($active,1-,61))
  if (%acctbots == $null) return
  writeini botlogin.ini %acctdots botlist $sorttok(%acctbots,32)
}
alias sendlogin {
  var %i = 1
  var %l
  while $var(%sendlogin.*,%i) != $null {
    if (($remove($var(%sendlogin.*,%i),$chr(37) $+ sendlogin.) == $nick) && ($getinfo($nick,$$1) != $null)) {
      msg =$nick $getinfo($nick,$$1)
      if ($$1 == password) unset %sendlogin. $+ $nick
      break
    }
    inc %i
  }
}
alias login {
  var %nicks = $1
  var %nick
  while (%nicks != $null) {
    %nick = $gettok(%nicks,1,44)
    if ($getinfo(%nick,handle) == $null) {
      echo -e # Nickname ' $+ %nick $+ ' does not exist in the bot list for any account.
    }
    else {
      set -u60 %sendlogin. $+ %nick
      if ($2 == dcc) dcc chat %nick
      elseif ($2 == telnet) ctcp %nick CHAT
    }
    %nicks = $deltok(%nicks,1,44)
  }
}
alias botmsg {
  var %nicks = $1
  var %nick
  while (%nicks != $null) {
    %nick = $gettok(%nicks,1,44)
    if ($getinfo(%nick,handle) == $null) {
      echo -e # Nickname ' $+ %nick $+ ' does not exist in the bot list for any account.
    }
    else {
      .msg %nick $2 $getinfo(%nick ,password) $3-
    }
    %nicks = $deltok(%nicks,1,44)
  }
}
alias ident {
  var %identcmd = $input(Enter the ident command for this bot. $+ $crlf $+ $crlf $+ The default for eggdrop is 'ident' $+ $chr(44) but some bot admins change this $+ $chr(44) so check with them if you're unsure.,1,Ident,ident)
  if (%identcmd != $null) {
    msg $$1 %identcmd $getinfo($$1,password) $getinfo($$1,handle)
  }
}
alias shosts {
  $input(Hostmasks for selected nicks. $address($snicks,1),o,Hostmasks)
}
menu menubar {
  Eggdrop
  .Add Account:menubar_addacct
  .Delete Account
  ..$submenu($menubar_delacct($1))
  .Change Handle
  ..$submenu($menubar_chghand($1))
  .Change Password
  ..$submenu($menubar_chgpass($1))
  .Edit Bot List
  ..$submenu($menubar_editbot($1))
}
menu nicklist {
  -
  Eggdrop
  .$iif(($getinfo($1,handle) != $null),Auth):botmsg $snicks auth 
  .$iif(($getinfo($1,handle) != $null),Ops)
  ..$iif((% isin $prefix),Halfop)
  ...Channel:botmsg $snicks halfop $chan
  ...Global:botmsg $snicks halfop
  ..$iif((@ isin $prefix),Op)
  ...Channel:botmsg $snicks op $chan
  ...Global:botmsg $snicks op
  ..$iif((+ isin $prefix),Voice)
  ...Channel:botmsg $snicks voice $chan
  ...Global:botmsg $snicks voice
  .$iif(($getinfo($1,handle) != $null),Msg Cmds)
  ..Addhost:botmsg $snicks addhost $?="enter hostmask to add $crlf example: *!*me@your.net"
  ..Addmask:botmsg $snicks addmask
  ..Die:botmsg $snicks die $?="enter optional quit message"
  ..Go:.msg $snicks go $chan
  ..Help:.msg $snicks help $?="enter command to get help on."
  ..$iif((($numtok($snicks,44) != 1) || $getinfo($1,handle) == $null),$style(2)) Ident:ident $1
  ..Info
  ...Default:botmsg $snicks info $?="enter default info line"
  ...Channel:botmsg $snicks info $chan $?="enter info line"
  ..Invite:botmsg $snicks invite $?="channel name"
  ..Jump:botmsg $snicks jump $?="enter server to jump to (optional)"
  ..Key:botmsg $snicks key $?="channel name"
  ..Memory:botmsg $snicks memory
  ..Notes
  ...Erase:botmsg $snicks notes erase $?="enter number to erase or 'all'"
  ...Index:botmsg $snicks notes index
  ...Read:botmsg $snicks notes read $?="enter number to read or 'all'"
  ...Send:botmsg $snicks notes to $?="enter handle to send to" $?="enter message to send"
  ..Rehash:botmsg $snicks rehash
  ..Reset:botmsg $snicks reset
  ..Save:botmsg $snicks save
  ..Status:botmsg $snicks status
  ..Who:.msg $snicks who $?="channel name"
  ..Whois:.msg $snicks whois $?="enter handle (nickname on bot)"
  .$iif(($getinfo($1,handle) != $null),Login)
  ..DCC Login:login $snicks dcc
  ..Telnet Login:login $snicks telnet
  .$iif(($getinfo($1,handle) == $null),Add to Bot List)
  ..$submenu($nicklistmenu_addbot($1))
  .$iif(($getinfo($1,handle) != $null),Custom)
  ..w/ pass:botmsg $1 $?="enter command"
  ..w/o pass:.msg $1 $?="enter command"
  -
}
menu query {
  -
  Eggdrop
  .Netbots
  ..Set max bans:say .nettcl set sl_bfmaxbans $?="enter maximum number of bans in banlist before locking channel"
  ..Bans
  ...Set new global ban: .nettcl newban $?="enter hostmask for this ban"
  ...Remove global ban:.nettcl killban $?="enter hostmask of ban to remove"
  .$iif(($getinfo($1,handle) != $null) && ($chat($1).status != active),Login) 
  ..DCC Login:login $1 dcc
  ..Telnet Login:login $1 telnet
  .$iif((($chat($1).status == active) || $getinfo($1,handle) == $null),Logout):.msg = $+ $1 .quit
  .$iif(($getinfo($1,handle) == $null),$style(2)) Ident:ident $1
  .$iif((($chat($1).status != active) || $getinfo($1,handle) == $null),$style(2)) Change Password:query_chgpass
  .$iif((($chat($1).status != active) || $getinfo($1,handle) == $null),$style(2)) Shell Cmd:{ .msg = $+ $1 .tcl exec $?="enter command to run" }
  .$iif(($getinfo($1,handle) == $null),Add to Bot List)
  ..$submenu($querymenu_addbot($1))
  -
}
on *:CHAT:Please enter your nickname.:sendlogin handle
on *:CHAT:Nickname.:sendlogin handle
on *:CHAT:Enter your password.*:sendlogin password
on *:CHAT:SSH-1.99-OpenSSH*:sendlogin handle
on *:CHAT:CHALLENGE*:sendlogin password
on *:CHAT:-=[Contagious]=- Personal password*:sendlogin password