show commit message; added nimc cfg
[d2df-bot.git] / src / d2dfbot.nim
blob4ddbffd4ae1a97580a564911dcf856dac9aa2b7e
1 import irc, strutils, tables, times, threadpool, net
2 import config, commands, buildsys
4 var refreshTime: float = epochTime() + 100.0
6 var client = newIrc(ircHost, ircPort.Port,
7                     nick = ircNick, user = ircNick, realname = ircNick,
8                     joinChans = @[ircChannel])
9 client.connect()
11 while true:
12   checkBuildFinished(client)
14   if epochTime() > refreshTime:
15     if masterRefresh:
16       checkServerChanges(client)
17     if buildAutoRebuild:
18       checkRebuildNeeded(client)
19     refreshTime = epochTime() + masterRefreshTime
21   var event: IrcEvent
22   if client.poll(event, 100):
23     case event.typ
24     of EvConnected:
25       discard
26     of EvDisconnected, EvTimeout:
27       break
28     of EvMsg:
29       if event.cmd == MPrivMsg:
30         checkMemos(client, event)
31         let msg = event.params[event.params.high]
32         if msg.startsWith(".:") and msg.len > 2:
33           let argv = msg[2 .. ^1].splitWhitespace()
34           let cmd = argv[0]
35           let args = argv[1 .. ^1].join(" ")
36           if cmd in botCommands:
37             echo("command: ", cmd, " ", args)
38             botCommands[cmd](client, event, args)
39       echo(event.raw)