Skip to content

Instantly share code, notes, and snippets.

@dbieber
Last active Feb 14, 2021
Embed
What would you like to do?
"""Every 10 minutes selects a topic from my Roam database and tweets it
from a private Twitter account. @PrivateBieber6
"""
import random
import time
import fire
import schedule
from messager import twitter_tool
import roam
def choose_message():
all_children = roam.get_children()
messages = []
for child in all_children:
if ('Things I\'d like to understand better' in child['string']
or 'Fleeting TODOs' in child['string']
or 'Distraction TODOs' in child['string']):
children = child.get('children', [])
for c in children:
if (c['string']
and '[[DONE]]' not in c['string']
and 'Distraction TODOs' not in c['string']
and len(c['string']) <= 240
and 'password' not in c['string'].lower()):
messages.append(c['string'])
return random.choice(messages)
def tweet(twitter):
message = choose_message()
twitter.sendPrivateTweet(message)
def main():
twitter = twitter_tool.Twitter()
schedule.every(10).minutes.do(tweet, twitter)
schedule.every(360).minutes.do(roam.update)
while True:
schedule.run_pending()
time.sleep(30)
if __name__ == '__main__':
fire.Fire()
@dbieber
Copy link
Author

dbieber commented Feb 9, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment