#!/usr/bin/python # -*- coding: utf-8 -*- import random from mastodon import Mastodon mastodon = Mastodon(access_token = 'ejemplo5eDmsrdeuntokenbgj7qf7WiTdo_X5dWUt4do2mMcKBqay8k', api_base_url = 'https://mastodon.madrid/') dataDir = "/home/fanta/repositorios/Haiku_generator/data" def random_line(fname): lines = open(fname).read().splitlines() return random.choice(lines) # Get random haiku lines line1 = random_line(dataDir + "/linea1.txt") line2 = random_line(dataDir + "/linea2.txt") line3 = random_line(dataDir + "/linea3.txt") # join the lines haiku = line1 + "\n" + line2 + "\n" + line3 # send the haiku to mastodon mastodon.status_post(haiku)