class_docstr: Twitter API v2 live stream client.
  
      This client gives access to a live stream of Tweets. That is, Tweets that have just been
      published. This is different to `stream.TwitterRecentStream`, which also covers Tweets that
      have been published over recent days, and not necessarily in real-time.
  
      A list of filtering rules has to be provided. For instance, this allows focusing on a subset of
      topics and/or users.
  
      !!! note
  
          Using this requires having the [`requests`](https://requests.readthedocs.io/en/latest/)
          package installed.
  
      Parameters
      ----------
      rules
          See the documentation[^2] for a comprehensive overview of filtering rules.
      bearer_token
          A bearer token that is available in each account's developer portal.
  
      Examples
      --------
  
      The live stream is instantiated by passing a list of filtering rules, as well as a bearer
      token. For instance, we can listen to all the breaking news Tweets from the BBC and CNN.
  
      >>> from river import stream
  
      >>> tweets = stream.TwitterLiveStream(
      ...     rules=["from:BBCBreaking", "from:cnnbrk"],
      ...     bearer_token="<insert_bearer_token>"
      ... )
  
      The stream can then be iterated over, possibly in an infinite loop. This will listen to the
      live feed of Tweets and produce a Tweet right after it's been published.
  
      ```py
      import logging
  
      while True:
          try:
              for tweet in tweets:
                  print(tweet)
          except requests.exceptions.RequestException as e:
              logging.warning(str(e))
              time.sleep(10)
      ```
  
      Here's a Tweet example:
  
      ```py
      {
          'data': {
              'author_id': '428333',
              'created_at': '2022-08-26T12:59:48.000Z',
              'id': '1563149212774445058',
              'text': "Ukraine's Zaporizhzhia nuclear power plant, which is currently held by
  Russian forces, has been reconnected to Ukraine's electricity grid, according to the
  country's nuclear operator https://t.co/xfylkBs4JR"
          },
          'includes': {
              'users': [
                  {
                      'created_at': '2007-01-02T01:48:14.000Z',
                      'id': '428333',
                      'name': 'CNN Breaking News',
                      'username': 'cnnbrk'
                  }
              ]
          },
          'matching_rules': [{'id': '1563148866333151233', 'tag': 'from:cnnbrk'}]
      }
      ```
  
      References
      ----------
      [^1]: [Filtered stream introduction](https://developer.twitter.com/en/docs/twitter-api/tweets/filtered-stream/introduction)
      [^2]: [Building rules for filtered stream](https://developer.twitter.com/en/docs/twitter-api/tweets/filtered-stream/integrate/build-a-rule)
      [^3]: [Stream Tweets in real-time](https://developer.twitter.com/en/docs/tutorials/stream-tweets-in-real-time)
code: def _delete_rules(self, rules):
      if rule_ids := [rule["id"] for rule in rules.get("data", [])]:
          payload = {"delete": {"ids": rule_ids}}
          return self._request(
              "POST", "tweets/search/stream/rules", json=payload
          ).json()
  
file_path: river/river/stream/tweet_stream.py
imports: from __future__ import annotations
  import json
  from urllib.parse import urljoin
label_desc: Use image node_id 4 for calling the TwitterLiveStream obj's underlying member method code with example usage: obj._delete_rules(rules) and returns: self