Skip to content

Commit 4cc8cfd

Browse files
committed
Option: Add query-users to matirc channel
1 parent 9cf2761 commit 4cc8cfd

File tree

2 files changed

+29
-12
lines changed

2 files changed

+29
-12
lines changed

src/ircd/login.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use anyhow::{Context, Error, Result};
22
use irc::{client::prelude::Command, proto::IrcCodec};
3+
use crate::ircd::proto::{join, raw_msg};
34
use log::{debug, info, trace, warn};
45
use tokio::net::TcpStream;
56
use tokio::sync::oneshot;
@@ -53,6 +54,22 @@ pub async fn auth_loop(
5354
)))
5455
.await?;
5556
info!("Processing login from {}!{}", nick, user);
57+
// Promote matric to chan
58+
let matrircchan = "matrirc".to_string();
59+
stream
60+
.send(join(
61+
Some(format!("{}!{}@matrirc", nick, user)),
62+
"matrirc".to_string(),
63+
))
64+
.await?;
65+
stream
66+
.send(join(
67+
Some(format!("{}!{}@matrirc", nick, user)),
68+
"matrirc".to_string(),
69+
))
70+
.await?;
71+
stream.send(raw_msg(format!(":matrirc 353 {} = {} :@matrirc", nick, matrircchan))).await?;
72+
stream.send(raw_msg(format!(":matrirc 366 {} {} :End", nick, matrircchan))).await?;
5673
let client = match state::login(&nick, &pass)? {
5774
Some(session) => matrix_restore_session(stream, &nick, &pass, session).await?,
5875
None => matrix_login_loop(stream, &nick, &pass).await?,

src/ircd/proto.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,6 @@ pub async fn ircd_sync_write(
165165
}
166166

167167
pub async fn join_channels(matrirc: &Matrirc) -> Result<()> {
168-
if args().autojoin == AutoJoinOptions::None {
169-
return Ok(());
170-
}
171-
172168
let irc = matrirc.irc();
173169
let matrix = matrirc.matrix();
174170
let mapping = matrirc.mappings();
@@ -189,14 +185,18 @@ pub async fn join_channels(matrirc: &Matrirc) -> Result<()> {
189185
&& args().autojoin.join_channels()
190186
{
191187
roomtarget.join_chan(irc).await;
192-
} else if chantype == RoomTargetType::Query && args().autojoin.join_queries() {
193-
let _ = irc
194-
.send(privmsg(
195-
roomtarget.target().await,
196-
&irc.nick,
197-
"* <Resumed connection to matrirc>",
198-
))
199-
.await;
188+
} else if chantype == RoomTargetType::Query {
189+
let name = roomtarget.target().await;
190+
let _ = irc.send(join(Some(format!("{}!{}@matrirc", name, name)), "matrirc".to_string())).await?;
191+
if args().autojoin.join_queries() {
192+
let _ = irc
193+
.send(privmsg(
194+
name,
195+
&irc.nick,
196+
"* <Resumed connection to matrirc>",
197+
))
198+
.await;
199+
}
200200
}
201201
}
202202
Ok(())

0 commit comments

Comments
 (0)