RControl Bot v1.12a

By Mi9 on Jul 28, 2016

Update: 2019.02.16


Save as RControl Bot.mrc in mirc/scripts folder

/load -rs scripts/RControl Bot.mrc

set bot password

register to bot with a username and password

RControl Bot must have OP status.

Available commands:
op, deop, hop, dehop, voice, devoice, aov, kick, ban, kban, join, part, jump, invite, users [c], chlist, chinfo, nick, quit, botstatus, enable/disable (bot | register), remuser, botpass, newpass, login, logout, help.

;a   RControl Bot v1.12a - 2016.09.24 - [by Mi9]
;    http://hawkee.com/snippet/17200/
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;
CTCP *:VERSION:.ctcpreply $nick VERSION RControl BOT v1.12a - [by Mi9] - http://hawkee.com/snippet/17200/

menu menubar {
  RControl Bot  [by Mi9]
  ..RControl Bot    ( $+ $upper($group(#rcontrol).status) $+ ):{
    if $group(#rcontrol).status == on { .disable #rcontrol | var %cgr 4 } 
    else { .enable #rcontrol | var %cgr 3 } 
    echo  $+ %cgr $+ :.: RControl Bot is $upper($group(#rcontrol).status)
  }
  ..-
  ..User registration   ( $+ $upper($group(#register).status) $+ ):{
    if $group(#register).status == on { .disable #register | var %cgr 4 } 
    else { .enable #register | var %cgr 3 } 
    echo  $+ %cgr $+ :.: RControl Bot - User registration is $upper($group(#register).status)
  }
  ..-
  ..Change Bot Password...:{
    .writeini scripts/rcontrol.cfg RC.by.Mi9 bpass $md5($$input(Enter password:,p,RControl Bot / Change Password - [by Mi9]))
    echo -a 4:.: RControl BOT PASSWORD CHANGED
  }
}

on !^*:text:botstatus:?:{ cfprot
  if ($1 == botstatus) {
    .notice $nick ::: RControl Bot - [by Mi9] - STATUS :::
    .notice $nick Bot control is $upper( $+ $group(#rcontrol).status $+ )
    .notice $nick Users registration is $upper( $+ $group(#register).status $+ )
  }
} halt
on !^*:text:enable*:?:{ cfprot
  if ($2 == $null || $3 == $null) { .msg $nick Syntax: /.msg $me ENABLE <bot $chr(124) register> <botpassword> | halt }
  if ($md5($3) == $readini(scripts/rcontrol.cfg,RC.by.Mi9,bpass)) {
    if ($2 == bot) { .enable #rcontrol | .notice $nick Bot commands is enabled. }
    if ($2 == register) { .enable #register | .notice $nick Users registration is ON. }
  }
  else .notice $nick Invalid password.
} halt
on !^*:text:disable*:?:{ cfprot
  if ($2 == $null || $3 == $null) { .msg $nick Syntax: /.msg $me DISABLE <bot $chr(124) register> <botpassword> | halt }
  if ($md5($3) == $readini(scripts/rcontrol.cfg,RC.by.Mi9,bpass)) {
    if ($2 == bot) { .disable #rcontrol | .notice $nick Bot commands is disabled. }
    if ($2 == register) { .disable #register | .notice $nick Users registration is OFF. }
  }
  else .notice $nick Invalid password.
} halt

#register on
on !^1:text:register*:?:{ cfprot
  if ($2 == $null || $3 == $null) { .msg $nick Syntax: /.msg $me REGISTER <username> <password> | halt }
  if ($readini(scripts/rcontrol.cfg,$2,$2) == $null) {
    .writeini scripts/rcontrol.cfg $2 $2 $md5($3)
    .notice $nick Username $2 was successfully registered.
  }
  else .notice $nick Sorry, username $2 is already registered.
} halt
#register end

#rcontrol on
on !^1:text:login*:?:{ cfprot
  if ($2 == $null || $3 == $null) { .msg $nick Syntax: /.msg $me LOGIN <username> <password> | halt }
  elseif ($readini(scripts/rcontrol.cfg,$2,$2) != $null) {
    if ($md5($3) == $readini(scripts/rcontrol.cfg,$2,$2)) {
      .auser id $nick $address($nick,1) - is logged in as $2
      .notice $nick AUTHENTICATION SUCCESSFUL
      acmd | .msg $nick Available commands: %acmd | unset %acmd
      var %ccl $comchan($nick,0)
      :giveaov
      if (%ccl == 0) { goto end }
      elseif ($comchan($nick,%ccl).op && %ccl != 0) {
        var %aov $readini(scripts/rcontrol.cfg,$2,aov)
        if (%aov != $null) {
          mode $comchan($nick,%ccl) + $+ %aov $nick
          dec %ccl | goto giveaov
        }  
      }
      :end
    }
    else { .notice $nick AUTHENTICATION FAILED (Invalid Password) }
  }
  else { .notice $nick AUTHENTICATION FAILED (Invalid Username) }
} halt

on !^id:text:*:?:{ cfprot
  acmd | if ($1 !isin %acmd) return | unset %acmd
  if ($1 == help) { acmd | .msg $nick Available commands: %acmd | unset %acmd }
  if ($1 == login) .notice $nick Sorry, You are already authenticated.
  if ($1 == logout) { .ruser $nick | .notice $nick AUTHENTICATION IS CANCELED }
  if ($1 == botpass) {
    if ($2 == $null || $3 == $null) { .msg $nick Syntax: /.msg $me BOTPASS <old botpassword> <new botpassword> }
    else {
      if ($readini(scripts/rcontrol.cfg,RC.by.Mi9,bpass) == $md5($2)) {
        .writeini scripts/rcontrol.cfg RC.by.Mi9 bpass $md5($3) | .notice $nick BOT PASSWORD SUCCESSFULLY CHANGED
      }
      else .notice $nick Old password is incorrect.
    }
  }
  if ($1 == newpass) {
    if ($2 == $null || $3 == $null) { .msg $nick Syntax: /.msg $me NEWPASS <username> <old password> <new password> }
    elseif ($readini(scripts/rcontrol.cfg,$2,$2) != $null) {
      if ($readini(scripts/rcontrol.cfg,$2,$2) == $md5($3)) {
        .writeini scripts/rcontrol.cfg $2 $2 $md5($4) | .notice $nick PASSWORD SUCCESSFULLY CHANGED
      }
      else .notice $nick Old password is incorrect.
    }
    else .notice $nick Invalid username.
  }
  if ($1 == aov) {
    if ($3 == $null || $3 !isin ovn || $4 == $null) { .msg $nick Syntax: /msg $me AOV <username> <o (for Auto-OP), v (for Auto-VOICE), n (for NONE)> <password> | halt }
    elseif ($readini(scripts/rcontrol.cfg,$2,$2) != $null) {
      if ($md5($4) == $readini(scripts/rcontrol.cfg,$2,$2)) {
        if ($3 == o || $3 == v) {
          var %aov $3
          .writeini scripts/rcontrol.cfg $2 aov %aov
          if ($3 == o) var %aov OP | else var %aov VOICE
          .notice $nick Mode for $2 is set to Auto- $+ %aov
        }
        else { .remini scripts/rcontrol.cfg $2 aov | .notice $nick Mode for $2 is set to NONE. }
      }
      else .notice $nick Invalid password.
    }
    else .notice $nick Invalid username.
  }
  if ($1 == users) {
    if ($2 == $null) {
      if $ulist(*,id,0) > 0 {
        set %usr:list $ulist(*,id,0) | set %usr:nr 0 | set %usr:nick $nick
        .notice %usr:nick Authenticated users $ulist(*,0) $+ :
      }
      usr-list-l
    }
    elseif $2 == c usr-list-c
  }
  if ($1 == chlist) chlist
  if ($1 == nick) {
    if ($2 == $null || $3 == $null) { .msg $nick Syntax: /.msg $me NICK <nick> [anick] <botpassword> | halt }
    if ($md5($3) == $readini(scripts/rcontrol.cfg,RC.by.Mi9,bpass)) {
      nick $2 | .notice $nick My nickname is now $2 
    }
    elseif ($md5($4) == $readini(scripts/rcontrol.cfg,RC.by.Mi9,bpass)) {
      nick $2 | anick $3 | .notice $nick My nickname and alternative nickname are now $2 $+ , $3 
    }
    else .notice $nick Invalid password.
  }
  if ($1 == quit) {
    if ($2 == $null) { .msg $nick Syntax: /.msg $me QUIT <botpassword> [message] | halt }
    if ($md5($2) == $readini(scripts/rcontrol.cfg,RC.by.Mi9,bpass)) $1 $3-
    else .notice $nick Invalid password.
  }
  if ($1 isin "deop devoice invite") { set %$3 [nick] }
  if ($1 isin "kick ban kban") { set %$3 <nick> [reason (only for kick and kban)] }
  if ($1 == op) {
    if ($2 == $null || $chr(35) !isin $left($2,1)) { stc$1 $1 | rchelp }
    elseif ($me isop $2) {
      if ($3 == $null) mode $2 +o $nick
      else mode $2 +o $3-
    }
    else no.op $2
  }
  if ($1 == deop) {
    if ($2 == $null || $chr(35) !isin $left($2,1)) { stc$1 $1 | rchelp }
    elseif ($me isop $2) {
      if ($3 == $null) mode $2 -o $nick
      else mode $2 -o $3-
    }
    else no.op $2
  }
  if ($1 == hop) {
    if ($2 == $null || $chr(35) !isin $left($2,1)) { stc$1 $1 | rchelp }
    elseif ($me isop $2) {
      if ($3 == $null) mode $2 +h $nick
      else mode $2 +h $3-
    }
    else no.op $2
  }
  if ($1 == dehop) {
    if ($2 == $null || $chr(35) !isin $left($2,1)) { stc$1 $1 | rchelp }
    elseif ($me isop $2) {
      if ($3 == $null) mode $2 -h $nick
      else mode $2 -h $3-
    }
    else no.op $2
  }
  if ($1 == voice) {
    if ($2 == $null || $chr(35) !isin $left($2,1)) { stc$1 $1 | rchelp }
    elseif ($me isop $2) {
      if ($3 == $null) mode $2 +v $nick
      else mode $2 +v $3-
    }
    else no.op $2
  }
  if ($1 == devoice) {
    if ($2 == $null || $chr(35) !isin $left($2,1)) { stc$1 $1 | rchelp }
    elseif ($me isop $2) {
      if ($3 == $null) mode $2 -v $nick
      else mode $2 -v $3-
    }
    else no.op $2
  }
  if ($1 == kick) {
    if ($2 == $null || $chr(35) !isin $left($2,1)) { stc$1 $1 | rchelp }
    elseif ($me isop $2) {
      kick $2 $3 $4-
    }
    else no.op $2
  }
  if ($1 == ban) {
    if ($2 == $null || $chr(35) !isin $left($2,1)) { stc$1 $1 | rchelp }
    elseif ($me isop $2) {
      mode $2 +b $3
    }
    else no.op $2
  }
  if ($1 == kban) {
    if ($2 == $null || $chr(35) !isin $left($2,1)) { stc$1 $1 | rchelp }
    elseif ($me isop $2) {
      mode $2 +b $3 | kick $2 $3 $4-
    }
    else no.op $2
  }
  if ($1 == invite) {
    if ($2 == $null || $chr(35) !isin $left($2,1)) { stc$1 $1 | rchelp }
    elseif ($3 == $null) invite $nick $2
    else invite $3 $2
  }
  if ($1 == jump) {
    if ($2 == $null || $chr(35) !isin $left($2,1)) { stc$1 $1 | rchelp }
    else hop -c $2 $3
  }
  if ($1 == join) {
    if ($2 == $null || $chr(35) !isin $left($2,1)) { stc$1 $1 | rchelp }
    else join $2 $3
  }
  if ($1 == part) {
    if ($2 == $null || $chr(35) !isin $left($2,1)) { stc$1 $1 | rchelp }
    else part $2
  }
  if ($1 == chinfo) {
    if ($2 == $null || $chr(35) !isin $left($2,1)) { stc$1 $1 | rchelp }
    else {
      if ($me !ison $2) { .notice $nick Sorry, I am not in  $2  channel. | halt }
      if ($chan($2).mode != $null) var %ch.mode $chan($2).mode | else var %ch.mode not set
      if ($chan($2).topic != $null) var %ch.topic $chan($2).topic | else var %ch.topic not set
      .notice $nick Channel information for $2
      .notice $nick Channel Mode: %ch.mode 1/ Topic: %ch.topic 1/ Idle: $chan($2).idle 1/ Nicknames: $+ $nick($2,0,a) ( OPS: $+ $nick($2,0,o) 1/ HalfOPS: $+ $nick($2,0,h) 1/ VOICED: $+ $nick($2,0,v) 1/ REGULAR: $+ $nick($2,0,r) )
    }
  }
  if ($1 == remuser) {
    if ($2 == $null || $3 == $null) { .msg $nick Syntax: /.msg $me REMUSER <username> <password $chr(124) botpassword> | halt }
    elseif ($readini(scripts/rcontrol.cfg,$2,$2) != $null) {
      if ($md5($3) == $readini(scripts/rcontrol.cfg,$2,$2) || $md5($3) == $readini(scripts/rcontrol.cfg,RC.by.Mi9,bpass)) {
        .remini scripts/rcontrol.cfg $2 | .notice $nick Username $2 was removed.
      }
      else .notice $nick Invalid password.
    }
    else .notice $nick Invalid username.
  }
} halt

on 1:START:{ addpasswd }
on 1:LOAD:{ addpasswd }
on 1:OPEN:?:*: if ($1 isin "botstatus enable disable login register") { close -m $nick }
on ID:OPEN:?:*:{ acmd | if ($1 isin %acmd) { close -m $nick | unset %acmd } }
on id:NICK:{ var %A.user $gettok($ulist($nick,1).info,7,32) | .auser id $newnick $address($newnick,1) - is logged in as %A.user | .ruser $nick $+ ! }
on @id:JOIN:#:{ aov.status }
on !1:PART:#:{ if ($nick(#,0,o) == 0 && $nick(#,0) <= 2 || $nick(#,0,o) == 1 && $nick(#,0) <= 2 && $me !isop #) { hop # | mode # +nt } }
on id:PART:#:{ if ($comchan($nick,0) == 1) { .notice $nick You are not authorised with me anymore. | .ruser $nick } }
on *:QUIT:{ .ruser $nick $+ ! | var %ccq $comchan($nick,0)
  :getop
  if (%ccq == 0) { goto end }
  elseif ($nick($comchan($nick,%ccq),0,o) == 0 || $nick($comchan($nick,%ccq),0,o) == 1 && $nick($comchan($nick,%ccq),0) == 2 && !$comchan($nick,%ccq).op) { hop $comchan($nick,%ccq) | mode $comchan($nick,%ccq) +nt }
  else { dec %ccq | goto getop }
  :end
}
on 1:DISCONNECT:{ .rlevel id }
on 1:EXIT:{ .rlevel id }
#rcontrol end

alias -l acmd {
  set %acmd 12op, 12deop, 12hop, 12dehop, 12voice, 12devoice, 12aov, 6kick, 6ban, $&
    6kban, 3join, 3part, 3jump, 3invite, 10users [c], 10chlist, 10chinfo, 10nick, $&
    10quit, 14botstatus, 14enable/disable (bot $chr(124) register), 5remuser, 5botpass, 5newpass, 5login, 5logout, help.
}
alias -l addpasswd {
  if ($readini(scripts/rcontrol.cfg,RC.by.Mi9,bpass) == $null) {
    echo 12 -a :.: RControl Bot by Mi9 :.:
    var %passwd $$input(Enter password:,p,RControl - [by Mi9])
    .writeini scripts/rcontrol.cfg RC.by.Mi9 bpass $md5(%passwd)
    echo -a 4:.: BOT PASSWORD ADDED
  }
}
alias -l aov.status {
  var %aov $readini(scripts/rcontrol.cfg,$gettok($ulist($nick,1).info,7,32),aov)
  if (%aov != $null && $ulevel == id) { .timer.aov $+ $chan 1 3 mode # + $+ %aov $nick }
}
alias -l cfprot { if $timer(. $+ $nick).type == online halt | else .timer. $+ $nick 1 3 return }
alias -l chlist {
  var %t.ch $chan(0)
  while (%t.ch > 0) {
    if (p isin $chan(%t.ch).mode) || (s isin $chan(%t.ch).mode) && ($nick($chan(%t.ch),$nick) == $chan) {
      inc %s.ch | goto skip
    }
    if ($me isreg $chan(%t.ch)) unset %my.ch.mode
    if ($me isvoice $chan(%t.ch)) var %my.ch.mode [+]
    if ($me ishop $chan(%t.ch)) var %my.ch.mode [%]
    if ($me isop $chan(%t.ch)) var %my.ch.mode [@]
    var %p.chlist $chan(%t.ch) $+ %my.ch.mode $+ %sep %p.chlist
    :skip
    dec %t.ch
    if (%t.ch == 0) {
      if ($chan(0) > 1) var %ltr s
      if (%t.ch > 1) var %wrd are | else var %wrd is
      if (%s.ch > 0) var %sp.ch :( $+ %s.ch of them %wrd secret or private $+ ).
      .notice $nick I am on $chan(0) Channel $+ %ltr $+ : %p.chlist %sp.ch
      unset %s.ch
    }
  }
}
alias -l no.op { .notice $nick Sorry $nick $+ , I don't have OP on $1 channel. }
alias -l stc$1 { set %$1 $1 }
alias -l rchelp { .msg $nick Syntax: /msg $me %$1 <#channel> %$3 | unset %$1 %$3 }
alias -l usr-list-l {
  inc %usr:nr
  if (%usr:nr <= %usr:list) {
    .notice %usr:nick $ulist(*,id,%usr:nr) $ulist(*,id,%usr:nr).info
    .timer.lstusr 1 1 usr-list-l
  }
  else { .notice %usr:nick End of users list. | unset %usr:* }
}
alias -l usr-list-c {
  var %usr:list $ulist(*,id,0), %usr:nr 0
  :next
  inc %usr:nr
  if (%usr:nr >= %usr:list) { unset %separ } | else { set %separ ; }
  if (%usr:nr <= %usr:list) { set %usr:show %usr:show $ulist(*,id,%usr:nr) ( $+ $gettok($ulist(*,id,%usr:nr).info,6,32) $+ ) $+ %separ | goto next }
  else { .notice $nick Authenticated users $ulist(*,0) $+ : | .notice $nick  %usr:show | .notice $nick End of users list. | unset %usr:* }
}

;z
;a   RControl User v2019.02.16 - [by Mi9]
;    
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

menu query,nicklist {
  RControl User [by Mi9] 
  .Login...:.msg $$1 LOGIN $$input(!!! $1 will receive confidential information !!! $crlf $+ <Username> <Password> separated by space.,p,RControl User - [by Mi9] - LOGIN to $1)
  . Logout:msg $$1 LOGOUT
  .-
  .List Auth Users [L]:msg $$1 users
  .List Auth Users [C]:msg $$1 users c
  .Channels List:/msg $$1 chlist
  .Channel Info...:/msg $$1 chinfo $chr(35) $+ $$input(Channel Info: $crlf $+ Enter channel name without #.,e,RControl User - [by Mi9] - $1)
  .-
  .Bot STATUS:/msg $$1 botstatus
  .-
  .Enable BOT Commands...:.msg $$1 enable bot $$input(!!! $1 will receive confidential information !!! $crlf $+ Enter Bot Password:,p,RControl User - [by Mi9] - Enable BOT Commands - $1)
  .Disable BOT Commands...:.msg $$1 disable bot $$input(!!! $1 will receive confidential information !!! $crlf $+ Enter Bot Password:,p,RControl User - [by Mi9] - Disable BOT Commands - $1)
  .-
  .Enable User REGISTRATION...:.msg $$1 enable register $$input(!!! $1 will receive confidential information !!! $crlf $+ Enter Bot Password:,p,RControl User - [by Mi9] - Enable User REGISTER - $1)
  .Disable User REGISTRATION...:.msg $$1 disable register $$input(!!! $1 will receive confidential information !!! $crlf $+ Enter Bot Password:,p,RControl User - [by Mi9] - Disable User REGISTER - $1)
  .-  
  .Change Bot Password...:.msg $$1 bpass $$input(!!! $1 will receive confidential information !!! $crlf $+ Change BOT Password: $crlf $+ <old password> <new password> separated by space.,p,RControl User - [by Mi9] - $1)
  .-
  .Register as New Username...:.msg $$1 register $$input(!!! $1 will receive confidential information !!! $crlf $+ <New_Username> <Password> separated by space.,p,RControl User - [by Mi9] - REGISTER to $1)
  .-
  .Help:msg $$1 help
}

;z

Comments

Sign in to comment.
Mi9   -  Aug 07, 2016

RControl Bot v1.12 - 2016.09.24

Some bug fixes


RControl Bot v1.11 - 2016.09.10

Improvement for "chlist" command.


RControl Bot v1.10 - 2016.09.07

Changes for "chlist" command

  • channels with mode +p, +s are skipped, if you're not on them.

RControl Bot v1.9a - 2016.09.04

Added commands:

  • change bot nickname and alternative_nickname (optional)
 /.msg botname nick <nick> [anick] <botpassword>
  • disconnect bot from IRC.
 /.msg botname quit <botpassword> [message]

Command changed:

  • "users c" command sent auth users in compact mode.
    Ex. Nick (auth_username); Nick2 (auth_username)
/msg botname users c

Improvements:

  • when an auth user change his nickname
  • auto-op|voice when an auth user join a channel (3 sec. delay)

RControl Bot v1.9 - 2016.08.09

Command added:

  • register (Default ON)
    Register username
    /.msg botname register <username> <password>
  • enable / disable
    Bot commands or Register
    /.msg botname enable  <bot | register> <botpass>
    /.msg botname disable  <bot | register> <botpass>
  • botstatus
    Display if Bot or Register status is ON or OFF

  • remuser
    Remove a username
    /.msg botname remuser <username> <password or botpass>

Improvments:

  • login now need a username
    /.msg botname login <username> <password>

RControl Bot v1.7 - 2016.08.07

  • I renamed "hop" command with "jump"
     /msg botname jump <#channel> [message]
  • Added commands:
    chlist
    chinfo
    hop / dehop ( For servers that supports HalfOP, Mode +/-h )

  • Some bug fixes
 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.