inventwithdean
commited on
Commit
·
07adff1
1
Parent(s):
3e68329
try
Browse files- yt_chat.py +8 -1
yt_chat.py
CHANGED
|
@@ -31,10 +31,17 @@ Keep your responses short, like two or three sentences, and be witty."""
|
|
| 31 |
self.messages = [self.system_message]
|
| 32 |
self.headers = {"Content-Type": "application/json", "x-api-key": api_key_unreal}
|
| 33 |
VIDEO_ID = "xBVJIJQg1FY"
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
def chat_interaction_loop(self):
|
| 37 |
"""Checks if the Host is in lobby, then pulls chat messages from the Live Stream. The Host then replies to the message."""
|
|
|
|
|
|
|
|
|
|
| 38 |
while self.chat.is_alive():
|
| 39 |
for c in self.chat.get().sync_items():
|
| 40 |
request = requests.get(
|
|
|
|
| 31 |
self.messages = [self.system_message]
|
| 32 |
self.headers = {"Content-Type": "application/json", "x-api-key": api_key_unreal}
|
| 33 |
VIDEO_ID = "xBVJIJQg1FY"
|
| 34 |
+
try:
|
| 35 |
+
self.chat = pytchat.create(video_id=VIDEO_ID)
|
| 36 |
+
except Exception as e:
|
| 37 |
+
print(f"Error creating pytchat object: {e}")
|
| 38 |
+
self.chat = None
|
| 39 |
|
| 40 |
def chat_interaction_loop(self):
|
| 41 |
"""Checks if the Host is in lobby, then pulls chat messages from the Live Stream. The Host then replies to the message."""
|
| 42 |
+
if not self.chat:
|
| 43 |
+
time.sleep(5)
|
| 44 |
+
return
|
| 45 |
while self.chat.is_alive():
|
| 46 |
for c in self.chat.get().sync_items():
|
| 47 |
request = requests.get(
|