-
-
Save dbieber/47660493954e62f4607cd8d19d54cf59 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See https://gist.github.com/dbieber/e85bbe9ddbc5868f6fcc34a0f8b5241a for twitter_tool.py
and https://gist.github.com/dbieber/7722280c7fa10d1fdfa507612427001d for roam.py