Skip to content

Commit abd4485

Browse files
committed
Fix parsing whispers
Fix parsing whispers
1 parent b3b99c2 commit abd4485

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

docs/changelog.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
Master
44
======
5+
- TwitchIO
6+
- Bug fixes
7+
- Fix whispers that were not able to be parsed
8+
59
- ext.commands
610
- Bug fixes
711
- Make sure double-quotes are properly tokenized for bot commands

twitchio/parse.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
)
4545
ACTIONS2 = ("USERSTATE", "ROOMSTATE", "PRIVMSG", "USERNOTICE", "WHISPER")
4646
USER_SUB = re.compile(r":(?P<user>.*)!")
47-
MESSAGE_RE = re.compile(r":(?P<useraddr>\S+) (?P<action>\S+) #(?P<channel>\S+)( :(?P<message>.*))?$")
47+
MESSAGE_RE = re.compile(r":(?P<useraddr>\S+) (?P<action>\S+) (?P<channel>\S+)( :(?P<message>.*))?$")
4848
FAST_RETURN = {"RECONNECT": {"code": 0, "action": "RECONNECT"}, "PING": {"action": "PING"}}
4949

5050
logger = logging.getLogger("twitchio.parser")
@@ -77,9 +77,12 @@ def parser(data: str, nick: str):
7777
return None # raise exception?
7878
user = result.group("useraddr").split("!")[0]
7979
action = result.group("action")
80-
channel = result.group("channel")
80+
channel = result.group("channel").lstrip("#")
8181
message = result.group("message")
8282

83+
if action == "WHISPER":
84+
channel = None
85+
8386
if action in ACTIONS2:
8487
prebadge = groups[0].split(";")
8588
badges = {}

0 commit comments

Comments
 (0)