Skip to content

Commit 92581ce

Browse files
preededIAmTomahawkx
andauthored
Add first to Message class (#340)
* Add `first` to Message class Boolean representing whether it's a first message or not. Could be None. * Update changelog.rst * Update twitchio/message.py Co-authored-by: Tom <[email protected]> * Update twitchio/message.py Co-authored-by: Tom <[email protected]> * Update twitchio/message.py Co-authored-by: Tom <[email protected]> * Update twitchio/message.py Co-authored-by: Tom <[email protected]> * Update message.py * Update message.py Co-authored-by: Tom <[email protected]>
1 parent 8b17891 commit 92581ce

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

docs/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Master
55
======
66
- TwitchIO
77
- Additions
8+
- Added :attr:`~twitchio.Message.first` to :class:`~twitchio.Message`
89
- Added :func:`~twitchio.PartialUser.fetch_channel_emotes` to :class:`~twitchio.PartialUser`
910
- Added :func:`~twitchio.Client.fetch_global_emotes` to :class:`~twitchio.Client`
1011
- Added :func:`~twitchio.Client.event_channel_join_failure` event:

twitchio/message.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ class Message:
3939
The content of this message.
4040
echo: :class:`bool`
4141
Boolean representing if this is a self-message or not.
42+
first: :class:`bool`
43+
Boolean representing whether it's a first message or not.
4244
4345
"""
4446

@@ -47,6 +49,7 @@ class Message:
4749
"content",
4850
"_author",
4951
"echo",
52+
"first",
5053
"_timestamp",
5154
"_channel",
5255
"_tags",
@@ -61,6 +64,12 @@ def __init__(self, **kwargs):
6164
self._tags = kwargs.get("tags")
6265
self.echo = kwargs.get("echo", False)
6366

67+
self.first = False
68+
if self._tags is not None:
69+
first = self._tags.get("first-msg")
70+
if first == "1":
71+
self.first = True
72+
6473
try:
6574
self._id = self._tags["id"]
6675
self._timestamp = self._tags["tmi-sent-ts"]

0 commit comments

Comments
 (0)