forked from Chaosthebot/Chaos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…aosthebot#364 - Twitter Api Working Chaosthebot#550: Re Reopen Chaosthebot#443 according to Chaosthebot#364 - Twitter Api Working Description: Fix encryptation problems, regenerate twitter keys @PlasmaPower ✅ PR passed with a vote of 6 for and 0 against, a weighted total of 6.0 and a threshold of 6.0, and a current meritocracy review. Vote record: @Leigende: 1 @PlasmaPower: 1 @andrewda: 1 @eamanu: 1 @kylerschin: 1 @rudehn: 1
- Loading branch information
Showing
14 changed files
with
131 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,4 @@ server/issue_commands_ran.json | |
.migrated | ||
ansible/*.retry | ||
db.sqlite | ||
*privkey |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import logging | ||
|
||
log = logging.getLogger("twitter") | ||
|
||
|
||
def PostTwitter(message, api_twitter): | ||
if len(message) > 140: | ||
print('Post has more of 140 chars') | ||
api = api_twitter | ||
try: | ||
api.PostUpdate(message) | ||
except: | ||
log.exception("Failed to post to Twitter") | ||
return 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from . import misc | ||
import twitter | ||
|
||
|
||
__all__ = ["misc", "twitter"] | ||
|
||
|
||
class API_TWITTER(): | ||
def __init__(self, path): | ||
self.__twitter_keys = misc.GetKeys(path) | ||
self.__api = twitter.Api(consumer_key=str(self.__twitter_keys['consumer_key']), | ||
consumer_secret=str(self.__twitter_keys['consumer_secret']), | ||
access_token_key=str(self.__twitter_keys['access_token']), | ||
access_token_secret=str(self.__twitter_keys['access_secret'])) | ||
|
||
def GetApi(self): | ||
return self.__api |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from encryption import decrypt | ||
|
||
|
||
def GetKeys(twitter_keys_path): | ||
consumer_key = '' | ||
consumer_secret = '' | ||
access_token = '' | ||
access_secret = '' | ||
PATH = 'twitter_keys/' | ||
l_files = ['consumer_key', 'consumer_secret', 'access_token', 'access_secret'] | ||
|
||
for k in l_files: | ||
f = open(PATH + k, 'rb') | ||
key = f.read() | ||
if (k == 'consumer_key'): | ||
consumer_key = decrypt(key) | ||
if (k == 'consumer_secret'): | ||
consumer_secret = decrypt(key) | ||
if (k == 'access_token'): | ||
access_token = decrypt(key) | ||
if (k == 'access_secret'): | ||
access_secret = decrypt(key) | ||
f.close() | ||
""" | ||
for k in keys: | ||
try: | ||
values = k.split('\n')[0].split('=')[1].strip() | ||
if(k.split('\n')[0].split('=')[0].strip() == 'consumer_key'): | ||
consumer_key = decrypt(values) | ||
elif(k.split('\n')[0].split('=')[0].strip() == 'consumer_secret'): | ||
consumer_secret = decrypt(values) | ||
elif(k.split('\n')[0].split('=')[0].strip() == 'access_token'): | ||
access_token = decrypt(values) | ||
elif(k.split('\n')[0].split('=')[0].strip() == 'access_secret'): | ||
access_secret = decrypt(values) | ||
except IndexError: | ||
# Maybe there are a '\n' between keys | ||
continue | ||
""" | ||
return {'consumer_key': consumer_key, 'consumer_secret': consumer_secret, | ||
'access_token': access_token, 'access_secret': access_secret} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters