Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Added optional custom message and optional keyword filtering" #21

Merged
merged 1 commit into from
Sep 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Revert "Added optional custom message and optional keyword filtering (#…
…20)"

This reverts commit e28e9b8.
  • Loading branch information
NNTin authored Sep 14, 2018
commit 285a83c1db3e21006f6ef9c5d15cf6ddc2da6ddc
8 changes: 0 additions & 8 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,6 @@
"INCLUDE_USER_REPLY": {
"description": "Include replies FROM your tracked twitter user to other twitter users",
"value": "True"
},
"CUSTOM_MESSAGE": {
"description": "OPTIONAL: Custom message. Useful for pinging @everyone, a role or individual discord members (syntax: <@ROLE_OR_MEMBER_ID>)",
"required": false
},
"KEYWORDS": {
"description": "OPTIONAL: Will only post tweets with certain keywords. Comma separate keyword sets. Separate a keyword set with +. Example: world+hello, dota--> hello guys! ✘, what in the world ✘, my first tweet: hello world ✔, let's play some dota! ✔",
"required": false
}
}
}
12 changes: 5 additions & 7 deletions config.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from dataIO import fileIO
import os

false_strings = ["false", "False", "f", "F", "0", "", "n", "N", "no", "No", "NO", "FALSE"]
# todo: add mongoDB support

false_strings = ["false", "False", "f", "F", "0", ""]

if fileIO("data.json", "check"):
data_json = fileIO("data.json", "load")
else:
keyword_sets = [keyword_set.split("+") for keyword_set in os.environ.get("KEYWORDS", []).replace(" ", "").split(",")]

data_json = {
"Twitter": {
"consumer_key": os.environ["CONSUMER_KEY"],
Expand All @@ -20,10 +20,8 @@
"IncludeReplyToUser": False if os.environ["INCLUDE_REPLY_TO_USER"] in false_strings else True,
"IncludeRetweet": False if os.environ["INCLUDE_RETWEET"] in false_strings else True,
"IncludeUserReply": False if os.environ["INCLUDE_USER_REPLY"] in false_strings else True,
"webhook_urls": os.environ["WEBHOOK_URL"].replace(" ", "").split(","),
"twitter_ids": os.environ["TWITTER_ID"].replace(" ", "").split(","),
"custom_message": os.environ.get("CUSTOM_MESSAGE", None),
"keyword_sets": keyword_sets
"webhook_urls": os.environ.get("WEBHOOK_URL", []).replace(" ", "").split(","),
"twitter_ids": os.environ.get("TWITTER_ID", []).replace(" ", "").split(",")
}
],
"twitter_ids": []
Expand Down
28 changes: 0 additions & 28 deletions data_example.json

This file was deleted.

14 changes: 1 addition & 13 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,6 @@ def _on_status(self, status):
else:
text = data['text']

if "keyword_sets" in data_discord:
for keyword_set in data_discord["keyword_sets"]:
keyword_present = [keyword.lower() in text.lower() for keyword in keyword_set]
keyword_set_present = all(keyword_present)
if keyword_set_present:
break
if not keyword_set_present:
break

for url in data['entities']['urls']:
if url['expanded_url'] is None:
continue
Expand Down Expand Up @@ -168,10 +159,7 @@ def _on_status(self, status):
if match:
webhook = Webhook.partial(match.group("id"), match.group("token"), adapter=RequestsWebhookAdapter())
try:
if "custom_message" in data_discord and data_discord["custom_message"] is not None:
webhook.send(embed=embed, content=data_discord["custom_message"])
else:
webhook.send(embed=embed)
webhook.send(embed=embed)
except discord.errors.HTTPException as error:
print('---------Error---------')
print('discord.errors.HTTPException')
Expand Down