Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save paul-english/0228d2263982afc41e8e582d270e8493 to your computer and use it in GitHub Desktop.
Save paul-english/0228d2263982afc41e8e582d270e8493 to your computer and use it in GitHub Desktop.
FTL Bot
import requests
from slackclient import SlackClient
DAYS = 1
FTL_URL = "https://backend.thefoodtruckleague.com/events/?days=%s&name=" % DAYS
SLACK_TOKEN = ""
def post_food_trucks_for_the_day():
sc = SlackClient(SLACK_TOKEN)
res = requests.get(FTL_URL)
events = res.json()
draper_events = [e for e in events if e['city'] == 'Draper']
office_events = [e for e in draper_events if 'Frontrunner' in e['address']]
food_trucks_message = "Today's food trucks:\n\n" + "\n\n".join([
"""*%s*
%s""" % (t['name'].strip(), t['about'].strip())
#(t['name'].decode('unicode_escape'), t['about'])
for e in events
if e['city'] == 'Draper' and 'Frontrunner' in e['address']
for t in e['attending_trucks']
])
#print(repr(food_trucks_message))
sc.api_call(
"chat.postMessage",
channel="",
text=food_trucks_message,
user="",
as_user=True,
)
if __name__ == "__main__":
post_food_trucks_for_the_day()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment