-
Notifications
You must be signed in to change notification settings - Fork 0
/
control.nim
43 lines (35 loc) · 916 Bytes
/
control.nim
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
import irc, strutils, secret
const
forbiddenCommands = ["exec", "quit", "exit", "disconnect"]
allowedNicks = ["onionly_me", "ryozukii", "deen_ddnet", "ddnetlive",
"aoeteeworlds", "learath2"]
var
client = newIrc("irc.twitch.tv", nick = "ddnetlive",
serverPass = serverPass, joinChans = @["#ddnetlive"])
fifo = open("input.fifo", fmWrite)
proc handle(nick, cmd: string) =
if nick notin allowedNicks:
return
for f in forbiddenCommands:
if cmd.contains(f):
return
echo nick, ": ", cmd
stdout.flushFile()
fifo.write(cmd)
fifo.write("\n")
fifo.flushFile()
client.connect()
var event: TIrcEvent
while true:
if client.poll(event):
case event.typ
of EvConnected:
discard
of EvDisconnected, EvTimeout:
client.reconnect()
of EvMsg:
case event.cmd
of MPrivMsg:
handle(event.nick, event.params[^1])
else:
discard