Closed tlevine closed 11 years ago
@abelsonlive Does this work? https://github.com/csvsoundsystem/fms_parser/blob/master/twitter/tweetbot.py
If so, maybe
api.yml
and then it's done
Yes, the twitter bot does work, But it needs more tweet types!
Here's how to contribute tweets:
SELECT date, close_today FROM t3c WHERE (item LIKE \'%subject to limit%\' AND year = 2013 AND month >=1) ORDER BY date DESC
QUERIES
dictionary in tweetbot.py
, eg:QUERIES = {'total_debt': 'SELECT date, close_today FROM t3c WHERE (item LIKE \'%subject to limit%\' AND year = 2013 AND month >=1) ORDER BY date DESC'}
def total_debt_tweet(df):
# determine length of DataFrame
end = len(df)-1
# extract current amount and amount at the beginning of the year
current_amt = df['close_today'][0]*MIL
previous_amt = df['close_today'][end]*MIL
# calculate change
delta = abs(current_amt - previous_amt)
# generate word to represnet the direction of change
if current_amt > previous_amt:
change = "increased"
elif current_amt < previous_amt:
change = "decreased"
# humanize values
# Notice the included `human_date` and `human_number` functions which simplify these values for you
current_date = human_date(df['date'][0])
amt = human_number(current_amt)
delta = human_number(delta)
previous_date = human_date(df['date'][end])
# generate tweet
vals = (current_date, amt, change, previous_date, URL)
return "As of %s, the US Gov is $%s in debt. This amount has %s since %s - %s" % vals
construct_tweet
to include your new query, eg:
def construct_tweet(options):
t = options.tweet_type
df = treasury_io(QUERIES[t])
if t == 'total_debt':
return total_debt_tweet(df)
-t
flag and the name of the query you just wrote:python twitter/tweetbot.py -t total_debt
It might be convenient to put this in the Python package along with the the importer code.
I suppose so, I'm not sure how much we want to encourage other people to make their own tweet bots. What do others think?
@abelsonlive, can you document how to get those tokens?
And if you have an api.yml for a test account, could you send it to me?
I think letting people make their own tweet bots is like letting people make their own graphs.
Check out csvsoundsystem/pytreasuryio@73dca84a3e43502e425e864b02715fd4fa9ffe06.
~/.twitter.yml
: csvsoundsystem/pytreasuryio@7e91b3d422dbc57220c35aa91b8153270d8df09dIt wasn't quite working when I closed it, but now it seems to be. f29e95f1a764aa68addbb00bbed2928f20817bbf
We will deliver a "Twitter bot that will tweet daily new data notifications."