Skip to content

Instantly share code, notes, and snippets.

@necrobuffalo
Last active March 3, 2017 00:05
Show Gist options
  • Save necrobuffalo/5c1c7eae0eb01d73457064fa6ec55891 to your computer and use it in GitHub Desktop.
Save necrobuffalo/5c1c7eae0eb01d73457064fa6ec55891 to your computer and use it in GitHub Desktop.
foodbot
[trello]
api_key=from site
api_secret=from site
token=from oauth
token_secret=from oauth
board=groceries
[notify]
pushbullet_token=from site
from trello import TrelloClient
from pushbullet import Pushbullet
import random
import configparser
config = configparser.ConfigParser()
config.read('bot.cfg')
client = TrelloClient(
api_key=config['trello']['api_key'],
api_secret=config['trello']['api_secret'],
token=config['trello']['token'],
token_secret=config['trello']['token_secret']
)
starch = client.search("board:{} label:starch list:have".format(config['trello']['board']))
vegetable = client.search("board:{} label:vegetable list:have".format(config['trello']['board']))
protein = client.search("board:{} label:protein list:have".format(config['trello']['board']))
text = "{}, {}, {}".format(random.choice(starch).name,random.choice(vegetable).name,random.choice(protein).name)
pb = Pushbullet(config['notify']['pushbullet_token'])
pb.push_note("Go eat something.", text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment