Advertisement
Seb

ChanReg Socket Service bot

Seb
Feb 10th, 2012
535
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 6.64 KB | None | 0 0
  1. ; edit the next aliases, and some part lower there is 4 more lines to edit
  2. ; make sure the link block matches the infos here. and: ./unreal rehash (or /rehash)
  3.  
  4. menu @chanreg {
  5.   Close sockets:sockclose *
  6.   Connect:r.con
  7. }
  8. alias ChanReg:Report { return #Snoop } ; the back channel where the bot joins. (usually with the other bots)
  9. alias ChanReg:Serv { return seb.entropyirc.dev } ; the example i was using
  10. alias ChanReg:Tokn { return 69 } ;it needs to be a random number
  11. alias ChanReg:Desc { return This is a description you will see in whois replies }
  12. alias ChanReg:Host { return chine-devel } ; @host.name.you.want
  13. alias ChanReg:Idnt { return M } ; ident@
  14. alias ChanReg:Name { return RegServ build 3.2b } ; fullname
  15.  
  16. ; those are usefull aliases, change the names and use them.
  17. alias r.con { chanreg serverip.goes.here PORT serverpass }
  18. alias r.s { ChanReg:Out :ChanReg PRIVMSG $1- }
  19. alias r { ChanReg:Out :ChanReg $1- }
  20.  
  21. ; /ChanReg <Host> <Port> <Password>
  22. ; /ChanReg:Cleanup ; use sockclose to kill it.
  23.  
  24. ;Stop editing
  25. #on *:start:{ if ($sock(ChanReg) == $null) { chanreg serverip.goes.here PORT serverpass } }
  26.  
  27. alias ChanReg {
  28.   if ($sock(ChanReg)) { echo -a * /ChanReg: I'm sorry but ChanReg is already linked to $sock($v1).addr $+ : $+ $sock($v1).port }
  29.   elseif ($0 != 3) { echo -a * /ChanReg: Invalid parameters specified, please use: /ChanReg <host> <port> <pass> }
  30.   elseif ($2. !isnum 1-65335) { echo -a * /ChanReg: Invalid port specified, please try again with a port between 1 and 65335 }
  31.   else {
  32.     unset %ChanReg:*
  33.     sockopen ChanReg $1 $2
  34.     sockmark ChanReg $3
  35.     ChanReg:Echo 03[CON] Connecting to $1 $+ : $2 $+ ...
  36.   }
  37. }
  38. alias ChanReg:Echo {
  39.   if (!$window(@ChanReg)) { window -ek0z @ChanReg }
  40.   echo @ChanReg $1-
  41. }
  42.  
  43.  
  44. alias ChanReg:Out {
  45.   if ($sock(ChanReg)) {
  46.     sockwrite -n $v1 $1-
  47.     ChanReg:Echo 06[WRT] $1-
  48.   }
  49.   else { echo -a * /ChanReg: Not linked to a network }
  50. }
  51. alias ChanReg:Cleanup {
  52.   var %host = $sock(ChanReg).addr, %Port = $sock(ChanReg).Port, %Pass = $sock(ChanReg).mark
  53.   sockclose ChanReg
  54.   unset %ChanReg:*
  55.   .TimerChanReg off
  56.   if ($1 && $1 != -r) {
  57.     ChanReg:Echo $1-
  58.   }
  59.   elseif ($1 == -r) {
  60.     if ($2-) { ChanReg:Echo $2- }
  61.     if (%host && %port && %pass) { .timerChanReg 1 15 ChanReg %host %port %pass }
  62.   }
  63. }
  64. on *:SOCKWRITE:ChanReg:{ if ($sockerr) { ChanReg:Cleanup -r 04[WRT] Unable to send data to $sock($sockname).addr $+ : $+ $sock($sockname).port $+ ... } }
  65. on *:SOCKCLOSE:ChanReg:{ ChanReg:Cleanup -r 04[CON] Connection with $sock($sockname).addr $+ : $+ $sock($sockname).port closed.... }
  66. on *:SOCKOPEN:ChanReg:{
  67.   tokenize 32 $sock($sockname).addr $sock($sockname).port $sock($sockname).mark
  68.   if ($Sockerr) {
  69.     ChanReg:Cleanup -r 04[CON] Unable to connect to $1 $+ : $2 $+ ...
  70.   }
  71.   elseif (!$3) {
  72.     ChanReg:Echo 04[CON] No password specified...
  73.   }
  74.   else {
  75.     ChanReg:Echo 03[CON] Registering with $1 $+ : $+ $2 $+ ...
  76.     ChanReg:Out PASS $3
  77.     ChanReg:Out SERVER $ChanReg:Serv 0 $ChanReg:Tokn : $+ $ChanReg:Desc
  78.     ChanReg:Out NICK ChanReg 1 0 $ChanReg:Idnt $ChanReg:Host $ChanReg:Serv 0 : $+ $ChanReg:Name
  79.    ;edit the next lines as you pleased. it needs a nickname and oper user
  80.     ChanReg:Out :ChanReg nickserv id PASS
  81.     ChanReg:Out :ChanReg oper USER PASS
  82.     ChanReg:Out :ChanReg MODE snoop :+oSqr
  83.     ChanReg:Out :ChanReg JOIN #snoop
  84.     ChanReg:Out : $+ $chanReg:Serv EOS
  85.     ChanReg:Out : $+ $chanReg:Serv MODE #Snoop +o snoop
  86.     ;the rest does not need editing.
  87.   }
  88. }
  89. on *:SOCKREAD:ChanReg:{
  90.   if ($sockerr) {
  91.     ChanReg:CleanUp -r [CON] Unable to receive data from $sock($sockname).addr $+ : $+ $sock($sockname).port $+ ...
  92.   }
  93.   else {
  94.     var %tmp
  95.     sockread %tmp
  96.     while ($sockbr) {
  97.       tokenize 32 %tmp
  98.       if ($1 == PING) { sockwrite -n $sockname PONG $2- }
  99.       elseif (:* iswm $1) && ($2- == PRIVMSG ChanReg $+(:,$chr(1),VERSION,$chr(1))) {
  100.         ChanReg:Out :ChanReg PRIVMSG $mid($1,2) $+(:,$chr(1),VERSION Channel Registration Service v1.0b,$chr(1))
  101.       }
  102.       elseif ($1-) {
  103.         ChanReg:Echo 12[RCV] $1-
  104.         if ($regex($1-,/^:\S+ PRIVMSG #Register :!reg(?:ister)?\b/i)) {
  105.           if (!$len($5) || $len($6)) || (#* !iswm $5) {
  106.             ChanReg:Out :ChanReg NOTICE $mid($1,2) :I'm sorry, but you have specified invalid parameters, please use: !reg #ChannelName
  107.           }
  108.           else {
  109.             set %ChanReg:Check $5 $mid($1,2) 0
  110.             ChanReg:Out :ChanReg mode $5
  111.             ChanReg:Out :ChanReg WHO $5
  112.           }
  113.         }
  114.         elseif (:* iswm $1) && ($3-4 == ChanReg $gettok(%ChanReg:Check,1,32)) {
  115.           var %chan = $gettok(%chanReg:Check,1,32)
  116.           var %nick = $gettok(%chanReg:Check,2,32)
  117.           var %cont = $gettok(%ChanReg:Check,3,32)
  118.           var %cmd = ChanReg:Out :ChanReg NOTICE %Nick
  119.           if ($2 == 324) && (r isincs $5) {
  120.             %cmd :I'm sorry but %chan is already registered
  121.             unset %ChanReg:Check
  122.           }
  123.           elseif ($2 $8 == 352 %nick) && (@ !isin $9) {
  124.             unset %ChanReg:*
  125.             %cmd :I'm sorry but you must be an Op on %chan to register it.
  126.             ChanReg:Out :ChanReg PRIVMSG %chan *Attention!* %nick Attempted to register %chan on #Register. (Failed. You must be op (@) to register)
  127.           }
  128.           elseif ($2 $8 == 352 %nick) && (@ isin $9) {
  129.             set %ChanReg:IsOp $true
  130.             set %ChanReg:Check %chan %nick $calc(%cont + 1)
  131.           }
  132.           elseif ($2 == 352) {
  133.             set %ChanReg:Check %chan %nick $calc(%cont + 1)
  134.           }
  135.           elseif ($2 == 315) {
  136.             if (!%ChanReg:IsOp) { %cmd :I'm sorry but you must on %chan to register it. }
  137.             elseif (%cont < 3) {
  138.               %cmd :I'm sorry, but you must have atleast 3 users on a %chan to register it.
  139.               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.
  140.               ChanReg:Out :ChanReg PRIVMSG $chanreg:report [Reg] 4Failed %nick tried to register %chan with %cont users.
  141.             }
  142.             else {
  143.               ChanReg:Out :ChanReg privmsg chanserv saregister %chan %nick Newly Registered channel
  144.               %cmd : $+ %chan is now registered to you, Instructions will be sent via MemoServ
  145.               ChanReg:Out :ChanReg PRIVMSG $chanreg:report [3Reg] %chan is Registered to %nick
  146.               ChanReg:Out :ChanReg privmsg memoserv send %nick Please change your channel's password NOW with /cs set %chan password new password. Thank you.
  147.             }
  148.             unset %ChanReg:*
  149.           }
  150.         }
  151.       }
  152.       sockread %tmp
  153.     }
  154.   }
  155. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement