317070 / python-twitch-stream

Python-twitch-stream is a simple lightweight library, which you can use to send your python video to twitch and react with the chat in real time.
MIT License
59 stars 22 forks source link

If username is not all lowercase, it is able to send chat messages but cannot receive them. #8

Closed NHDaly closed 8 years ago

NHDaly commented 8 years ago

For TwitchChatStream, if username has capital letters in it, the chatstream.twitch_receive_messages() doesn't ever return messages.

It is able to send messages, but not receive them.

Here is a simple example:

with TwitchChatStream(
      username=twitch_username,
      oauth=twitch_oauth,
      verbose=False) as chatstream:

  chatstream.join_channel('<my_lowercase_username>')
  print('connected to: ', chatstream.current_channel)

  chatstream.send_chat_message('Hello!')

  # The main loop to poll the chat.
  while True:
      received = chatstream.twitch_receive_messages()

      # process all the messages
      if received:
          print("received")

If twitch_username has capitals in it, the send succeeds but never receives messages, whereas if it's all lowercase, everything works. This even happens if i manually force join_channel to the lowercase named channel.

RoboCD commented 8 years ago

Thank you for noticing this, I thought I was going crazy when this didn't work. One simple fix for this if it doesn't work, as in the color.py example, is to change line 42 to. username = args.username.lower() This way it no longer matters whether it's capital or not. Seems strange that it has to be lowercase.

NHDaly commented 8 years ago

Haha yeah I was too! Spent a while pretty upset. :)

Oooh, yes, great idea, @RoboCD. That's a good fix. :)

NHDaly commented 8 years ago

@RoboCD Which line 42 are you talking about?

NHDaly commented 8 years ago

I've sent a PR for updating the example in the README

317070 commented 8 years ago

Merged!