My Daily Gist | Ferdinand Silva


Socket Programming Sample Code In Titik PL (IRC Echo Bot)

 
irc_port = 6667
socket = ""
irc_server = r("Please Enter IRC Server Address: ")
irc_nick = r("Please Enter IRC Nick: ")
irc_channel = r("Please Enter IRC Channel: ")
socket = netc("tcp", irc_server + ":" + tos(irc_port))
socket_msg = ""
wl (T)
socket_msg = netr(socket, 1024)
if (str_ind(socket_msg, "ERROR :Closing link:") > -1)
brk
ef (str_ind(socket_msg, "Looking up your ident") > -1)
netw(socket, "NICK " + irc_nick + "\n")
netw(socket, "USER " + irc_nick + ' "' + irc_nick + '.com" "' + irc_server + '" : ' + irc_nick + " robot\n")
ef (str_ind(socket_msg, "PING ") > -1)
netw(socket, str_rpl(socket_msg, "PING", "PONG") + "\n")
ef (str_ind(socket_msg, "End of message of the day") > -1)
netw(socket, "JOIN #" + irc_channel + "\n")
ef (str_ind(socket_msg, "PRIVMSG #" + irc_channel) > -1)
netw(socket, "PRIVMSG #" + irc_channel + " :The message is: " + str_spl(socket_msg, "PRIVMSG #" + irc_channel + " :")[1] + "\n")
fi
p(socket_msg)
lw
view raw bot.ttk hosted with ❤ by GitHub