Sockbot v3

By SeiferAlmasy on Mar 26, 2004

Sockbot v3

alias sockbot {
  if ($1 == close) { sockwrite -n irc QUIT $iif($2,exiting client) }
  elseif (!$1) { sock.window y | window -c @sock }
  elseif ($1 == join) && ($sock(irc)) { sockwrite -n irc JOIN $2 | sockparse [SELF JOIN] on $2 }
  elseif ($1 == part) && ($sock(irc)) { sockwrite -n irc PART $2 | sockparse [SELF PART] on $2 }
  elseif ($1 == op) && ($sock(irc)) { sockwrite -n irc MODE $2 +o $3 | sockparse [OP MODE] on $+($2,:) $3 }
  elseif ($1 == deop) && ($sock(irc)) { sockwrite -n irc MODE $2 -o $3 | sockparse [DEOP MODE] on $+($2,:) $3 }
  elseif ($1 == voice) && ($sock(irc)) { sockwrite -n irc MODE $2 +v $3 | sockparse [VOICE MODE] on $+($2,:) $3 }
  elseif ($1 == devoice) && ($sock(irc)) { sockwrite -n irc MODE $2 -v $3 | sockparse [DEVOICE MODE] on $+($2,:) $3 }
  elseif ($1 == ban) && ($sock(irc)) { sockwrite -n irc MODE $2 +b $address($3,2) | sockparse [BAN] on $+($2,:) $address($3,2) }
  elseif ($1 == kick) && ($sock(irc)) { sockwrite -n irc KICK $2- | sockparse [KICK] on $+($2,:) $iif($3,$+(reason:,$3)) }
  elseif ($1 == kb) && ($sock(irc)) { sockwrite -n irc MODE $2 +b $address($3,2) | sockwrite -n irc kick $2- | sockparse [KICK BAN] on $+($2,:) $address($3,2) $+ $iif($4,$+(reason:,$4-)) }
  elseif ($1 == mode) && ($sock(irc)) && ($hget(sockbot,nick)isop $2) { sockwrite -n irc MODE $2 $3 | sockparse mode change in $+($2,:) $3- }
  elseif ($1 == say) && ($sock(irc)) { sockwrite -n irc PRIVMSG $2 $+(:,$3-) | sockparse [MSG] to $2 from $+($hget(sockbot,nick),:) $3- }
  elseif ($1 == nick) && ($sock(irc)) { sockwrite -n irc NICK $3 | sockparse [NICK] change from $hget(sockbot,nick) to $3 | hadd sockbot nick $5 }
  elseif ($1 == options) { dialog -m soptions soptions }
  else {
    .sockopen irc $2 $iif($3,$3,6667)
    if (!$hget(sockbot)) { .hmake -s sockbot 1000 }
    .hadd sockbot nick $1
    .hadd sockbot server $2
    $iif($3,.hadd sockbot port $3)
  }
}

; --------- EVENTS ---------

on *:start:{ sload }

; --------- SOCK EVENTS ---------

on *:SOCKOPEN:irc:{
  sock.window y
  sockwrite -n irc NICK $hget(sockbot,nick)
  sockwrite -n irc USER $iif($hget(sockbot,ident),$ifmatch,sockbot) . . $iif($hget(sockbot,rname),$ifmatch,sockbot)
  sjoin
}

on *:SOCKREAD:irc:{
  var %temp | sockread %temp | tokenize 32 %temp
  if ($1) {
    var %n  = $gettok($remove($1,:),1,33)
    if ($1 == ping) { sockwrite -n $sockname PONG $2- }
    elseif ($2 == NOTICE) {  sockparse [NOTICE] to $hget(sockbot,nick) from $+(%n,:)  $remove($4-,:) }
    elseif ($2 == PRIVMSG) && ($left($3,1) != $chr(35)) { sockparse $timestamp msg from %n to $+($hget(sockbot,nick),:) $remove($4-,:)  }
    elseif ($istok($hget(sockbot,masters),%n,44)) && (*.join* iswm $4-) { sockwrite -n irc JOIN $5 | sockparse join on $5 }
    elseif ($istok($hget(sockbot,masters),%n,44)) && (*.part* iswm $4-) { sockwrite -n irc PART $5 | | sockparse part on $5  }
    elseif ($istok($hget(sockbot,masters),%n,44)) && (*.nick* iswm $4-) { sockwrite -n irc NICK $5 | .hadd sockbot nick $5 }
    elseif ($istok($hget(sockbot,masters),%n,44)) && (*.op* iswm $4-) { sockwrite -n irc MODE $5 +o $6 | sockparse op on $+($5,:) $6 }
    elseif ($istok($hget(sockbot,masters),%n,44)) && (*.deop* iswm $4-) { sockwrite -n irc MODE $5 -o $6 | sockparse deop on $+($5,:) $6 }
    elseif ($istok($hget(sockbot,masters),%n,44)) && (*.voice* iswm $4-) { sockwrite -n irc MODE $5 +v $6 | sockparse voice on $+($5,:) $6 }
    elseif ($istok($hget(sockbot,masters),%n,44)) && (*.devoice* iswm $4-) { sockwrite -n irc MODE $5 -v $6 | sockparse devoice on $+($5,:) $6 }
    elseif ($istok($hget(sockbot,masters),%n,44)) && (*.ban* iswm $4-) { sockwrite -n irc MODE $5 +b $address($6,2) | sockparse ban on $+($5,:) $6 }
    elseif ($istok($hget(sockbot,masters),%n,44)) && (*.kick* iswm $4-) { sockwrite -n irc KICK $5- | sockparse kick on $+($5,:) $6 $iif($7,$+(reason:,$chr(32),$7-)) }
    elseif ($istok($hget(sockbot,masters),%n,44)) && (*.kb* iswm $4-) { sockwrite -n irc MODE $5 +b $address($6,2) | sockwrite -n irc KICK $5- | sockparse kick on $+($5,:) $6 $iif($7,$+(reason:,$chr(32),$7-)) }
    elseif ($istok($hget(sockbot,masters),%n,44)) && (*.say* iswm $4-) { sockwrite -n irc PRIVMSG $5 $+(:,$6-) | sockparse msg to $2 from $+($hget(sockbot,nick),:) $3- }
    elseif ($istok($hget(sockbot,masters),%n,44)) && (*.die* iswm $4-) { sockwrite -n irc QUIT $iif($5,$5-,exiting client by %n)  }
    elseif ($2 == KICK) { sockwrite -n irc JOIN $3 }
  }
}

; --------- DIALOG ---------

dialog soptions {
  title "Sockbot v3"
  size -1 -1 119 97
  option dbu
  tab "Auto Functions", 1, 1 3 116 91
  list 3, 4 43 95 47, tab 1 size
  edit "", 4, 4 33 95 10, tab 1
  button "+", 5, 101 33 13 11, tab 1
  combo 7, 34 20 65 32, tab 1 size drop
  text "Network", 8, 5 21 25 8, tab 1
  button "-", 6, 101 44 13 11, tab 1
  button "+", 9, 101 20 13 11, tab 1
  tab "Master", 10
  list 15, 4 43 95 47, tab 10 size
  edit "", 16, 4 33 95 10, tab 10
  text "Master List", 17, 5 21 29 8, tab 10
  button "-", 18, 101 44 13 11, tab 10
  button "+", 19, 101 33 13 11, tab 10
}
on *:DIALOG:soptions:*:*:{
  sload
  if ($devent == SCLICK) {
    if ($did == 9) { hadd sockbot $+(ajoin.,$$?="Enter Network") $chr(32) | sload -n }
    elseif ($did == 5) && ($did($dname,4).text) && ($did($dname,7).seltext) { hadd sockbot $+(ajoin.,$ifmatch) $addtok($hget(sockbot,$+(ajoin.,$ifmatch)),$did($dname,4).text,44) | did -r $dname 4 | sload -c $ifmatch }
    elseif ($did == 6) && ($did($dname,3).seltext) && ($did($dname,7).seltext)  { hadd sockbot $+(ajoin.,$ifmatch) $remtok($hget(sockbot,$+(ajoin.,$ifmatch)),$did($dname,3).seltext,44) | sload -c $ifmatch }
    elseif ($did == 7) { sload -c $did($dname,7).seltext }
    elseif ($did == 19) && ($did($dname,16).text) { hadd sockbot masters $addtok($hget(sockbot,masters),$ifmatch,44) | sload -m | did -r $dname 16 }
    .hsave -o sockbot $sockhash
  }
  elseif ($devent == INIT) {
    sload -n
  }
}

; --------- CUSTOM WINDOW  ---------

alias -l sock.back {
  var %1 = 1
  while (%1 <= $fline(@sock,*,0)) {
    cline $color(text) @sock $fline(@sock,*,%1)
    inc %1
  }
}

alias -l sock.window {
  if ($window(@sock)) && ($1 == y) { window -c @sock }
  $iif($1 == y,window -al @sock)
  aline @sock $+($chr(2),::,$chr(2)) /sockbot v3 by $+($chr(2),$chr(31),:,$chr(2),$chr(31)) SiLvErWiNgS
  aline @sock $+($chr(2),::,$chr(2)) Nickname $+($chr(2),$chr(31),:,$chr(2),$chr(31)) $hget(sockbot,nick)
  aline @sock $+($chr(2),::,$chr(2)) Real Name $+($chr(2),$chr(31),:,$chr(2),$chr(31)) $hget(sockbot,rname)
  aline @sock $+($chr(2),::,$chr(2)) Host $+($chr(2),$chr(31),:,$chr(2),$chr(31)) $+(~,$hget(sockbot,ident),@,$sock(irc).ip)
  aline @sock $+($chr(2),::,$chr(2)) Server $+($chr(2),$chr(31),:,$chr(2),$chr(31)) $hget(sockbot,server) $+($chr(2),$chr(31),:,$chr(2),$chr(31)) $iif($hget(sockbot,port),$ifmatch,$sock(irc).port)
}

menu @sock {
  save log:filter -wf @sock $$?="enter filename ex: sock.txt"
  -
  $iif($sock(irc),$style(0),$style(2)) commands
  .op:sockbot op $$?="enter channel" $$?="enter nick"
  .deop:sockbot deop $$?="enter channel" $$?="enter nick"
  .voice:sockbot voice $$?="enter channel" $$?="enter nick"
  .devoice:sockbot devoice $$?="enter channel" $$?="enter nick"
  .-
  .kick:sockbot kick $$?="enter channel" $$?="enter nick"  $$?="enter reason"
  .kb:sockbot kb $$?="enter channel" $$?="enter nick" $$?="enter reason"
  .ban:sockbot ban $$?="enter channel" $$?="enter nick"
  .-
  .mode:sockbot mode $$?="enter channel"  $$?="enter mode ex: -n +n etc."
  .say:sockbot say $$?="enter channel" $$?="enter text"
  .nick:sockbot nick $$?="enter nickname"
  sock master
  .add:sockbot master add $$?="enter nick"
  .del:sockbot master del $$?="enter nick"
  auto join
  .add:sockbot ajoin add $$?="enter channel"
  .del:sockbto ajoin del $$?="enter channel"
  set info
  .ident:{ hadd sockbot ident $$?="enter ident" | .hsave -o sockbot sockbot.hsh }
  .real name:{ hadd sockbot rname $$?="enter real name ex: John Doe" | .hsave -o sockbot sockbot.hsh }
  -
  clear cache:dline @sock 1- | sock.window x
  sock info:{
    sock.window x
  }
  -
  find text:{
    var %1 = 1,%string = $$?="enter search word"
    while (%1 <= $fline(@sock,$+(*,$replace(%string,$chr(32),*),*),0)) {
      cline $color(info) @sock $fline(@sock,$+(*,$replace(%string,$chr(32),*),*),%1)
      inc %1
      .timer 1 10 sock.back
    }
  }
}

; --------- CORE ALIASES ---------

alias -l sload {
  if ($isfile($sockhash)) && (!$hget(sockbot)) && (!$1) { .hmake -s sockbot 1000 | .hload -s sockbot $sockhash }
  elseif ($1 == -n) { did -r soptions 7 | var %1 = 1 | while (%1 <= $hmatch(sockbot,ajoin*,0)) { did -a soptions 7 $gettok($hmatch(sockbot,ajoin*,%1),2,46) | inc %1  } }
  elseif ($1 == -c) && ($2) { did -r soptions 3 | var %1 = 1 | while (%1 <= $numtok($hget(sockbot,$+(ajoin.,$2)),44)) { did -a soptions 3 $gettok($hget(sockbot,$+(ajoin.,$2)),%1,44) | inc %1 } }
  elseif ($1 == -m) { did -r soptions 15 | var %1 = 1 | while (%1 <= $numtok($hget(sockbot,masters),44)) { did -a soptions 15 $gettok($hget(sockbot,masters),%1,44) | inc %1 } }
}
alias -l sjoin {
  var %1 = 1
  while (%1 <= $hmatch(sockbot,ajoin*,0)) {
    if ($+(*,$gettok($hmatch(sockbot,ajoin*,%1),2,46),*) iswm $hget(sockbot,server)) { sockwrite -n irc JOIN $hget(sockbot,$hmatch(sockbot,ajoin*,%1))  }
    inc %1
  }
}
alias -l sockhash return sockbot.hsh
alias -l sockparse $iif($window(@sock),aline @sock $timestamp $1-,halt)

Comments

Sign in to comment.
_dead   -  Feb 02, 2007
  • /hsave: no such table \'sockbot\' (line 91, script3.ini)
  • /hsave: no such table \'sockbot\' (line 91, script3.ini)
  • /hsave: no such table \'sockbot\' (line 91, script3.ini)
  • /hsave: no such table \'sockbot\' (line 91, script3.ini)
  • /hsave: no such table \'sockbot\' (line 91, script3.ini)
  • /hsave: no such table \'sockbot\' (line 91, script3.ini)
  • /hsave: no such table \'sockbot\' (line 91, script3.ini)
  • /hsave: no such table \'sockbot\' (line 91, script3.ini)
  • /hsave: no such table \'sockbot\' (line 91, script3.ini)
  • /hsave: no such table \'sockbot\' (line 91, script3.ini)
  • /hsave: no such table \'sockbot\' (line 91, script3.ini)
  • /hsave: no such table \'sockbot\' (line 91, script3.ini)
  • /hsave: no such table \'sockbot\' (line 91, script3.ini)
 Respond  
biase   -  Jul 26, 2005

elseif ($1 == mode) && ($sock(irc)) && ($hget(sockbot,nick)isop $2) { sockwrite -n irc MODE $2 $3 | sockparse mode change in $+($2,:) $3- }
better fix this one at ($hget(sockbot,nick)isop $2)

 Respond  
asianimage   -  Aug 09, 2004

your protections are too slow...try $hregex

 Respond  
SeiferAlmasy   -  Mar 31, 2004

good for you

 Respond  
AnTi-s0cIaL   -  Mar 26, 2004

i have a simpler script wot flood fuctions on it

 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.