List out of index when pinged bi twitch irc

hi i resolved my ping issue but when i recive the ping message all go wrong…
29
this is the error from terminal.
34
this is the part of my main code, pingpong is an easy function with just the send pong instruction.
45
this is the last image, a little part how i get the message how can i fix this problem? :mask:

By accessing the the array using the index 2, you are accessing the third element in the array since arrays start at 0. When you split your message by :, you’re only splitting the string into 2 parts, so you’d want to access second element at index 1.

That would be the quick fix. Although I’d recommend making your parsing a little more flexible to handle various kinds of IRC messages.

ok so i have to read the full irc message not splitted?
if yes now i’m thinking how change it in main script and don’t delete the split
use it just for ping, i don’t know how to write the right code

I wouldn’t say you have to since I’m not sure to what extent that function will be used. If you’re certain that you will only ever be receiving a certain type of message of a certain format, splitting would work fine. I would just double check to make sure the format won’t ever change.

If you do want to make it more flexible, I’d recommend reading up on the RFC 1459 Spec concerning message formatting.

Ok this Is too hard for me :joy:, in practice how can i fix that? I have Just ti change the split Number?

To directly fix the error you’re having, change

message = separate[2]

to

message = separate[1]

Keep in mind this will only work as intended as long as there is only one : in the entire IRC message.

with this i fixed the ping aswell but i can’t recognise command now.
i try with another function like get message,but the problem is the same
29
getMessageuser is the same getMessage just with separate[2]
i think i have to change the method to get line

Fixed! Thank you very much :relieved:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.