A basic socket bot for mIRC
This is only the basic skeleton of what I hope to be the finished product, Im only posting this to get some opinions before I try to go more in depth. Compliments, comments, and constructive criticism are welcome :)
To Use
Right click any window
Click "Run Ninjabot"
Changelog
v1.1
dialog ninjabot {
title "Ninja Bot"
size -1 -1 326 266
option pixels notheme
tab "Main", 1, 1 0 325 260
tab "Remote", 7
tab "Log", 20
button "Connect", 2, 69 225 65 25, tab 1 ok
edit %sockbot.server, 3, 63 48 198 20, tab 1 %sockbot.server
edit %sockbot.port, 4, 113 88 100 20, tab 1 %sockbot.port
text "Server", 5, 111 32 100 17, tab 1 center
text "Port", 6, 113 72 100 17, tab 1 center
text "Say", 12, 13 36 100 17, tab 7
edit "", 13, 114 51 100 20, tab 7 autohs
edit "", 14, 114 80 178 20, tab 7 autohs
text "Raw", 15, 13 184 100 17, tab 7
edit "", 16, 39 200 262 20, tab 7 autohs
button "Send", 17, 131 225 65 25, tab 7 ok
text "Target", 18, 36 52 71 17, tab 7
text "Message", 19, 36 81 71 17, tab 7
edit "", 21, 6 25 314 226, tab 20 autovs multi hsbar vsbar
text "Password", 22, 113 116 100 17, tab 1 center
edit %sockbot.pass, 23, 64 132 198 20, tab 1 pass autohs %sockbot.pass
text "Nick", 24, 113 160 100 17, tab 1 center
edit %sockbot.nick, 25, 71 176 185 20, tab 1 autohs %sockbot.nick
text "Other Commands", 8, 13 119 100 17, tab 7
combo 9, 36 144 100 70, tab 7 drop
edit "", 10, 135 144 154 20, tab 7
button "Background", 11, 171 225 65 25, tab 1
}
menu channel,status,menubar {
-
Run Ninjabot:dialog $iif($dialog(ninjabot),-v,-m) ninjabot ninjabot
}
on *:DIALOG:ninjabot:*:0:{ if ($devent == init) { did -a $dname 9 NICK
did -a $dname 9 JOIN
did -a $dname 9 PART
did -a $dname 9 UMODE
}
elseif ($devent == close && $sock(ninjabot)) { botsend quit :Ninja Bot 12m4IR8C Socket Bot $nbv
sockclose ninjabot
}
}
on *:DIALOG:ninjabot:SCLICK:2:{ if ($sock(ninjabot)) { sockclose ninjabot }
if (!$did(3) || !$did(4) || !$did(25)) { noop $input(Error! One or more required fields were not filled out,ok10,Ninja Bot) }
elseif (*.*.* !iswm $did(3) && $did(3)) { noop $input(Error! $did(3) is not a valid server,ok10,Ninja Bot) }
elseif ($did(4) !isnum && $did(4)) { noop $input(Error! $did(4) is not a valid port,ok10,Ninja Bot) }
else { sockopen ninjabot $did(3) $did(4)
sockmark ninjabot $did(25) $did(23)
did -a $dname 21 $timestamp Opening connection... $crlf
}
}
on *:DIALOG:ninjabot:SCLICK:17:{ haltdef
if ($did(13) && $did(14)) { botsend privmsg $did(13) $+(:,$did(14)) }
if ($did(16)) { botsend $did(16) }
if ($did(9) && $did(10)) { if ($did(9) == JOIN) { botsend join $did(10) }
elseif ($did(9) == PART) { botsend part $gettok($did(10),1,32) :Ninja Bot 12m4IR8C Socket Bot $nbv }
elseif ($did(9) == NICK) { botsend nick $did(10)
sockmark ninjabot $puttok($sock(ninjabot).mark,$did(10),1,32)
}
elseif ($did(9) == UMODE) { botsend mode $gettok($sock(ninjabot).mark,1,32) $did(10) }
}
did -r $dname 10
did -r $dname 14
}
on *:DIALOG:ninjabot:SCLICK:11:{ dialog -x $dname
noop $input($+(Bot will now continue to run in the background,$crlf,No logs will be collected during this time),ok10,Ninja Bot)
}
on *:SOCKOPEN:ninjabot:{ tokenize 32 $sock($sockname).mark
sockwrite -nt $sockname nick $1
sockwrite -nt $sockname user ninjabot ninjabot ninjabot :mIRC Socket Bot
if ($2) { sockwrite -nt $sockname pass $2 }
}
on *:SOCKREAD:ninjabot:{ sockread %data
if ($sockerr) { did -a ninjabot 21 $timestamp [ERROR] $sock($sockname).wsmsg | halt }
if ($dialog(ninjabot)) { did -a ninjabot 21 $timestamp %data $+ $crlf }
tokenize 32 %data
if ($1 == PING) { botsend PONG $2 }
}
on *:SOCKCLOSE:ninjabot:{ dialog -x ninjabot
echo $color(info) -at *** Ninja Bot was disconnected from the server $+($chr(40),%data,$chr(41))
}
on *:UNLOAD:{ unset %sockbot.*
echo $color(info) -at *** Ninja bot has been unloaded and all associated variables were cleared
}
alias -l botsend { sockwrite -nt ninjabot $1- }
alias -l noserv { return $remove($1-,:) }
alias nbv { return v1.1 }
u dont check if $did(3) is a good format eg: www.site.com
u can put the variable directly in dialog but not like u put it
instead of
edit "", 3, 63 48 198 20, tab 1 autohs %sockbot.server
edit "", 4, 113 88 100 20, tab 1 %sockbot.port
must be
edit %sockbot.server, 3, 63 48 198 20, tab 1 %sockbot.server
edit %sockbot.server, 4, 113 88 100 20, tab 1 %sockbot.port
then u can remove the init part in dialog event