Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from time import time
- import praw
- """
- HIROSHIMA
- 08/06/1945 08:16:00 JST
- -770172240
- NAGASAKI
- 08/09/1945 11:02:00 JST
- -769903080
- """
- reddit = praw.Reddit(
- username='username',
- password='password',
- client_id='client_id',
- client_secret='client_secret',
- user_agent='script:Time_Since_Bombings:0.1 (by /u/kimpeek)'
- )
- def seconds_since():
- """Return the total seconds since each bombing"""
- return time() + 770168640, time() + 769903080
- def converted_seconds(seconds):
- """Calculate the the years, months, days, hours, minutes, seconds and return as tuple
- :param seconds: int, float
- :return tuple: 6 ints"""
- y, r = divmod(seconds, 60 * 60 * 24 * 365)
- mo, r = divmod(r, 60 * 60 * 24 * (365 / 12))
- d, r = divmod(r, 60 * 60 * 24)
- h, r = divmod(r, 60 * 60)
- mi, r = divmod(r, 60)
- return int(y), int(mo), int(d), int(h), int(mi), int(r)
- def response():
- """Build the response comment
- :return str:"""
- response_string = """BOOM
- Time since Little Boy on Hiroshima
- [{}/{}/{}/{}/{}/{}]
- Time since Fat Man on Nagasaki
- [{}/{}/{}/{}/{}/{}]
- """.format(*converted_seconds(seconds_since()[0]), *converted_seconds(seconds_since()[1]))
- return response_string
- def main():
- """Watch for mentions and respond to them as they come. Mark them as read after responding"""
- for mention in reddit.inbox.mentions():
- if mention.new:
- mention.reply(response())
- mention.mark_read()
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement