Jerry Bell :verified_paw: :donor: on Nostr: nprofile1q…quqhd it's a custom python script I wrote (with help from chatgpt) using ...
nprofile1qy2hwumn8ghj7un9d3shjtnddaehgu3wwp6kyqpqde6v4m79lpgak3rs3vmy8ppa90e8qqhuhxs3u9uh6ysfu3df7vyqtquqhd (nprofile…uqhd) it's a custom python script I wrote (with help from chatgpt) using the Mastodon python library. The quotes are in a text file and the script selects a random row from the text file each time cron calls it. The script looks like this:
text_file_path = '/home/provision/bots/suntzu/quotes.txt'
MASTODON_API_BASE_URL = 'https://infosec.exchange'; # Replace with your instance
ACCESS_TOKEN = 'redacted' # Replace with your access token
def get_random_line(file_path):
with open(file_path, 'r') as file:
lines = file.readlines()
return random.choice(lines).strip()
def post_to_mastodon(content):
mastodon = Mastodon(
access_token=ACCESS_TOKEN,
api_base_url=MASTODON_API_BASE_URL
)
mastodon.toot(content)
if __name__ == "__main__":
random_quote = get_random_line(text_file_path)
post_to_mastodon(random_quote)
text_file_path = '/home/provision/bots/suntzu/quotes.txt'
MASTODON_API_BASE_URL = 'https://infosec.exchange'; # Replace with your instance
ACCESS_TOKEN = 'redacted' # Replace with your access token
def get_random_line(file_path):
with open(file_path, 'r') as file:
lines = file.readlines()
return random.choice(lines).strip()
def post_to_mastodon(content):
mastodon = Mastodon(
access_token=ACCESS_TOKEN,
api_base_url=MASTODON_API_BASE_URL
)
mastodon.toot(content)
if __name__ == "__main__":
random_quote = get_random_line(text_file_path)
post_to_mastodon(random_quote)