Make ethercalc support optional
Do not require ethercalc URL and cells.
This commit is contained in:
parent
b8ca0c43ff
commit
b9790b685f
|
@ -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::
|
||||
|
||||
|
|
16
ptgbot/db.py
16
ptgbot/db.py
|
@ -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': {}}
|
||||
|
|
Loading…
Reference in New Issue