some tweaks in help

This commit is contained in:
Ondřej Hruška 2021-08-22 12:24:03 +02:00
parent 482a93c172
commit df197f91b7
No known key found for this signature in database
GPG key ID: 2C5FD5035250423D
2 changed files with 49 additions and 16 deletions

View file

@ -91,7 +91,7 @@ static RE_HELP: once_cell::sync::Lazy<Regex> = Lazy::new(|| {
});
static RE_MEMBERS: once_cell::sync::Lazy<Regex> = Lazy::new(|| {
command!(r"(?:members)")
command!(r"(?:members|who)")
});
static RE_LEAVE: once_cell::sync::Lazy<Regex> = Lazy::new(|| {
@ -423,6 +423,7 @@ mod test {
fn test_members() {
assert!(!RE_MEMBERS.is_match("/admin lain@pleroma.soykaf.com"));
assert!(RE_MEMBERS.is_match("/members"));
assert!(RE_MEMBERS.is_match("/who"));
}
#[test]

View file

@ -382,28 +382,54 @@ impl GroupHandle {
}
}
StatusCommand::Help => {
if self.config.is_member_only() {
let mut s = "This is a member-only group. ".to_string();
if self.config.can_write(&notif_acct) {
s.push_str("*You are not a member, ask one of the admins to add you.*");
} else {
if is_admin {
s.push_str("*You are an admin.*");
} else {
s.push_str("*You are a member.*");
}
}
replies.push(s);
} else {
let mut s = "This is a public-access group. ".to_string();
if is_admin {
s.push_str("*You are an admin.*");
}
replies.push(s);
}
replies.push(
"To share an original post with the group, mention the group user.\n\
Posts with commands won't be shared. Supported commands:\n\
"\nTo share an original post, mention the group user.\n\
Posts with commands, and replies, won't be shared.\n\
\n\
**Supported commands:**\n\
`/ignore, /i` - make the group completely ignore the post\n\
`/boost, /b` - boost the replied-to post into the group\n\
`/leave` - leave the group as a member".to_string());
`/members, /who` - show group members / admins\n\
`/boost, /b` - boost the replied-to post into the group".to_string());
if self.config.is_member_only() {
replies.push("`/leave` - leave the group".to_string());
}
if is_admin {
replies.push(
"`/members` - list members and admins\n\
"`/add user` - add a member (use e-mail style address)\n\
`/kick, /remove user` - kick a member\n\
`/add user` - add a member\n\
`/ban x` - ban a user or a server\n\
`/unban x` - lift a ban\n\
`/op, /admin user` - give admin rights\n\
`/deop, /deadmin user` - remove admin rights\n\
`/op, /admin user` - grant admin rights\n\
`/deop, /deadmin user` - revoke admin rights\n\
`/opengroup` - make member-only\n\
`/closegroup` - make public-access\n\
`/announce x` - make a public announcement from all that follows".to_string());
`/announce x` - make a public announcement from the rest of the status".to_string());
}
}
StatusCommand::ListMembers => {
let mut show_admins = false;
if is_admin {
if self.config.is_member_only() {
replies.push("Group members:".to_string());
@ -420,12 +446,18 @@ impl GroupHandle {
}
}
} else {
replies.push("Group admins:".to_string());
let mut admins = self.config.get_admins().collect::<Vec<_>>();
admins.sort();
for a in admins {
replies.push(format!("{}", a));
}
show_admins = true;
}
} else {
show_admins = true;
}
if show_admins {
replies.push("Group admins:".to_string());
let mut admins = self.config.get_admins().collect::<Vec<_>>();
admins.sort();
for a in admins {
replies.push(format!("{}", a));
}
}
}