Skip to content

Instantly share code, notes, and snippets.

@myano
Created Jan 30, 2019
Embed
What would you like to do?
#!/usr/bin/env python3
import copy
from collections import OrderedDict
f = open('weechat.conf', 'r')
formats = ['/join -noswitch ', '/query ']
networks = {
'freenode': copy.copy(formats),
'freenode-vsy': copy.copy(formats),
'freenode-wx': copy.copy(formats),
'freenode-yn': copy.copy(formats),
'oftc6': copy.copy(formats),
'efnet': copy.copy(formats),
#'rizon': copy.copy(formats),
#'notacon': copy.copy(formats),
#'sorcery': copy.copy(formats),
'snoonet': copy.copy(formats),
#'undernet': copy.copy(formats),
'mozilla': copy.copy(formats),
'foonetic': copy.copy(formats),
'irccloud': copy.copy(formats),
}
for line in f:
for network in networks.keys():
if 'buffer = "irc;' + network + '.' in line:
l = line.split(';')
g = l[1].split('.', 1)
channel = ''.join(g[1:])
if channel.startswith('#'):
networks[network][0] += channel + ','
else:
nick = channel
networks[network][1] += nick + ','
f.close()
#sorted_networks = OrderedDict(sorted(sorted_networks.items()))
for x in sorted(networks):
print('/connect ' + str(x))
for y in networks[x]:
print('\t', y)
print('')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment