Seb icon

ChanReg Socket Service bot

Seb | PRO | 02/11/12 02:15:33 AM UTC | 0 ⭐ | 1475 👁️ | Never ⏰ | []
mIRC |

6.64 KB

|

None

|

0 👍

/

0 👎

; edit the next aliases, and some part lower there is 4 more lines to edit
; make sure the link block matches the infos here. and: ./unreal rehash (or /rehash)
 
menu @chanreg {
  Close sockets:sockclose *
  Connect:r.con
}
alias ChanReg:Report { return #Snoop } ; the back channel where the bot joins. (usually with the other bots)
alias ChanReg:Serv { return seb.entropyirc.dev } ; the example i was using
alias ChanReg:Tokn { return 69 } ;it needs to be a random number
alias ChanReg:Desc { return This is a description you will see in whois replies }
alias ChanReg:Host { return chine-devel } ; @host.name.you.want
alias ChanReg:Idnt { return M } ; ident@
alias ChanReg:Name { return RegServ build 3.2b } ; fullname
 
; those are usefull aliases, change the names and use them.
alias r.con { chanreg serverip.goes.here PORT serverpass }
alias r.s { ChanReg:Out :ChanReg PRIVMSG $1- }
alias r { ChanReg:Out :ChanReg $1- }
 
; /ChanReg <Host> <Port> <Password>
; /ChanReg:Cleanup ; use sockclose to kill it.
 
;Stop editing
#on *:start:{ if ($sock(ChanReg) == $null) { chanreg serverip.goes.here PORT serverpass } }
 
alias ChanReg {
  if ($sock(ChanReg)) { echo -a * /ChanReg: I'm sorry but ChanReg is already linked to $sock($v1).addr $+ : $+ $sock($v1).port }
  elseif ($0 != 3) { echo -a * /ChanReg: Invalid parameters specified, please use: /ChanReg <host> <port> <pass> }
  elseif ($2. !isnum 1-65335) { echo -a * /ChanReg: Invalid port specified, please try again with a port between 1 and 65335 }
  else {
    unset %ChanReg:*
    sockopen ChanReg $1 $2
    sockmark ChanReg $3
    ChanReg:Echo 03[CON] Connecting to $1 $+ : $2 $+ ...
  }
}
alias ChanReg:Echo {
  if (!$window(@ChanReg)) { window -ek0z @ChanReg }
  echo @ChanReg $1-
}
 
 
alias ChanReg:Out {
  if ($sock(ChanReg)) {
    sockwrite -n $v1 $1-
    ChanReg:Echo 06[WRT] $1-
  }
  else { echo -a * /ChanReg: Not linked to a network }
}
alias ChanReg:Cleanup {
  var %host = $sock(ChanReg).addr, %Port = $sock(ChanReg).Port, %Pass = $sock(ChanReg).mark
  sockclose ChanReg
  unset %ChanReg:*
  .TimerChanReg off
  if ($1 && $1 != -r) { 
    ChanReg:Echo $1- 
  }
  elseif ($1 == -r) {
    if ($2-) { ChanReg:Echo $2- }
    if (%host && %port && %pass) { .timerChanReg 1 15 ChanReg %host %port %pass }
  }
}
on *:SOCKWRITE:ChanReg:{ if ($sockerr) { ChanReg:Cleanup -r 04[WRT] Unable to send data to $sock($sockname).addr $+ : $+ $sock($sockname).port $+ ... } }
on *:SOCKCLOSE:ChanReg:{ ChanReg:Cleanup -r 04[CON] Connection with $sock($sockname).addr $+ : $+ $sock($sockname).port closed.... }
on *:SOCKOPEN:ChanReg:{
  tokenize 32 $sock($sockname).addr $sock($sockname).port $sock($sockname).mark
  if ($Sockerr) { 
    ChanReg:Cleanup -r 04[CON] Unable to connect to $1 $+ : $2 $+ ... 
  }
  elseif (!$3) { 
    ChanReg:Echo 04[CON] No password specified...
  }
  else {
    ChanReg:Echo 03[CON] Registering with $1 $+ : $+ $2 $+ ...
    ChanReg:Out PASS $3
    ChanReg:Out SERVER $ChanReg:Serv 0 $ChanReg:Tokn : $+ $ChanReg:Desc
    ChanReg:Out NICK ChanReg 1 0 $ChanReg:Idnt $ChanReg:Host $ChanReg:Serv 0 : $+ $ChanReg:Name
   ;edit the next lines as you pleased. it needs a nickname and oper user
    ChanReg:Out :ChanReg nickserv id PASS
    ChanReg:Out :ChanReg oper USER PASS
    ChanReg:Out :ChanReg MODE snoop :+oSqr
    ChanReg:Out :ChanReg JOIN #snoop
    ChanReg:Out : $+ $chanReg:Serv EOS
    ChanReg:Out : $+ $chanReg:Serv MODE #Snoop +o snoop
    ;the rest does not need editing.
  }
}
on *:SOCKREAD:ChanReg:{
  if ($sockerr) { 
    ChanReg:CleanUp -r [CON] Unable to receive data from $sock($sockname).addr $+ : $+ $sock($sockname).port $+ ... 
  }
  else {
    var %tmp
    sockread %tmp
    while ($sockbr) {
      tokenize 32 %tmp
      if ($1 == PING) { sockwrite -n $sockname PONG $2- }
      elseif (:* iswm $1) && ($2- == PRIVMSG ChanReg $+(:,$chr(1),VERSION,$chr(1))) {
        ChanReg:Out :ChanReg PRIVMSG $mid($1,2) $+(:,$chr(1),VERSION Channel Registration Service v1.0b,$chr(1))
      }
      elseif ($1-) {
        ChanReg:Echo 12[RCV] $1-
        if ($regex($1-,/^:\S+ PRIVMSG #Register :!reg(?:ister)?\b/i)) {
          if (!$len($5) || $len($6)) || (#* !iswm $5) { 
            ChanReg:Out :ChanReg NOTICE $mid($1,2) :I'm sorry, but you have specified invalid parameters, please use: !reg #ChannelName 
          }
          else { 
            set %ChanReg:Check $5 $mid($1,2) 0
            ChanReg:Out :ChanReg mode $5
            ChanReg:Out :ChanReg WHO $5
          }
        }
        elseif (:* iswm $1) && ($3-4 == ChanReg $gettok(%ChanReg:Check,1,32)) {
          var %chan = $gettok(%chanReg:Check,1,32)
          var %nick = $gettok(%chanReg:Check,2,32)
          var %cont = $gettok(%ChanReg:Check,3,32)
          var %cmd = ChanReg:Out :ChanReg NOTICE %Nick
          if ($2 == 324) && (r isincs $5) {
            %cmd :I'm sorry but %chan is already registered
            unset %ChanReg:Check
          }
          elseif ($2 $8 == 352 %nick) && (@ !isin $9) { 
            unset %ChanReg:* 
            %cmd :I'm sorry but you must be an Op on %chan to register it.
            ChanReg:Out :ChanReg PRIVMSG %chan *Attention!* %nick Attempted to register %chan on #Register. (Failed. You must be op (@) to register)
          }
          elseif ($2 $8 == 352 %nick) && (@ isin $9) {
            set %ChanReg:IsOp $true
            set %ChanReg:Check %chan %nick $calc(%cont + 1)
          }
          elseif ($2 == 352) {
            set %ChanReg:Check %chan %nick $calc(%cont + 1)
          }
          elseif ($2 == 315) {
            if (!%ChanReg:IsOp) { %cmd :I'm sorry but you must on %chan to register it. }
            elseif (%cont < 3) { 
              %cmd :I'm sorry, but you must have atleast 3 users on a %chan to register it. 
              ChanReg:Out :ChanReg PRIVMSG %chan Sorry, %chan didn't clear registration's requirements for now. Invite $calc(3-%cont) of your friends, and try again.
              ChanReg:Out :ChanReg PRIVMSG $chanreg:report [Reg] 4Failed %nick tried to register %chan with %cont users.
            }
            else {
              ChanReg:Out :ChanReg privmsg chanserv saregister %chan %nick Newly Registered channel
              %cmd : $+ %chan is now registered to you, Instructions will be sent via MemoServ
              ChanReg:Out :ChanReg PRIVMSG $chanreg:report [3Reg] %chan is Registered to %nick
              ChanReg:Out :ChanReg privmsg memoserv send %nick Please change your channel's password NOW with /cs set %chan password new password. Thank you.
            }
            unset %ChanReg:*
          }
        }
      }
      sockread %tmp
    }
  }
}

Comments