Skip to content

Commit

Permalink
Improve clarity of AsyncStream.on_data
Browse files Browse the repository at this point in the history
  • Loading branch information
Harmon758 committed Jan 26, 2021
1 parent a9f2897 commit 349c807
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions tweepy/asynchronous/streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,14 @@ async def on_data(self, raw_data):
return await self.on_disconnect_message(data["disconnect"])
if "limit" in data:
return await self.on_limit(data["limit"]["track"])
for message_type in ("scrub_geo","status_withheld", "user_withheld",
"warning"):
if message_type in data:
method = getattr(self, "on_" + message_type)
return await method(data[message_type])
if "scrub_geo" in data:
return await self.on_scrub_geo(data["scrub_geo"])
if "status_withheld" in data:
return await self.on_status_withheld(data["status_withheld"])
if "user_withheld" in data:
return await self.on_user_withheld(data["user_withheld"])
if "warning" in data:
return await self.on_warning(data["warning"])

log.warning("Received unknown message type: %s", raw_data)

Expand Down

0 comments on commit 349c807

Please sign in to comment.