-
Notifications
You must be signed in to change notification settings - Fork 9
/
runbot.py
executable file
·42 lines (34 loc) · 1.16 KB
/
runbot.py
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
#!/usr/bin/env python
"""Run the bot."""
import argparse
import sys
import os
from twisted.internet import reactor
from twisted.internet.task import LoopingCall
from twisted.python import log
from twisted.web.client import Agent
from twisted.web.server import Site
from twisted.web.wsgi import WSGIResource
import pycon_bot.driver
from pycon_bot import settings
def run_bot(irc_server, irc_port, irc_channel, bot_name, logfile):
log.startLogging(logfile)
if irc_server is not None:
bot = pycon_bot.driver.PyConBotFactory([irc_channel], bot_name)
reactor.connectTCP(irc_server, irc_port, bot)
reactor.run()
if __name__ == '__main__':
p = argparse.ArgumentParser()
p.add_argument('--irc-server', default='irc.freenode.net')
p.add_argument('--irc-port', type=int, default=6667)
p.add_argument('--irc-channel', default=settings.IRC_CHANNEL),
p.add_argument('--irc-nickname', default=settings.IRC_NICK),
args = p.parse_args()
# Run ze bot!
run_bot(
irc_server=args.irc_server,
irc_port=args.irc_port,
irc_channel=args.irc_channel,
bot_name=args.irc_nickname,
logfile=sys.stderr,
)