Skip to content

Instantly share code, notes, and snippets.

@myano
Created January 30, 2019 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save myano/e6914b678e77835b8dafbea992d49ef3 to your computer and use it in GitHub Desktop.
Save myano/e6914b678e77835b8dafbea992d49ef3 to your computer and use it in GitHub Desktop.
#!/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