Skip to content

Commit

Permalink
use timestamps on search query
Browse files Browse the repository at this point in the history
  • Loading branch information
robertoszek committed Nov 28, 2022
1 parent 8cf833b commit 9957708
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions pleroma_bot/_twitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,19 @@ def _get_tweets(
response.raise_for_status()
tweets = response.json()
else: # pragma: todo
now = datetime.strftime(
datetime.now(), "%Y-%m-%dT%H:%M:%SZ"
now_ts = int(datetime.utcnow().timestamp())
fmt_date = ("%Y-%m-%dT%H:%M:%S.%fZ", "%Y-%m-%dT%H:%M:%SZ")
for fmt in fmt_date:
try:
start_time_ts = int(datetime.strptime(
start_time, fmt
).timestamp())
except ValueError:
pass
query = (
f"(from:{t_user}) "
f"since_time:{start_time_ts} until_time:{now_ts}"
)
query = f"(from:{t_user}) since:{start_time} until:{now}"
param = {
"include_profile_interstitial_type": "1",
"include_rts": {str(self.include_rts).lower()},
Expand Down

0 comments on commit 9957708

Please sign in to comment.