Connecting to twitch.tv Connected to twitchTraceback (most recent call last): Sending our details to twitch... File "C:\Users\crech\Downloads\Twitch Plays\main\main.py", line 12, in <module> t.twitch_connect(username, key); File "C:\Users\crech\Downloads\Twitch Plays\main\twitch.py", line 30, in twitch_connect s.send('USER %s\r\n' % user); TypeError: a bytes-like object is required, not 'str' [Finished in 2.8s]
任何人都知道如何修复P.S.这是主要代码
#Define the imports
import twitch
import keypresser
import keyholder
t = twitch.Twitch();
k = keypresser.Keypresser();
#Enter your twitch username and oauth-key below, and the app connects to twitch with the details.
#Your oauth-key can be generated at http://twitchapps.com/tmi/
username = "Candme";
key = "oauth:[REDACTED]";
t.twitch_connect(username, key);
#The main loop
while True:
#Check for new mesasages
new_messages = t.twitch_recieve_messages();
if not new_messages:
#No new messages...
continue
else:
for message in new_messages:
#Wuhu we got a message. Let's extract some details from it
msg = message['message'].lower()
username = message['username'].lower()
print(username + ": " + msg.encode('utf-8'));
#This is where you change the keys that shall be pressed and listened to.
#The code below will simulate the key q if "q" is typed into twitch by someone
#.. the same thing with "w"
#Change this to make Twitch fit to your game!
if msg == "w": keyholder.holdForSeconds(msg, 0.1);
if msg == "s": keyholder.holdForSeconds(msg, 0.1);
if msg == "a": keyholder.holdForSeconds(msg, 0.1);
if msg == "d": keyholder.holdForSeconds(msg, 0.1);
if msg == "e": keyholder.holdForSeconds(msg, 0.1);
if msg == "q": keyholder.holdForSeconds(msg, 0.1);
if msg == "t": keyholder.holdForSeconds(msg, 0.1);
如果有人可以帮助我,我将非常感激。谢谢!
这是填充文字,因此我可以发布: FILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXTFILLERTEXT