diff --git a/README.md b/README.md index 7220a17..81e174c 100644 --- a/README.md +++ b/README.md @@ -41,12 +41,9 @@ from cocorum import ssechat chat = ssechat.SSEChat(stream_id = STREAM_ID) #Stream ID can be base 10 or 36 chat.clear_mailbox() #Erase messages that were still visible before we connected -msg = True -while msg: - msg = chat.next_chat_message #Hangs until a new message arrives +while True: + msg = chat.get_message() #Hangs until a new message arrives print(msg.user.username, ":", msg) - -print("Chat has closed.") ``` ## Conclusion diff --git a/pyproject.toml b/pyproject.toml index 75ac571..091899d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "cocorum" -version = "0.5.3" +version = "1.0.0" keywords = ["rumble", "api", "wrapper", "livestream"] authors = [ { name="Wilbur Jaywright", email="zargulthewizard@outlook.com" }, @@ -20,7 +20,7 @@ classifiers = [ "Programming Language :: Python :: 3", "License :: OSI Approved :: GNU Affero General Public License v3", "Operating System :: OS Independent", - "Development Status :: 3 - Alpha", + "Development Status :: 4 - Beta", ] [project.urls] diff --git a/src/cocorum/ssechat.py b/src/cocorum/ssechat.py index fef01cb..9dd2c51 100644 --- a/src/cocorum/ssechat.py +++ b/src/cocorum/ssechat.py @@ -10,12 +10,9 @@ chat = ssechat.SSEChat(stream_id = STREAM_ID) #Stream ID can be base 10 or 36 chat.clear_mailbox() #Erase messages that were still visible before we connected -msg = True -while msg: - msg = chat.next_chat_message #Hangs until a new message arrives +while True: + msg = chat.get_message() #Hangs until a new message arrives print(msg.user.username, ":", msg) - -print("Chat has closed.") ``` S.D.G.""" @@ -317,6 +314,7 @@ def next_jsondata(self): self.chat_running = False #Chat has been closed return if not message.data: #Blank SSE event + print("Blank SSE event:", message) #Self recursion should work so long as we don't get dozens of blank events in a row return self.next_jsondata() @@ -381,8 +379,7 @@ def stream_id_b10(self): """The chat ID in user""" return utils.stream_id_36_to_10(self.stream_id) - @property - def next_chat_message(self): + def get_message(self): """Return the next chat message (parsing any additional data), waits for it to come in, returns None if chat closed""" if not self.__mailbox: #We don't already have messages #JSON data is coming in, but it isn't of messages type'