Allocate guest nicks that skip online and registered names
This commit is contained in:
parent
2c81af108b
commit
118782a4bf
5 changed files with 40 additions and 7 deletions
|
|
@ -1,13 +1,12 @@
|
|||
use echo_api::{Sender, ServiceCtx};
|
||||
use echo_api::{NetView, Sender, ServiceCtx, Store};
|
||||
|
||||
// LOGOUT: log out and rename to a guest nick (prefix + a per-logout sequence).
|
||||
pub fn handle(me: &str, guest_nick: &str, guest_seq: &mut u32, from: &Sender, ctx: &mut ServiceCtx) {
|
||||
pub fn handle(me: &str, guest_nick: &str, guest_seq: &mut u32, from: &Sender, ctx: &mut ServiceCtx, net: &dyn NetView, db: &dyn Store) {
|
||||
if from.account.is_none() {
|
||||
ctx.notice(me, from.uid, "You're not logged in.");
|
||||
return;
|
||||
}
|
||||
let guest = format!("{guest_nick}{guest_seq}");
|
||||
*guest_seq = guest_seq.wrapping_add(1);
|
||||
let guest = echo_api::next_guest_nick(guest_nick, guest_seq, net, db);
|
||||
ctx.logout(from.uid);
|
||||
ctx.force_nick(from.uid, &guest);
|
||||
ctx.notice(me, from.uid, format!("You're now logged out. Your nick is now \x02{}\x02.", guest));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue