Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Weekly Automation
# Required pip installs: py-trello boto3
from trello import TrelloClient
from datetime import datetime
import boto3
import os
def log(input):
stamp = str(datetime.now())
print(stamp + " " + input)
def lambda_handler(event, context):
log("Begining.")
# Trello API credentials, acquired from https://trello.com/app-key
trello_client = TrelloClient(
api_key=os.environ['trello_api_key'],
api_secret=os.environ['trello_api_secret'],
token=os.environ['trello_api_token'],
token_secret=os.environ['trello_token_secret']
)
# AWS credentials
boto3_client = boto3.client(
"sns",
aws_access_key_id=os.environ['aws_access_key_id'],
aws_secret_access_key=os.environ['aws_secret_access_key'],
region_name="us-east-1"
)
# Replace with your IDs.
my_personal_board_id = 5
my_done_list_id = 2
my_release_list_id = 3
my_phone_number = os.environ['phone_number'] # Must be in E.164 format
all_boards = trello_client.list_boards()
personal_board = all_boards[my_personal_board_id]
pb_lists = personal_board.list_lists()
done_list = pb_lists[my_done_list_id]
release_list = pb_lists[my_release_list_id]
output = ""
cards = done_list.list_cards()
log("Cards retrieved.")
for i in range(len(cards)):
this_card = cards[i]
output = output + "\n• " + this_card.name
date = datetime.today().strftime('%Y-%m-%d')
new_card_title = "Week ending " + date
release_list.add_card(new_card_title, output)
done_list.archive_all_cards()
log("Release completed.")
to_print = "This week you accomplished:" + output
print(to_print)
boto3_client.publish(
PhoneNumber=my_phone_number,
Message=to_print
)
log("Text sent.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment