Created
May 28, 2022 09:58
-
-
Save six519/74ee75d70fe6d402d8833feeaab3de54 to your computer and use it in GitHub Desktop.
Socket Programming Sample Code In Titik PL (IRC Echo Bot)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment