-
Notifications
You must be signed in to change notification settings - Fork 3
/
Twitter.py
41 lines (36 loc) · 1.27 KB
/
Twitter.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
41
#! /usr/bin/env python
"""
File: CoffeeRobot.py
Copyright (c) 2016 Austin Ayers
License: MIT
Course: Artificial Intellegence
Date: April 4, 2016
Email: [email protected]
Name: Austin Ayers
Description: Coffee Twitter Class
"""
import tweepy
class Twitter():
"""
Twitter class, simply a function to tweet a string or a boolean update on whether or not the coffee is ready.
"""
def __init__(self):
"""
Initializes Twitter, establishes authentication w/ following keys.
"""
cfg = {
"consumer_key" : "XDAEJtqe2vjSj94egQq4BaCXX",
"consumer_secret" : "XvgRdAaTU1vDpWdwquKMbgyk0HIcaCNWxXjoWtXOAU8Y4oKuaE",
"access_token" : "720366080250630145-z819wKYjvqncLeYBcg46K9rPtxNh8mI",
"access_token_secret" : "dMbGofZ1uWYJ8hqmI4BsveT0rQGvdkFxoVLee3e9Hi7lt"
}
self.api = self.get_api(cfg)
def get_api(self, cfg):
auth = tweepy.OAuthHandler(cfg['consumer_key'], cfg['consumer_secret'])
auth.set_access_token(cfg['access_token'], cfg['access_token_secret'])
return tweepy.API(auth)
def tweet(self, message):
"""
Tweets the following string message
"""
status = self.api.update_status(status=message)