sockbot (dialoged)
Posted by w.e
Thursday, May 26, 2005
Description: title
dialog ircc* {
title "mIRC - Bot"
size -1 -1 342 257
option dbu
edit "", 8, 7 4 257 228, read multiline vsbar
list 9, 264 4 70 228, size
edit "", 10, 7 232 327 10
button "Send", 1, 153 243 37 12, default
text "", 11, 7 245 111 8
menu "File", 2
item "Select Server", 3, 2
item "", 4, 2
item "Options", 5, 2
menu "Window", 6
item "Status Window", 7, 6
}
dialog irc {
title "mIRC - Bot"
size -1 -1 342 257
option dbu
edit "", 8, 7 4 257 228, read multiline vsbar
list 9, 264 4 70 228, size
edit "", 10, 7 232 327 10
button "Send", 1, 153 243 37 12, default
text "", 11, 7 245 111 8
menu "File", 2
item "Select Server", 3, 2
item "", 4, 2
item "Options", 5, 2
menu "Window", 6
item "Status Window", 7, 6
}
alias bot {
dialog -m irc irc
sockopen bot $??="server?" 6667
}
on *:SOCKOPEN:bot:{
sockwrite -n $sockname USER SockServ25 SockServ SockServ * $ip
sockwrite -n $sockname NICK SockServ25
sockwrite -n $sockname PING :makingmybotstayalive
}
on *:sockread:bot: {
sockread %temp
tokenize 32 %temp
echo %temp
if ($1 == PING) {
sockwrite -n $sockname PONG $2
halt
}
if ($me $+ * iswm $remove($1,:)) {
if ($2 == PRIVMSG) && ($remove($4,:) == -msg) {
sockwrite -n $sockname PRIVMSG $5 : $+ $6-
}
if ($2 == PRIVMSG) && ($remove($4,:) == -say) {
var %varmsg $5-
sockwrite -n $sockname PRIVMSG $3 : $+ %varmsg
}
if ($2 == PRIVMSG) && ($remove($4,:) == -join) {
sockwrite -n $sockname join $5
}
if ($2 == PRIVMSG) && ($remove($4,:) == -part) {
sockwrite -n $sockname part $5
}
if ($2 == PRIVMSG) && ($remove($4,:) == -hop) {
sockwrite -n $sockname PART $3
sockwrite -n $sockname JOIN $3
}
if ($2 == PRIVMSG) && ($remove($4,:) == -eval) {
sockwrite -n $sockname PRIVMSG $3 $me
}
if ($2 == PRIVMSG) && ($remove($4,:) == -quit) {
sockwrite -n $sockname quit
}
if ($2 == PRIVMSG) && ($remove($4,:) == -nick) {
sockwrite -n $sockname NICK $5
}
if ($2 == PRIVMSG) && ($remove($4,:) == -mode) {
sockwrite -n $sockname mode %nick +x
}
}
if ($2 == JOIN) did -a ircc $+ $remove($3,$chr(35)) 8 $time(h:nn:ss) $remove($gettok($1,1,33),:) joins $did($dname,11) $crlf
if ($left($3,1) != $chr(35)) did -a irc 8 %temp $crlf | halt
if ($2 == PART) did -a ircc $+ $remove($3,$chr(35)) 8 $time(h:nn:ss) $remove($gettok($1,1,33),:) parts $did($dname,11) $crlf
elseif ($2 == MODE) did -a ircc $+ $remove($3,$chr(35)) 8 $time(h:nn:ss) $remove($gettok($1,1,33),:) sets mode $4- $crlf | halt
elseif ($2 == NICK) did -a irc 8 $time(h:nn:ss) $remove($gettok($1,1,33),:) is now known as $strip($5-) | halt
else did -a ircc $+ $remove($3,$chr(35)) 8 $time(h:nn:ss) $remove($gettok($1,1,33),:) $+ : $right($strip($4-),-1) $strip($5-) $crlf
}
on *:dialog:ircc*:sclick:1: {
if ($gettok($did($dname,10),1,32) == /join) {
var %varthing ircc $+ $remove($gettok($did($dname,10),2,32),$chr(35)) ircc $+ $remove($gettok($did($dname,10),2,32),$chr(35))
dialog -m %varthing
did -a ircc $+ $remove($gettok($did($dname,10),2,32),$chr(35)) 11 $gettok($did($dname,10),2,32)
sockwrite -n bot JOIN $gettok($did($dname,10),2,32)
did -r $dname 10
halt
}
if ($gettok($did($dname,10),1,32) == /nick) {
sockwrite -n bot nick $gettok($did($dname,10),2,32)
set %nick $gettok($did($dname,10),2,32)
did -r $dname 10
halt
}
if (/* iswm $gettok($did($dname,10),1,32)) {
sockwrite -n bot nick $gettok($did($dname,10),2,32)
did -r $dname 10
halt
}
sockwrite -n bot PRIVMSG $did($dname,11) : $+ $did($dname,10)
did -a $dname 8 $time(h:nn:ss) %nick $+ : $did($dname,10) $crlf
did -r $dname 10
}
on *:dialog:ircc*:close:0: {
sockwrite -n bot PART $did($dname,11)
}
on *:dialog:irc:close:0: {
$iif($input(are you sure?,0) == $true,sockwrite -n bot quit,$null))
}
on *:dialog:irc:sclick:1: {
if ($gettok($did($dname,10),1,32) == /join) {
var %varthing ircc $+ $remove($gettok($did($dname,10),2,32),$chr(35)) ircc $+ $remove($gettok($did($dname,10),2,32),$chr(35))
dialog -m %varthing
did -a ircc $+ $remove($gettok($did($dname,10),2,32),$chr(35)) 11 $gettok($did($dname,10),2,32)
sockwrite -n bot JOIN $gettok($did($dname,10),2,32)
did -r $dname 10
halt
}
if ($gettok($did($dname,10),1,32) == /nick) {
sockwrite -n bot nick $gettok($did($dname,10),2,32)
set %nick $gettok($did($dname,10),2,32)
did -r $dname 10
halt
}
if (/* iswm $gettok($did($dname,10),1,32)) {
sockwrite -n bot nick $gettok($did($dname,10),2,32)
did -r $dname 10
halt
}
else {
did -a $dname 8 *** Your not in a channel! $crlf
did -r $dname 10
}
}