separate data to config constants, add
This commit is contained in:
parent
f1b48d77df
commit
a5508e5ef2
1 changed files with 20 additions and 7 deletions
27
irc.lamb
27
irc.lamb
|
@ -1,8 +1,15 @@
|
||||||
-- global data stuff
|
-- config constants
|
||||||
|
|
||||||
|
HOST = "127.0.0.1".
|
||||||
|
PORT = 6667.
|
||||||
|
NICK = "lambot".
|
||||||
|
|
||||||
-- nicks of administrators
|
-- nicks of administrators
|
||||||
ADMINS = ["darkf"].
|
ADMINS = ["darkf"].
|
||||||
|
|
||||||
|
-- channels to join
|
||||||
|
CHANS = ["#lobby"].
|
||||||
|
|
||||||
-- First we'll define some helper functions
|
-- First we'll define some helper functions
|
||||||
|
|
||||||
map(f, []) -> [].
|
map(f, []) -> [].
|
||||||
|
@ -130,6 +137,13 @@ handleMessage(s, nick, chan, "$savefacts") -> do
|
||||||
s
|
s
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
handleMessage(s, nick, chan, "$join "::j) -> do
|
||||||
|
if isAdmin(nick) then do
|
||||||
|
fputstr(sock, "JOIN " + j + "\r\n");
|
||||||
|
s
|
||||||
|
end else s
|
||||||
|
end.
|
||||||
|
|
||||||
handleMessage(s, nick, chan, "$ping") -> do say(chan, nick + ": pong"); s end.
|
handleMessage(s, nick, chan, "$ping") -> do say(chan, nick + ": pong"); s end.
|
||||||
|
|
||||||
handleMessage(s, nick, chan, "$quit") -> do
|
handleMessage(s, nick, chan, "$quit") -> do
|
||||||
|
@ -213,14 +227,13 @@ end.
|
||||||
-- now for our actual program!
|
-- now for our actual program!
|
||||||
|
|
||||||
-- build our socket and connect to the server
|
-- build our socket and connect to the server
|
||||||
sock = sockopen("127.0.0.1", 6667).
|
sock = sockopen(HOST, PORT).
|
||||||
|
|
||||||
-- send introduction
|
-- send introduction
|
||||||
fputstr(sock, "PASS foobar\r\n").
|
fputstr(sock, "PASS " + NICK + "\r\n").
|
||||||
fputstr(sock, "NICK quaileggeater\r\n").
|
fputstr(sock, "NICK " + NICK + "\r\n").
|
||||||
fputstr(sock, "USER fooname 0 * :Foo G. Bar\r\n").
|
fputstr(sock, "USER " + NICK + " 0 * :Lamb Da. Bot\r\n").
|
||||||
fputstr(sock, "JOIN #TYBG\r\n").
|
map(\chan -> fputstr(sock, "JOIN " + chan + "\r\n"), CHANS).
|
||||||
fputstr(sock, "PRIVMSG #TYBG :sup.\r\n").
|
|
||||||
|
|
||||||
-- loop receiving lines
|
-- loop receiving lines
|
||||||
mainloop(state) ->
|
mainloop(state) ->
|
||||||
|
|
Loading…
Reference in a new issue