-
Notifications
You must be signed in to change notification settings - Fork 2
/
TwittBot.py
executable file
·40 lines (26 loc) · 1015 Bytes
/
TwittBot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import os
from os.path import expanduser
import json
import time
import twitter
class TwitBot(object):
"""docstring for TwitBot"""
def __init__(self):
super( TwitBot, self).__init__()
credentials = json.load(open(expanduser("~/credentials.json"),'r'))
self.twtapi = twitter.Api(consumer_key=credentials["Twitter API Key"],
consumer_secret=credentials["Twitter API Secret"],
access_token_key=credentials["Twitter Access Token"],
access_token_secret=credentials["Twitter Token Secret"]
)
def postUpdate(self,media,msg):
response = self.twtapi.PostUpdates(status=msg,media=media)
return response
def tests():
bot = TwitBot()
msg = "Pronóstico Numérico de la precipitación para las próximas 24 horas a partir del modelo WRF-SisPI (Inicializado el día 2020-10-14 12:00 UTC/Hora local: 2020-10-14 08:00 AM)"
vidfile ="/home/miguel/Downloads/wrfout_2020101412_d3_rain_sfc_.mp4"
bot.post(msg,vidfile)
if __name__ == '__main__':
bot = TwitBot()
tests()