[TASK] Establish a basic python package.

This commit is contained in:
Jan Philipp Timme 2015-12-12 13:51:46 +01:00
parent b32ae49953
commit c32487ee91
4 changed files with 36 additions and 29 deletions

3
piebot/__init__.py Normal file
View File

@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from .bot import ConnectionManager

View File

@ -4,7 +4,7 @@ import asyncio
import inspect
import logging
import irc
from . import irc
logging.basicConfig(format="[%(asctime)s] [%(levelname)s] %(message)s", level=logging.DEBUG, datefmt="%d.%m.%Y %H:%M:%S")
logger = logging.getLogger(__name__)
@ -176,30 +176,3 @@ class ConnectionManager(object):
self.remove_endpoint((host, port))
else:
loop.call_exception_handler(context)
if __name__ == "__main__":
loop = asyncio.get_event_loop()
connection_manager = ConnectionManager(loop)
connection_manager.add_endpoint(("irc.euirc.net", 6667), {
"encoding": "utf-8",
"nick": "Pb42",
"ident": "foobar2000",
"realname": "Baz McBatzen",
"channels": ["#botted"]
})
connection_manager.add_endpoint(("irc.freenode.net", 6667), {
"encoding": "utf-8",
"nick": "Pb42",
"ident": "foobar2000",
"realname": "Baz McBatzen",
"channels": ["#botted"]
})
try:
loop.run_forever()
except KeyboardInterrupt:
pass
finally:
loop.close()

View File

@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
def parse(line):
""" This is the basic irc line parser function.
"""
prefix = ""
subject = ""
trailing = ""

29
run.py Normal file
View File

@ -0,0 +1,29 @@
import asyncio
from piebot import ConnectionManager
loop = asyncio.get_event_loop()
# TODO: Move configuration into a config file!
connection_manager = ConnectionManager(loop)
connection_manager.add_endpoint(("irc.euirc.net", 6667), {
"encoding": "utf-8",
"nick": "Pb42",
"ident": "foobar2000",
"realname": "Baz McBatzen",
"channels": ["#botted"]
})
connection_manager.add_endpoint(("irc.freenode.net", 6667), {
"encoding": "utf-8",
"nick": "Pb42",
"ident": "foobar2000",
"realname": "Baz McBatzen",
"channels": ["#botted"]
})
try:
loop.run_forever()
except KeyboardInterrupt:
pass
finally:
loop.close()