Make ethercalc support optional

Do not require ethercalc URL and cells.
This commit is contained in:
Thierry Carrez 2017-05-29 17:21:43 +02:00
parent b8ca0c43ff
commit b9790b685f
2 changed files with 14 additions and 8 deletions

View File

@ -46,7 +46,11 @@ Edit config.ini contents, for example::
server=irc.freenode.net
port=6667
channels=testptg
db=html/ptg.json
[db]
filename=html/ptg.json
ethercalc=
cells=
In one terminal, run the bot::

View File

@ -44,13 +44,15 @@ class PTGDataBase():
self.save()
def from_ethercalc(self):
ethercalc = requests.get(self.ethercalc_url).json()
self.data['ethercalc'] = []
for cell in self.ethercalc_cells:
if 'comment' in ethercalc[cell] and 'datavalue' in ethercalc[cell]:
msg = '%s: %s' % (ethercalc[cell]['comment'],
ethercalc[cell]['datavalue'])
self.data['ethercalc'].append(msg)
if self.ethercalc_url:
ethercalc = requests.get(self.ethercalc_url).json()
self.data['ethercalc'] = []
for cell in self.ethercalc_cells:
if ('comment' in ethercalc[cell] and
'datavalue' in ethercalc[cell]):
msg = '%s: %s' % (ethercalc[cell]['comment'],
ethercalc[cell]['datavalue'])
self.data['ethercalc'].append(msg)
def wipe(self):
self.data = {'now': {}, 'next': {}}