Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- on *:start:{ .connect | .server -m chat3.koach.com }
- on *:socklisten:start:{
- .sockaccept localhost
- .sockclose $sockname
- }
- on *:sockread:localhost:{
- if ($sockerr > 0) return
- var %ldata | sockread %ldata | tokenize 32 %ldata
- if ($1 == JOIN) {
- if ($chr(44) isin $2) {
- var %x = 1
- while (%x <= $numtok($2,44)) {
- var %c $gettok($2,%x,44)
- var %j $calc(%x * 1100)
- .timerjoin $+ %j -m 1 %j mjoin $remove(%c,$chr(37))
- inc %x
- }
- }
- else mjoin $remove($2,$chr(37))
- }
- elseif ($1 == AWAY) {
- if ($me ison $remove($2,:)) sw AWAY $remove($2,:) $iif($left($3-,1) == :,$right($3-,-1),$3-)
- else {
- if ($me ison $active) sw AWAY $active $iif+($left($2-,1) == :,$right($2-,-1),$2-)
- else echo -a To avoid flooding, please specify which channel to change away status. /away <channel> <message>
- }
- }
- elseif ($1 == KICK) sockwrite -n buzzen $1-3 $iif($left($4-,1) == :,$right($4-,-1),$4-)
- elseif ($1 == PRIVMSG) {
- if ($me ison $2) sw $1-
- else sw $1 $comchan($2,1) $2-
- }
- elseif ($1 == NOTICE) {
- if ($me ison $2) sw $1-
- else sw $1 $comchan($2,1) $2-
- }
- else sw $1-
- }
- on *:sockclose:localhost:{
- .sockclose localhost
- .sockclose start
- .sockclose buzzen
- .timer -m 1 100 connect
- }
- on *:sockopen:buzzen:{
- .sw AUTHTYPE ircwx1
- .sw LOGINH %email %password
- .sw USER $me $me $me $+(:,anon)
- .sw CLIENTMODE cd1
- }
- on *:sockread:buzzen:{
- if ($sockerr > 0) return
- var %fdata
- sockread %fdata
- if (%fdata != $null) edata ← %fdata
- %fdata = $regsubex(%fdata, /\[(?:style\x20.*?|/style)\]/gi,$null)
- tokenize 32 %fdata
- if ($2 == 353) {
- if ($chr(44) isin $6) {
- var %a = 6, %b, %name
- while (%a <= $0) {
- %name = $remove($gettok($gettok($1-,%a,32),2,44),:)
- if ($left($remove($gettok($gettok($1-,%a,32),1,44),:),1) == A) .hadd -m $md5($5) $remodes(%name) away
- if ($right($remove($gettok($gettok($1-,%a,32),1,44),:),1) == V) %name = $+($remove(%name,$remodes(%name)),+,$remodes(%name))
- if (%b == $null) %b = %name
- else %b = %b %name
- inc %a
- }
- sockwrite -n localhost :FlashIrcServer.1 353 $me = $5 : $+ %b
- }
- else sockwrite -n localhost $1-
- }
- elseif ($2 == 403) && ($chr(37) isin $4) sw CREATE $4
- elseif ($2 == NOTICE) && ($3 != AUTH) {
- if ($3 == $server) {
- sockwrite -n localhost $+(:,$3) $2 $gettok($right($1,-1),1,33) $iif($left($4,1) == :,$4-,$+(:,$4-))
- }
- else {
- if ($left($4,1) == :) sockwrite -n localhost $1-
- else {
- if ($left($5-,2) == :) && ($right($5-,1) == ) sockwrite -n localhost $1-3 $5-
- else {
- var %f $gettok($5,1,32)
- if ($left(%f,7) == :TIME) sockwrite -n localhost $1-3 :TIME $+($right($5-,-7),)
- elseif ($left(%f,7) == :VERSION) sockwrite -n localhost $1-3 :VERSION $+($right($5-,-7),)
- else sockwrite -n localhost $1-3 $5-
- }
- }
- }
- }
- elseif ($2 == PRIVMSG) {
- if ($left($4,1) == :) {
- if ($left($4-,2) == :) && ($right($remove($4-,$chr(15)),1) == ) && ($4 != :ACTION) {
- .SIGNAL -n CTCP_REQUEST $strip($gettok($remove($1,:),1,33) $gettok($1,2,33) $3 $left($right($remove($4-,$chr(15)),-2),-1))
- }
- else sockwrite -n localhost $1-
- }
- else {
- if ($left($5-,2) == :) && ($right($5-,1) == ) && ($5 != :ACTION) {
- .SIGNAL -n CTCP_REQUEST $strip($gettok($remove($1,:),1,33) $gettok($1,2,33) $3 $left($right($remove($5-,$chr(15)),-2),-1))
- }
- elseif ($5 == :ACTION) && ($right($5-,1) == ) sockwrite -n localhost $1-
- else sockwrite -n localhost $1 WHISPER $3-
- }
- }
- elseif ($2 = JOIN) {
- if ($chr(37) isin $3) sockwrite -n localhost $1-
- else sockwrite -n localhost $1 $2 $4-
- }
- elseif ($2 == DATA) && ($4 == PID) set %pid $6
- elseif ($2 == 822) {
- if ($me ison $3) {
- if ($gettok($right($1,-1),1,33) != $me) echo $3 11Away: $gettok($right($1,-1),1,33) has been marked as being away. $tag($right($4-,-1))
- else echo $3 11Away: You have been marked as being away. $tag($right($4-,-1))
- cline -m 15 $3 $gettok($right($1,-1),1,33)
- sockwrite -n localhost $1-
- }
- }
- elseif ($2 == 821) {
- if ($me ison $3) {
- if ($gettok($right($1,-1),1,33) != $me) echo $3 11Away: $gettok($right($1,-1),1,33) is no longer marked as being away.
- else echo $3 11Away: You are no longer marked as being away.
- cline -m 0 $3 $gettok($right($1,-1),1,33)
- sockwrite -n localhost $1-
- }
- }
- else sockwrite -n localhost $1-
- }
- on *:sockclose:buzzen:{ .disconnect }
- alias login {
- .disconnect
- .unset %email
- .unset %password
- .connect
- }
- alias connect {
- if (%email == $null) set %email $$input(Email:,e,Login)
- if (%password == $null) set %password $md5($$input(Password:,p,Login))
- if (%debug == on) .window -k0 @sockread
- .var %localport = $rport
- .socklisten start %localport
- .timer -m 1 200 .server 127.0.0.1 %localport
- .timer 1 1 sockopen buzzen $iif(%server == $null,irc.buzzen.net,%server) 6667
- }
- alias sw {
- if ($sock(buzzen).status == active) {
- .sockwrite -n buzzen $1-
- .edata → $1-
- }
- }
- alias remodes return $remove($remove($remove($remove($remove($1-,'),.),@),%),+)
- alias rport { var %port $rand(2000,6000) | while (!$portfree(%port)) { %port = $rand(2000,6000) } | return %port }
- alias edata {
- if (%debug == on) {
- if ($window(@sockread) == $null) .window -k0 @sockread
- .echo @sockread $+(,$1,) $2-
- }
- }
- alias sread {
- if ($1 == on) {
- if ($window(@sockread) == $null) .window -k0 @sockread
- .set %debug on
- }
- elseif ($1 == off) {
- .set %debug off
- .window -c @sockread
- }
- else .echo -a ERROR: Invalid parameter. /sread [on|off]
- }
- alias mjoin { sw join $+($chr(37),$1) }
Advertisement
Add Comment
Please, Sign In to add comment