Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

it's asking or bytes-like object wherever there are strings. #9

Open
EightRice opened this issue Dec 31, 2020 · 1 comment
Open

it's asking or bytes-like object wherever there are strings. #9

EightRice opened this issue Dec 31, 2020 · 1 comment

Comments

@EightRice
Copy link

TypeError Traceback (most recent call last)
in
----> 1 main()

in main()
171 ircmsg = ircsock.recv(2048)
172 # remove any line breaks
--> 173 ircmsg = ircmsg.strip('\n\r')
174 # print received message to stdout (mostly for debugging).
175 print(ircmsg)

TypeError: a bytes-like object is required, not 'str'

@wrgore
Copy link

wrgore commented Feb 18, 2021

Hello @EightRice -

This is likely because the code repository here uses Python2, however you'll need to utilize Python3 for this. If you take a look at the related tutorial below, there is a section titled "Channel Join" which should sum up the issue for you and provide a fix.

https://acloudguru.com/blog/engineering/creating-an-irc-bot-with-python3

The fix itself looks something like what is below. Notice the bytes data type as well as the decode message.

ircsock.send(bytes("JOIN "+ chan +"n", "UTF-8")) ircmsg = "" while ircmsg.find("End of /NAMES list.") == -1: ircmsg = ircsock.recv(2048).decode("UTF-8") ircmsg = ircmsg.strip('nr') print(ircmsg)

Hope this helps!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants