Browse Source

Make ethercalc support optional

Do not require ethercalc URL and cells.
changes/56/473756/1
Thierry Carrez 4 years ago
parent
commit
b9790b685f
2 changed files with 14 additions and 8 deletions
  1. +5
    -1
      README.rst
  2. +9
    -7
      ptgbot/db.py

+ 5
- 1
README.rst 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::


+ 9
- 7
ptgbot/db.py 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': {}}


Loading…
Cancel
Save