Sephiroth
http://sephiroth.scifi-action.de/board/

Socket Bot
http://sephiroth.scifi-action.de/board/viewtopic.php?f=4&t=21
Seite 1 von 1

Autor:  Sephiroth [ 18. März 2008 00:15 ]
Betreff des Beitrags:  Socket Bot

;; Usage: /clone <botnick> [server] [port]
;; No passwort Support for the Server!
;; Added: NickChange Support
;; Version: 0.52

alias clone {
  sockclose clone. $+ $$1
  sockclose clone.int
  clear @ $+ $1 $+ .clone
  if ($portfree(113)) socklisten clone.int 113
  sockopen clone. $+ $1 $iif($2,$2,$server) $iif($3,$3,$iif($port,$port,6667))
  set -u60 %clonick $1
}
menu @*.clone {
  restart:{
    if ($sock(clone. $+ $remove($gettok($active,1,46),@))) {
      set %socketto $sock(clone. $+ $remove($gettok($active,1,46),@)).to
      sockwrite -n clone. $+ $remove($gettok($active,1,46),@) join 0
      sockwrite -n clone. $+ $remove($gettok($active,1,46),@) quit :restaaaaaaaaaaaaarting
    }
    clone $remove($gettok($active,1,46),@) %sockto
  }
  clear:clear
  close:{
    if ($sock(clone. $+ $remove($gettok($active,1,46),@))) {
      sockwrite -n clone. $+ $remove($gettok($active,1,46),@) quit :playing games with my heart
    }
    sockclose clone.int
    sockclose clone.ident. $+ $remove($gettok($active,1,46),@)
    sockclose clone. $+ $remove($gettok($active,1,46),@)
    window -c $active
  }
  socklist:socklist
  whois:whois $remove($gettok($active,1,46),@)
}
on 1:input:@*.clone:{
  if /* !iswm $1 {
    s $sock(clone. $+ $remove($gettok($active,1,46),@),1) $1-
  }
}
alias s {
  sockwrite -n $1-
  es $1-
}
alias es {
  echo -t @ $+ $gettok($1,2,46) $+ .clone -> $2-
}
on 1:sockopen:clone.*: {
  var %clnick = $gettok($sockname,2,46)
  window -ekz $+(@,%clnick,.clone)
  if clone.ident.* !iswm $sockname {
    if (!$sockerr) {
      s $sockname Nick %clnick
      s $sockname User %clnick $ip $sock($sockname).ip : $+  $+ %clnick
    }
    else {
      es $sockname ->x %clnick - Error Connection refused
      sockclose $sockname
    }
  }
}
on 1:sockread:clone.*:{
  ;; Set here your home channel(s) (separate this channels with komma)
  set -u %myfuckingchannel #my.channel
  ;; Usermode for the bot
  set -u %botusermode +iwRx

  ;; set here randomidents
  set -u %randomident fuck love hate clone help gline kill frag own

  ;; set adminhost (this must be a wildmask !!!)
  set -u %adminmask $ial($me)

  ;; set privatemessagereport
  set -u %pmrep false

  ;; standard is home channel (set this to one channel or $me)
  set -u %pmrepchannel $gettok(%myfuckingchannel,1,44)

  ;; if your home channel for reports is $me and you turn noticeme on you will recive notices instead of privmsgs
  set -u %noticeme false

  ;; set ignored nicks (don't remove Q & L if you are on QuakeNet)
  set -u %ignorednicks Q L

  if clone.ident.* !iswm $sockname {
    var %clnick = $gettok($sockname,2,46)
    var %a,%?cvers = v0.52

    sockread %a
    tokenize 32 %a
    var %nick = $remove($gettok($1,1,33),:),%address = $remove($gettok($1,2,33),:)
    if (!$window($+(@,%clnick,.clone))) window -ekz $+(@,%clnick,.clone)
    echo -t $+(@,%clnick,.clone) <- $1-

    ;on connect
    if ($1 == ping) && ($remove($2,:) isalnum) {
      s $sockname pong $remove($2,:)
      s $sockname mode %clnick %botusermode
      s $sockname join %myfuckingchannel
    }

    ;on ping
    if (ping :* iswm $1-) && ($remove($2,:) !isnum) {
      s $sockname join %myfuckingchannel
      s $sockname PONG $2
    }

    ;on text events
    ;every bot follows the admin
    ;triggers for the bots are:
    ;<BOTNICK> <command>
    ;this will execute every command if you send it
    ;<botnick> raw <command>
    ;for example
    ;> botnr1 raw privmsg #homechannel :i love rock'n roll
    ;<botnr1> i love rock'n roll
    var %_nick = $remove($gettok($1,1,$asc(!)),:)
    if (: $+ %adminmask PRIVMSG #* : $+ %clnick hop* iswm $1-) { s $sockname part $3 :hoppel di hop | s $sockname join $3 }
    if (: $+ %adminmask PRIVMSG #* : $+ %clnick join* iswm $1-) { s $sockname join $6 : $+ $7- }
    if (: $+ %adminmask PRIVMSG #* : $+ %clnick part* iswm $1-) { s $sockname part $6 : $+ $7- }
    if (: $+ %adminmask PRIVMSG #* : $+ %clnick frag* iswm $1-) { s $sockname privmsg $3 :ACTION takes out his gun and frags $$6-  }
    if (: $+ %adminmask PRIVMSG #* : $+ %clnick msg* iswm $1-) { s $sockname privmsg $6 : $+ $$7- }
    if (: $+ %adminmask PRIVMSG #* : $+ %clnick say* iswm $1-) { s $sockname privmsg $3 : $+ $$6- }
    if (: $+ %adminmask PRIVMSG #* : $+ %clnick raw* iswm $1-) { s $sockname $$6- }
    if (: $+ %adminmask PRIVMSG #* : $+ %clnick nick* iswm $1-) { s $sockname NICK $$6 }
    if (: $+ %adminmask PRIVMSG #* : $+ %clnick me* iswm $1-) { s $sockname privmsg $3 :ACTION $$6-  }
    if (: $+ %adminmask PRIVMSG #* : $+ %clnick describe* iswm $1-) { s $sockname privmsg $6 :ACTION $$7-  }
    if (: $+ %adminmask PRIVMSG #* : $+ %clnick quit* iswm $1-) { set -u20 %clone. [ $+ [ %clnick ] ] 1 | s $sockname quit :Time wasted at IRC: $duration($sock($sockname,1).to) | sockclose $sockname | window -c $+(@,%clnick,.clone) }
    if (: $+ %adminmask PRIVMSG #* : $+ %clnick status* iswm $1-) { s $sockname privmsg $3 :[ $+ %clnick $+ $chr(93) Socket Clone %?cvers running since $uptime(mirc,1) online since $duration($sock($sockname,1).to) }
    if (: $+ %adminmask PRIVMSG #* : $+ bots hop* iswm $1-) { s $sockname part $3 :hoppel di hop | s $sockname join $3 }
    if (: $+ %adminmask PRIVMSG #* : $+ bots frag* iswm $1-) { s $sockname privmsg $3 :ACTION takes out his gun and frags $$6-  }
    if (: $+ %adminmask PRIVMSG #* : $+ bots join* iswm $1-) { s $sockname join $6 : $+ $7- }
    if (: $+ %adminmask PRIVMSG #* : $+ bots part* iswm $1-) { s $sockname part $6 : $+ $7- }
    if (: $+ %adminmask PRIVMSG #* : $+ bots msg* iswm $1-) { s $sockname privmsg $6 : $+ $$7- }
    if (: $+ %adminmask PRIVMSG #* : $+ bots say* iswm $1-) { s $sockname privmsg $3 : $+ $$6- }
    if (: $+ %adminmask PRIVMSG #* : $+ bots raw* iswm $1-) { s $sockname $iif($6,$6-,$chr(10)) }
    if (: $+ %adminmask PRIVMSG #* : $+ bots quit* iswm $1-) { set -u20 %clone. [ $+ [ %clnick ] ] 1 | s $sockname quit :Time wasted at IRC: $duration($sock($sockname,1).to) | window -c $+(@,%clnick,.clone) }
    if (: $+ %adminmask PRIVMSG #* : $+ bots status* iswm $1-) { s $sockname privmsg $3 :[ $+ %clnick $+ $chr(93) Socket Clone %?cvers running since $uptime(mirc,1) online since $duration($sock($sockname,1).to) }
    if (: $+ %adminmask PRIVMSG #* : $+ bots me* iswm $1-) { s $sockname privmsg $3 :ACTION $$6-  }
    if (: $+ %adminmask PRIVMSG #* : $+ bots describe* iswm $1-) { s $sockname privmsg $6 :ACTION $$7-  }

    if (: $+ %clnick $+ !*@* NICK :* iswm $1-) {
      var %nick = %clnick,%newnick = $remove($3,:),%@ =  $+(@,%nick,.clone),%~@ = $+(@,%newnick,.clone)
      sockrename clone. $+ %nick clone. $+ %newnick
      write -c ~bot.tmp
      savebuf %@ ~bot.tmp
      if ($window(%@)) window -c %@
      if (!$window(%~@)) window -ekz %~@ | clear %~@
      loadbuf %~@ ~bot.tmp
      .remove ~bot.tmp
    }
    ;report for different events (ignore this if you don't understand it!) (to turn it off set %pmrep to false)
    if ($sock($sockname,1).to > 30) && !$findtok(%ignorednicks,%_nick,1,32) {
      if ($left($remove($3,:),1) != $chr(35)) && ($2 != NICK) && ($2 !isnum) && ($2 !== QUIT) && ($1 !== PING) && ($1 !== NOTICE) {
        if (%pmrep == true) {
          s $sockname $iif(%pmrepchannel == $me && %noticeme == true,NOTICE,PRIVMSG) %pmrepchannel : $+ $+(!,%nick $iif(%address,$+([,%address,])),!) $2-
        }
      }
    }

    ;CTCP Replys Modify it how you need it
    if ($sock($sockname,1).to > 30) {
      if (:*!*@* PRIVMSG %clnick :VERSION iswm $1-) { s $sockname notice %nick :VERSION Socket Clone %?cvers running since $uptime(mirc,1) online since $duration($sock($sockname,1).to) $+  }
      if (:*!*@* PRIVMSG %clnick :PING * iswm $1-) { s $sockname notice %nick :PING $5 $+  }
      if (:*!*@* PRIVMSG %clnick :FINGER iswm $1-) { s $sockname notice %nick :FINGER %clnick ( $+ %clnick $+ ) $asctime $+  }
      if (:*!*@* PRIVMSG %clnick :TIME iswm $1-) { s $sockname notice %nick :TIME $asctime $+  }
    }
  }
  else {
    var %a
    sockread %a
    sockwrite $sockname %a : USERID : UNIX : $gettok(%randomident,$r(1,$numtok(%randomident,32)),32)
    sockclose clone.int
  }
}
on 1:socklisten:clone.int:{ sockaccept clone.ident. $+ %clonick }

Seite 1 von 1 Alle Zeiten sind UTC + 1 Stunde
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/