-
Notifications
You must be signed in to change notification settings - Fork 0
/
twitter.py
73 lines (67 loc) · 2.11 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# -*- coding: utf-8 -*-
import os
from gui import ask
import collections
import webbrowser
import config
import twython
import sound
import audio_player
global snd
snd = sound.sound()
player = audio_player.URLStream()
timelines=collections.OrderedDict()
apikey="W48NhXLuPeP66yvcXXurhQPY6"
apisecret="jST5JRY7KK8tjyxEm6QcpIWrHrMWeHXqyNPsK5w0ohYd9L7kHu"
#apikey="gRcSncxR8Y2buqPYFd4U8qJKU"
#apisecret="4gq2245Nust9dLCOTzBaJKvJQgrzwiqBYfKVDm7cpw1kb7WfUQ"
def auth():
global soundpack
try:
soundpack = config.appconfig['general']['soundpack']
except:
soundpack = "default"
global twitter
twitter = twython.Twython(apikey, apisecret)
global auth
if config.appconfig['general']['key']=="" or config.appconfig['general']['secret']=="":
auth = twitter.get_authentication_tokens()
OAUTH_TOKEN = auth['oauth_token']
OAUTH_TOKEN_SECRET = auth['oauth_token_secret']
webbrowser.open(auth['auth_url'])
verifier = ask.ask(message='Enter pin:')
twitter = twython.Twython(apikey, apisecret, OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
tokens=twitter.get_authorized_tokens(verifier)
config.appconfig['general']['key']=tokens['oauth_token']
config.appconfig['general']['secret']=tokens['oauth_token_secret']
config.appconfig.write()
twitter = twython.Twython(apikey, apisecret,config.appconfig['general']['key'],config.appconfig['general']['secret'])
account=twitter.get_account_settings()
global screenname
screenname=account['screen_name']
def Tweet(text,id=""):
if id=="":
twitter.update_status(status=text)
else:
twitter.update_status(status=text,in_reply_to_status_id=id)
snd.play("sendtweet")
return True
def DM(user,text):
twitter.send_direct_message(user=user,text=text)
def Retweet(id):
twitter.retweet(id=id)
snd.play("sendtweet")
def Like(id):
twitter.create_favorite(id=id)
def Unlike(id):
twitter.destroy_favorite(id=id)
def Quote(text,s):
url="https://twitter.com/"+s['user']['screen_name']+"/status/"+s['id_str']+"/"
Tweet(text+" "+url)
snd.play("sendtweet")
def Follow(user):
twitter.create_friendship(screen_name=user)
def Unfollow(user):
twitter.destroy_friendship(screen_name=user)
def exit():
os._exit(0)