osa1 / tiny

A terminal IRC client
MIT License
1.01k stars 61 forks source link

ability to mention users who posted a message before and aren't in the user list #253

Closed LordMZTE closed 4 years ago

LordMZTE commented 4 years ago

some servers, such as irc.twitch.tv don't show users in the user list (at least they don't show up when using /names). And tab completion doesn't suggest them. This makes it annoying to mention someone because tab completion cannot be used. This could simply be fixed by allowing to mention users who have sent a message before. however, this may also be a problem with the /names command because i have seen a user list in other IRC clients such as HexChat before on the same servers

osa1 commented 4 years ago

Thanks for reporting. I'll try irc.twitch.tv and see what's different there that breaks /names and tab completion in tiny. Once we know the problem we can think about a solution.

osa1 commented 4 years ago

Yeah, this seems to be an issue with Twitch's IRC server. In IRC Guide they say they're following RFC 1459, which says this in section 4.2.1:

If a JOIN is successful, the user is then sent the channel's topic (using RPL_TOPIC) and the list of users who are on the channel (using RPL_NAMREPLY), which must include the user joining.

However I just joined a channel with hundreds of viewers and this is the RPL_NAMREPLY I got:

[2020-09-16 16:24:34] DEBUG [libtiny_client/src/lib.rs:452] parsed msg: Msg { pfx: Some(User { nick: "osa1_.tmi.twitch.tv", user: "" }), cmd: Reply { num: 353, params: ["osa1_", "=", "#diegosaurs", "osa1_"] } }

In addition to being completely bogus format-wise, it doesn't have any of the users other than me.

however, this may also be a problem with the /names command because i have seen a user list in other IRC clients such as HexChat before on the same servers

Are you sure? Here's the screenshot of the same channel in hexchat:

Screenshot_2020-09-16_16-32-49

User list is empty.

The server also doesn't support NAMES command:

16:29 tmi.twitch.tv: osa1_ NAMES Unknown command

So I think the only improvement here is as you suggest, we add the users who post a message to the channel to the channel's user list.

LordMZTE commented 4 years ago

image HexChat detects all users in the channel about 1 minute after joining. maybe if you wait a bit HexChat will detect them for you too?

LordMZTE commented 4 years ago

so it appears i installed a twitch HexChat plugin a while ago which may be handling this. however i can't find it anymore

osa1 commented 4 years ago

Interesting... I just tried locally and it seems like it can somehow get the user list in the channel you show (brookzerker), but not in the channel I tried above (diegosaurs). I'll investigate more, but in any case I think this isn't something we can solve perfectly. For example in the channel I showed HexChat is also having problems. Ideally Twitch would fix their servers.

so it appears i installed a twitch HexChat plugin a while ago which may be handling this. however i can't find it anymore

I don't have any plugins installed but HexChat can still show users in brookzerker (but not in diegosaurs).

LordMZTE commented 4 years ago

that's interesting. however i don't have high hopes on twitch fixing this, so the best solution for tiny will probably be somehow adding users who have chatted before to a user list or using some special behaviour for twitch. both of those suggestions wouldn't be ideal of course.

osa1 commented 4 years ago

I agree. I'll investigate this more and figure out how HexChat gets the user list in brookzerker. We can then implement the same + implement your suggestion of adding a user to the channel's user list when they post a message.

osa1 commented 4 years ago

I recorded IRC traffic in wireshark. It turns out HexChat uses "membership" capability which makes the server to send user updates in some cases (not all! For example the crowded channel I tried above still doesn't work).

HexChat sends CAP LS 302 as the first message when it connects (before PASS and anything else). I have no idea what 302 is there, I thought to get list of capabilities we simply send CAP LS... Anyways, then Twitch responds

-- From server to HexChat
:tmi.twitch.tv CAP * LS :twitch.tv/tags twitch.tv/commands twitch.tv/membership

HexChat then requests membership capability:

-- From HexChat to server
CAP REQ :twitch.tv/membership
CAP END

Finally the server acks:

:tmi.twitch.tv CAP * ACK :twitch.tv/membership

If you want you can have the same behavior today by sending these after connecting to the server (but before joining to the channels! I just tried and if you do this after joining it doesn't work)

CAP REQ :twitch.tv/membership
CAP END

Now when we join some of the channels we get JOIN and RPL_NAMREPLY also works, but only on small channels. For example, this is the messages I get from the server for the two channels we tested above:

:osa1_.tmi.twitch.tv 353 osa1_ = #brookzerker :anotherttvviewer aten rowario lurxx museun nightbot ss2053 teischente brookzerker brookzerker_bot feelsduckman
...
:osa1_.tmi.twitch.tv 353 osa1_ = #diegosaurs :osa1_

We get a RPL_NAMREPLY for brookzerker because it's a small channel. For the other channel we don't get it.

LordMZTE commented 4 years ago

i just tried this and it also works for me. maybe an array of commands to be sent to the server upon connection could be added to the config.yml file. this would allow putting these commands in there, and this issue would be resolved right?

osa1 commented 4 years ago

maybe an array of commands to be sent to the server upon connection could be added to the config.yml file. this would allow putting these commands in there, and this issue would be resolved right?

We actually had this feature at some point but removed it in 0.4.0, see the CHANGELOG entry for details. I can elaborate on why it's not a good idea if you're interested in implementing an IRC client.

LordMZTE commented 4 years ago

Oh alright, it is just a little annoying to type the commands every time I want to use tiny with the twitch IRC servers. So what if tiny does it like HexChat and automatically sends the CAP REQ commands as HexChat does? That also brings up the question of what makes HexChat decide to use these CAPs?

osa1 commented 4 years ago

So what if tiny does it like HexChat and automatically sends the CAP REQ commands as HexChat does?

This is a possibility, yes. But even if we do this it won't solve the problem 100% as Twitch won't send users in crowded channels, so my priority currently is to implement the original suggestion of adding a user to the channel when they send a message.

That also brings up the question of what makes HexChat decide to use these CAPs?

No idea, I'd guess that it always uses membership CAP when it's available.

LordMZTE commented 4 years ago

Of course, it won't be a perfect solution but it would certainly be helpful if these CAPs would automatically be used. But I agree, my original suggestion would probably be more useful, as it doesn't really make sense to mention a user who hasn't sent a message anyways.

osa1 commented 4 years ago

I implemented the original suggestion and as far as I can tell it's working nicely. Please feel free to reopen if you encounter any problems.

Let's leave the CAP stuff to another issue. It's a bit more involved and I'm not sure it's worth just to support a server that doesn't implement the RFCs properly.

flber commented 3 years ago

Hello, sorry for adding to a closed issue, but what is the config required for irc.twitch.tv? I know it requires an OAuth token, but I'm unsure about the syntax for the tiny config file.

osa1 commented 3 years ago

Hi @flber. Here's what I'm using to connect to twitch:

    - addr: irc.chat.twitch.tv
      tls: true
      port: 6697
      pass: 'oauth:<my oauth token>'
      realname: <my username>
      nicks: ['<my username>']
      join: []
flber commented 3 years ago

Thanks @osa1! That works!