Title: "Making a Socket Bot"

Author: Deathscythe_Hell

Date: April 29, 2000

Written for [#clan-X-scripterz] http://clan-x-scripterz.com


Sockets are the most efficient ways to make a bot. The unique things about a socket it is
that you can make a true bot, but without the mirc.exe. If you know Raw IRC (raw)
then making a socket bot would be no problemo! Lets start off with some examples:
First, we will open the socket using the "/sockopen" command, like so: /sockopen IRC irc.dal.net 6667 IRC is the name we will be specifing it as, because you might have multipule sockets open.
irc.dal.net is the server we are connectiong to. 6667 is the port
for the connection. Now since our socket is connected, lets register it to the server. You would have to manually type this: /sockwrite -n irc NICK Bob /sockwrite -n irc USER Bob . . Bob The -n in the command specifies mIRC to add a CarriageReturn/LineFeed combination ($crlf)
to the end of the text, somewhat like an enter. NICK is the command send
sent to the server, telling the sockets nick will be BOB. USER
is the command sent to the server, telling it to specify your real-name
and identd as Bob and Bob. You can
specify other words, but I recommend sticking with the nick. Say you didn't want to always manually type those commands? Well, you can use a remote to do it
for you. It would be the on SOCKOPEN event. It would look like this: on *:SOCKOPEN:irc:{ sockwrite -n irc NICK Bob sockwrite -n irc USER Bob . . Bob } You could also use a %variable to set as the nick, and replace Bob with %variable Now, say you want to find out the text that another user typed, or you want to find out what the server
sent you. In that case, you would use the /sockread command with a
on SOCKREAD event. It would look something like this: on *:SOCKREAD:irc:{ sockread %temp } %temp is going to be the variable we will set the text as, Now, we can find out the nick-name, or
the server, by extending out our on SOCKREAD event like so: on *:SOCKREAD:irc:{ sockread %temp set %nick $gettok(%temp,1,33) set %nick $remove(%nick,!,:) } Here, it sets %nick the first token of %temp, using the character with an ASCII number of 33,
which is an exclamtion point (!) by using the $gettok identifier.
If Bill had an address of ant.isp.com, and his
ident was hello, and he said "Hello, I am Bill"
in channel #chat, %temp would look like this: :Bill!hello@any.isp.com PRIVMSG #chat :Hello, I am Bill PRIVMSG means that the suser messaged the following word with the text following the target to send
the text to. So, in this case, he messaged #chat Hello, I am Bill Now, say we want the bot to respond to any user that types Hello, in the channel #chat, by messaging
the channel with the Hello, with there nick behind it. How would we do that? We would extend out on SOCKREAD event even
more. It would look like this: on *:SOCKREAD:irc:{ sockread %temp set %nick $gettok(%temp,1,33) set %nick $remove(%nick,!,:) tokenize 32 $gettok(%temp,2-,32) if (($1 == PRIVMSG) && ($2 == #chat) && ($right($3,-1) == Hello)) { sockwrite -n irc PRIVMSG $2 :Hello, %nick } } The tokenize command fills in $1, $2, $3, $N parameters with %temp using the character with a
ASCII number of 32, which is a space. Now the if statement checks if $1 equals PRIVMSG and $2 equals the channel
and the text the user sends equals Hello. If all the statements are true,
then the script will send PRIVMSG #chat :Hello <nick> to the IRC
server, which, the server, will eventually send to the other users that u said Hello
<nick> For help with raw IRC commands, please look at the rfc for raw IRC commands.