From dcf694d5d01f400524b33a87753fb25d0bb83ab8 Mon Sep 17 00:00:00 2001 From: ngharo Date: Thu, 14 Sep 2017 15:42:02 -0500 Subject: Working cut for bots that connect to Freenode --- main.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 main.py (limited to 'main.py') diff --git a/main.py b/main.py new file mode 100644 index 0000000..2b8a902 --- /dev/null +++ b/main.py @@ -0,0 +1,41 @@ +import sys +import math +import collections +import zokket +from bot import Bot + +botname_prefix = 'audzx' +queue = collections.deque() +rate = 5.0 # messages +per = 8.0 # seconds +max_workers = 6 +channel = '#test123aszz' + +if len(sys.argv) == 2: + channel = sys.argv[1] + +if channel[0] != '#': + channel = '#' + channel + +linecount = 0 +for line in sys.stdin: + queue.append(line.strip()) + linecount += 1 + +workers = int(math.ceil(linecount / rate)) +if workers > max_workers: + workers = max_workers + +if workers == 0: + sys.exit(1) + +print 'starting {} worker threads'.format(workers) +threads = [] +for i in range(workers): + botname = botname_prefix + chr(97 + i) + threads.append(Bot(channel, threads, queue, botname, rate, per)) + +for bot in threads: + bot.start() + +zokket.DefaultRunloop.run() -- cgit v1.2.3