Skip to content

Commit 69d9856

Browse files
committed
Dockerized irclogger. (Closes Issue #9)
1 parent abc0422 commit 69d9856

File tree

4 files changed

+17
-10
lines changed

4 files changed

+17
-10
lines changed

Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM crux/python:onbuild
2+
3+
ENTRYPOINT ["irclogger"]
4+
CMD ["-c", "#circuits", "irc.freenode.net", "6667"]

irclogger/main.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111

1212
from __future__ import print_function
1313

14+
from uuid import uuid4 as uuid
1415
from socket import gethostname
1516
from optparse import OptionParser
1617
from collections import defaultdict
17-
from socket import error as SocketError
1818
from time import localtime, strftime, time
1919
from datetime import date, datetime, timedelta
2020
from os import environ, getcwd, makedirs, path
@@ -48,6 +48,13 @@
4848
PIDFILE = path.join(path.dirname(__file__), "{0:s}.pid".format(__name__))
4949

5050

51+
def randnick():
52+
x = uuid().hex
53+
xs = map(str.isalpha, x)
54+
i = xs.index(True)
55+
return x[i:][:10]
56+
57+
5158
def parse_options():
5259
parser = OptionParser(usage=USAGE, version=VERSION)
5360

@@ -65,7 +72,7 @@ def parse_options():
6572

6673
parser.add_option(
6774
"-n", "--nick",
68-
action="store", default=environ["USER"], dest="nick",
75+
action="store", default=environ.get("USER", randnick()), dest="nick",
6976
help="Nickname to use"
7077
)
7178

@@ -212,10 +219,10 @@ def ready(self, component):
212219
def keepalive(self):
213220
self.fire(write(b"\x00"))
214221

215-
def error(self, etype, evalue, etraceback, handler=None):
216-
if isinstance(evalue, SocketError):
217-
if not self.transport.connected:
218-
Timer(5, connect(self.host, self.port)).register(self)
222+
def error(self, *args):
223+
print("ERROR:", args)
224+
if not self.transport.connected:
225+
Timer(5, connect(self.host, self.port)).register(self)
219226

220227
def connected(self, host, port):
221228
"""Connected Event

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
circuits
2-
.

start

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)