-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.moon
More file actions
47 lines (38 loc) · 1.19 KB
/
bot.moon
File metadata and controls
47 lines (38 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/env moon
require "socket"
require "moonscript"
require "thread"
require "irc"
version = "moonbot 0.2" .. string.format " [%s] on [%s]",
"MoonScript " .. (require "moonscript.version").version,
_VERSION
irc.connect
server: "irc.rizon.net"
port: 6666
nick: "moonbot"
version: version
callback: ->
init = coroutine.create ->
wait 10
do
password = os.getenv "PASSWORD"
message "NickServ", "IDENTIFY " .. password if password
wait 2
join "#rice"
received = (msg) -> -- Function for receiving messages
if msg == msg\match "PING :.+"
send string.format "PONG %s",
msg\match "PING :(.+)"
elseif msg == msg\match ":[^%s]+ PRIVMSG [^%s]+ :\001VERSION\001"
log "Sent version %s"\format version
send string.format "NOTICE %s :\001VERSION %s\001",
msg\match ":(.-)![^%s]+ PRIVMSG [^%s]+ :\001VERSION\001",
version
elseif (string.sub msg, 1, 1) == ":"
user, command, at, text = msg\match ":([^%s]+) ([^%s]+) ([^%s]+) :?(.+)"
if command == "PRIVMSG"
if text == ".bots"
message at, string.format "Reporting in!"
-- if text == ".me"
-- me at, "test"
{ :init, :received }