Cleaner Python Code

This commit is contained in:
jacktjong
2022-11-04 22:21:19 +01:00
parent d3b62c1c61
commit f840a456af

View File

@@ -41,51 +41,25 @@ def words(message):
@event('tweet')
def generate_tweet(ctx, e):
tweet = dict(e.data)
pops = [
"display_text_range",
"in_reply_to_status_id",
"in_reply_to_status_id_str",
"in_reply_to_user_id",
"in_reply_to_user_id_str",
"in_reply_to_screen_name",
"geo",
"coordinates",
"place",
"contributors",
"is_quote_status"
]
try:
try:
tweet.pop("display_text_range")
except KeyError:
pass
try:
tweet.pop("in_reply_to_status_id")
except KeyError:
pass
try:
tweet.pop("in_reply_to_status_id_str")
except KeyError:
pass
try:
tweet.pop("in_reply_to_user_id")
except KeyError:
pass
try:
tweet.pop("in_reply_to_user_id_str")
except KeyError:
pass
try:
tweet.pop("in_reply_to_screen_name")
except KeyError:
pass
try:
tweet.pop("geo")
except KeyError:
pass
try:
tweet.pop("coordinates")
except KeyError:
pass
try:
tweet.pop("place")
except KeyError:
pass
try:
tweet.pop("contributors")
except KeyError:
pass
try:
tweet.pop("is_quote_status")
except KeyError:
pass
for x in pops:
try:
tweet.pop(x)
except KeyError:
pass
except:
pass
# base sample on previous one