-
Notifications
You must be signed in to change notification settings - Fork 5
Autojoin IRC channels on connect #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Some clients do not remember and autojoin previously connected channels. Sending JOINs for these channels on connect helps to rediscover these channels.
|
Thanks! I think this initiates the join too fast? It seems to consider the rooms as "LeftChan", but some should be joined as far as I understand the join is processed as soon as the matrix handle is created but we need to wait for the First sync in src/matrix/mod.rs, possibly it makes more sense to join in or after sync_room on the matrix side |
|
Thanks for testing and feedback! Yes, your observations sounds correct and matches with some of the "erratic" behaviour I have observed when initially testing. Moving the call seems like a good idea; I'll take a shot at implementing and testing it. It might, however, be end of week until I can get to it. |
|
Done, it seems to work a lot more reliable now, including better (heuristic) detection of queries vs channel names (I've also fixed a small bug in the prefix assignment, obviously prefix |
|
Great! I've tested and yes I get names working now, this is much better. Another thing I don't get is, regular servers (e.g. libera.chat or whatever) don't do this. Perhaps if we didn't ignore joins then the "normal" weechat mechanism would work? |
Hmm, so technically speaking, when sending a JOIN, weechat silently upgrades the queries to a full channel. The rest of our code works fine because the room mapping does not really care what RoomTargetType we have. But it nevertheless all feels hacky, and I don't really like hacks... On the other hand, the IRC-protocol does not offer a builtin way to silently open/push a query, there is only privmsg.
Well, normally, queries are never opened on connect, only on incoming messages or manually via the Before trying out matrirc, I was using https://github.com/poljar/weechat-matrix which has the same UX (so all queries are opened; but being a weechat plugin weechat-matrix can "silently" open them), so this workaround seemed as a natural substitute to me. For completeness, here's my weechat filter: |
|
Sorry for the slow reply, I'm quite busy IRL (moving next week!) and will be without internet for a couple of weeks probably so taking a few minutes to reply quickly now.
I think this is acceptable as a first step (perhaps until , but I agree we probably want to aim for better/cleaner here -- let's discuss a bit more alternatives.
So that's a very good question, as the name available for query isn't the same as the nicks in individual channels there's just no way to know. But my question has another side, how does it work on normal servers for regular channels? (one problem that might happen is that we recompute channel names everytime, with two channels having the same display name the irc-side channel name for ircd might change from one boot to the next.. but that's a problem you'd have with this anyway, we'd really need to remember the name as some kind of matrirc state in a db like I started thinking about in #8. Or I guess I could start leaving rooms I don't use more aggressively...) So that leaves the question for queries... I honestly don't have much idea here; I think if we have a way to list them it's enough as it's pretty much how it works with normal servers but with your current implementation that makes the autojoins optional I'm fine with that for now. |
No worries, life happens to all of us :) I Hope all things realted to your move work(ed) out well :)
Another alternative that I came up with: We could promote the matrirc query to a full channel, and autojoin all "query-contacts" there. This enables the user to see all his direct 1:1 contacts there, and as a bonus, we get /query-completion when in this buffer. I've prototyped this functionality in the latest revision. Seems to be acceptable complexity, code-wise and we get to keep the idiomatic distinction between channels and queries.
Yeah, irc expects the client to know which channels it wants to join, with optional invites if anyone wants to see anyone else.
Hope the code does not spoil your "digital detox" :) |
4cc8cfd to
4933a74
Compare
|
@martinetd: Meanwhile developed any strong feelings towards one or the option? |
martinetd
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another alternative that I came up with: We could promote the matrirc query to a full channel, and autojoin all "query-contacts" there. This enables the user to see all his direct 1:1 contacts there, and as a bonus, we get /query-completion when in this buffer. I've prototyped this functionality in the latest revision. Seems to be acceptable complexity, code-wise and we get to keep the idiomatic distinction between channels and queries.
That's interesting, so it's a channel you cannot talk to but that just shows a list of all possible names for queries -- I actually like the idea!
That'd work well with irssi as well, and we can repurpose the channel for admin commands (such as join a new chan or whatever like how bitlbee or appservice management bots work) later if we want to.
I'm still way behind on "fun" dev time, but I'm happy to trust you on this; there's a couple of minor nits clippy found but it's probably fine to merge as is; thank you and sorry for the wait!
I'll be running this branch a couple of days and let's get this merged out of the way
| use tokio::sync::mpsc; | ||
| use tokio_util::codec::Framed; | ||
|
|
||
| use crate::args::{args, AutoJoinOptions}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AutoJoinOptions is unused since you've used the join_queries()/channels() methods
| roomtarget.join_chan(irc).await; | ||
| } else if chantype == RoomTargetType::Query { | ||
| let name = roomtarget.target().await; | ||
| let _ = irc.send(join(Some(format!("{}!{}@matrirc", name, name)), "matrirc".to_string())).await?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clippy warns on this on my machine: you're using ? so all that's left here is an Unit ();
Either the error is safe to error and there should be no ? or we should drop the let _ =
Looking around the rest of this loop I think we should be consistent: either we expect errors and we should perhaps continue; or keep going, or we should bail out with ? on the join queries case as well.
I think that irc.send has no reason to fail in a way that's recoverable, so I'd make drop the let _ and use ? below as well, but happy either way tbh
The other comment I have reading this diff is that the abstraction for join() is rather annoying when making someone join when we don't have a string ready for their nick!user@host triplet, so perhaps it's make sense to make a second join helper, but I'm happy to let you judge on that as well
Or so I thought, but irssi doesn't like the "matrirc promoted into a channel" without a hash prefix :/ I've tried renaming to #matrirc consistently in a new autojoin-wip branch of this repo (rebased your patches + small nits I pointed out fixed + that channel rename work), but it's not working properly and I've already spent more time on it than I have; I'll try to get back to it soonish... If you can figure it out that'd be welcome. So... yeah... more later. |
Pull request based on the discussion/request from #8.
Please consider this more as a "testable draft", this might not be fully fleshed out yet :)