[twitter] Move twitter config options to subpoint twitter
This commit is contained in:
parent
8af6205146
commit
66684c2fea
|
@ -17,13 +17,12 @@ class TwitterBot(Censor):
|
|||
def __init__(self, twitter_model):
|
||||
super().__init__(twitter_model.hood)
|
||||
self.twitter_model = twitter_model
|
||||
self.tokens = {
|
||||
'consumer_key': config['twitter_consumer_key'],
|
||||
'consumer_secret': config['twitter_consumer_secret'],
|
||||
'access_token': twitter_model.access_token,
|
||||
'access_token_secret': twitter_model.access_token_secret,
|
||||
}
|
||||
self.client = PeonyClient(**self.tokens)
|
||||
self.client = PeonyClient(
|
||||
consumer_key=config['twitter']['consumer_key'],
|
||||
consumer_secret=config['twitter']['consumer_secret'],
|
||||
access_token=twitter_model.access_token,
|
||||
access_token_secret=twitter_model.access_token_secret,
|
||||
)
|
||||
self.polling_interval_sec = 60
|
||||
self.mentions_since_id = self.twitter_model.mentions_since_id
|
||||
self.dms_since_id = self.twitter_model.dms_since_id
|
||||
|
|
|
@ -47,8 +47,8 @@ async def twitter_delete(twitter=Depends(get_twitter)):
|
|||
async def twitter_create(response: Response, hood=Depends(get_hood)):
|
||||
try:
|
||||
request_token = await get_oauth_token(
|
||||
config['twitter_consumer_key'],
|
||||
config['twitter_consumer_secret'],
|
||||
config['twitter']['consumer_key'],
|
||||
config['twitter']['consumer_secret'],
|
||||
callback_uri='http://127.0.0.1:8000/api/twitter/callback',
|
||||
)
|
||||
if request_token['oauth_callback_confirmed'] != 'true':
|
||||
|
@ -69,8 +69,8 @@ async def twitter_read_callback(oauth_token: str, oauth_verifier: str):
|
|||
try:
|
||||
twitter = await Twitter.objects.filter(access_token=oauth_token).get()
|
||||
access_token = await get_access_token(
|
||||
config['twitter_consumer_key'],
|
||||
config['twitter_consumer_secret'],
|
||||
config['twitter']['consumer_key'],
|
||||
config['twitter']['consumer_secret'],
|
||||
twitter.access_token,
|
||||
twitter.access_token_secret,
|
||||
oauth_verifier,
|
||||
|
|
Loading…
Reference in a new issue