Skip to content

Instantly share code, notes, and snippets.

@dbieber
Last active February 14, 2021 04:56
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbieber/47660493954e62f4607cd8d19d54cf59 to your computer and use it in GitHub Desktop.
Save dbieber/47660493954e62f4607cd8d19d54cf59 to your computer and use it in GitHub Desktop.
"""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