Browse Source

Handle more formats (e.g. early aohell)

master
JustAnotherArchivist 3 years ago
parent
commit
878e5f39b6
1 changed files with 14 additions and 3 deletions
  1. +14
    -3
      efnet-irclogger-convert.py

+ 14
- 3
efnet-irclogger-convert.py View File

@@ -5,7 +5,7 @@ import sys
assert len(sys.argv) == 2, 'Arg: filename'
filename = sys.argv[1]

date = filename[:10]
date = filename.rsplit('/', 1)[-1][:10]

with open(filename, 'r') as fp:
for line in fp:
@@ -24,16 +24,27 @@ with open(filename, 'r') as fp:
words = line.split(' ')[1:]
if words[1:3] == ['has', 'joined']: # JOIN
print(f'{ts} JOIN {words[0]} joins')
elif words[0] == 'Joins:': # JOIN
print(f'{ts} JOIN {words[1]} joins')
elif words[1:3] == ['has', 'left']: # PART
print(f'{ts} PART {words[0]} leaves')
reason = f' [{" ".join(words[3:])}]' if len(words) > 4 or words[3] != '' else ''
print(f'{ts} PART {words[0]} leaves{reason}')
elif words[0] == 'Parts:': # PART
reason = f' [{" ".join(words[3:])[1:-1]}]' if len(words) > 4 or words[3] != '()' else ''
print(f'{ts} PART {words[1]} leaves{reason}')
elif words[1:4] == ['has', 'quit', 'IRC']: # QUIT
print(f'{ts} QUIT {words[0]} quits [{" ".join(words[4:])[1:-1]}]')
elif words[0] == 'Quits:': # QUIT
reason = f' [{" ".join(words[3:])[1:-1]}]' if len(words) > 4 or words[3] != '()' else ''
print(f'{ts} QUIT {words[0]} quits{reason}')
elif words[1:4] == ['was', 'kicked', 'by']: # KICK
print(f'{ts} KICK {words[0]} is kicked by {words[4]} [{" ".join(words[5:])[1:-1]}]')
elif words[1:3] == ['sets', 'mode:']: # MODE
print(f'{ts} MODE {line[4:]}')
elif words[1:4] == ['changes', 'topic', 'to:']: # TOPIC
print(f'{ts} TOPIC {words[0]} sets the topic to: {" ".join(words[5:])}')
print(f'{ts} TOPIC {words[0]} sets the topic to: {" ".join(words[4:])}')
elif words[1:4] == ['changes', 'topic', 'to']: # TOPIC
print(f'{ts} TOPIC {words[0]} sets the topic to: {" ".join(words[4:])[1:-1]}')
elif words[1:5] == ['is', 'now', 'known', 'as']: # NICK
print(f'{ts} NICK {line[4:]}')
elif words[1:3] == ['starts', 'logging']: # Silently ignore (there's already a JOIN)


Loading…
Cancel
Save