class_docstr: Twitch chat stream client.
  
  This client gives access to a live stream of chat messages in Twitch channels using IRC protocol.
  You need to have a Twitch account and receive an OAuth token from https://twitchapps.com/tmi/.
  
  Parameters
  ----------
  nickname
      The nickname of your account.
  token
      OAuth token which has been generated.
  channels
      A list of channel names like `["asmongold", "shroud"]` you want to collect messages from.
  buffer_size
      Size of buffer in bytes used for receiving responses from Twitch with IRC (default 2 kB).
  timeout
      A timeout value in seconds for waiting response from Twitch (default 60s). It can be useful if all requested channels are offline or chat is not active enough.
  
  Returns
  -------
  Stream items are python dictionaries with keys:
  dt (datetime)
      Datetime indicating when response with this message has been received from Twitch.
  channel (str)
      A channel where message has been posted.
  username (str)
      User who posted the message.
  msg (str)
      The message itself.
  
  Examples
  --------
  The live stream is instantiated by passing your Twitch account nickname, OAuth token and list of channels. Other parameters are optional.
  
  >>> from river import stream
  
  >>> twitch_chat = stream.TwitchChatStream(
  ...     nickname="twitch_user1",
  ...     token="oauth:okrip6j6fjio8n5xpy2oum1lph4fbve",
  ...     channels=["asmongold", "shroud"]
  ... )
  
  The stream can be iterated over like this:
  
  ```py
  for item in twitch_chat:
      print(item)
  ```
  
  Here's a single stream item example:
  ```py
  {
      'dt': datetime.datetime(2022, 9, 14, 10, 33, 37, 989560),
      'channel': 'asmongold',
      'username': 'moojiejaa',
      'msg': 'damn this chat mod are wild'
  }
  ```
  
  References
  ----------
  [^1]: [Twitch IRC doc](https://dev.twitch.tv/docs/irc)
class_docstr_tok: ["Twitch","chat","stream","client",".","This","client","gives","access","to","a","live","stream","of","chat","messages","in","Twitch","channels","using","IRC","protocol",".","You","need","to","have","a","Twitch","account","and","receive","an","OAuth","token","from","https",":","\/\/twitchapps.com\/tmi\/",".","Parameters","--","--","--","--","--","nickname","The","nickname","of","your","account",".","token","OAuth","token","which","has","been","generated",".","channels","A","list","of","channel","names","like","`","[","``","asmongold","''",",","``","shroud","''","]","`","you","want","to","collect","messages","from",".","buffer_size","Size","of","buffer","in","bytes","used","for","receiving","responses","from","Twitch","with","IRC","(","default","2","kB",")",".","timeout","A","timeout","value","in","seconds","for","waiting","response","from","Twitch","(","default","60s",")",".","It","can","be","useful","if","all","requested","channels","are","offline","or","chat","is","not","active","enough",".","Returns","--","--","--","-","Stream","items","are","python","dictionaries","with","keys",":","dt","(","datetime",")","Datetime","indicating","when","response","with","this","message","has","been","received","from","Twitch",".","channel","(","str",")","A","channel","where","message","has","been","posted",".","username","(","str",")","User","who","posted","the","message",".","msg","(","str",")","The","message","itself",".","Examples","--","--","--","--","The","live","stream","is","instantiated","by","passing","your","Twitch","account","nickname",",","OAuth","token","and","list","of","channels",".","Other","parameters","are","optional",".",">",">",">","from","river","import","stream",">",">",">","twitch_chat","=","stream.TwitchChatStream","(","...","nickname=","''","twitch_user1","''",",","...","token=","''","oauth",":","okrip6j6fjio8n5xpy2oum1lph4fbve","''",",","...","channels=","[","``","asmongold","''",",","``","shroud","''","]","...",")","The","stream","can","be","iterated","over","like","this",":","``","`","py","for","item","in","twitch_chat",":","print","(","item",")","``","`","Here","'s","a","single","stream","item","example",":","``","`","py","{","'dt","'",":","datetime.datetime","(","2022",",","9",",","14",",","10",",","33",",","37",",","989560",")",",","'channel","'",":","'asmongold","'",",","'username","'",":","'moojiejaa","'",",","'msg","'",":","'damn","this","chat","mod","are","wild'","}","``","`","References","--","--","--","--","--","[","^1","]",":","[","Twitch","IRC","doc","]","(","https",":","\/\/dev.twitch.tv\/docs\/irc",")"]
code: def _extract_chat_messages(
      self, resp: str, dt: dt.datetime
  ) -> Iterator[ChatMessageItem]:
      for m in self.chat_item_pattern.finditer(resp):
          if not m or not m.groups():
              continue
          user, chan, msg = m.groups()
          yield ChatMessageItem(
              dt=dt, channel=chan, username=user, msg=msg.strip()
          )
  
file_path: river/river/stream/twitch_chat_stream.py
imports: from __future__ import annotations
  import dataclasses
  import datetime
  import enum
  import re
  import socket
  from collections.abc import Iterator
label_desc: Use image node_id 5 for calling the TwitchChatStream obj's underlying member method code with example usage: obj._extract_chat_messages(resp, dt) without return types