draft/multiline: inbound BATCH parsing + concat assembly, deliver assembled lines; advertise limits
This commit is contained in:
parent
5a34ec57da
commit
d4c4c1a7d0
6 changed files with 148 additions and 1 deletions
|
|
@ -127,9 +127,40 @@ pub fn commands() -> Vec<Box<dyn Command>> {
|
|||
Box::new(Redact),
|
||||
Box::new(MarkRead),
|
||||
Box::new(Metadata),
|
||||
Box::new(Batch),
|
||||
]
|
||||
}
|
||||
|
||||
/// BATCH — the client side of draft/multiline. `BATCH +<ref> draft/multiline
|
||||
/// <target>` opens a batch; the `@batch=<ref>`-tagged PRIVMSG/NOTICE lines are
|
||||
/// buffered (see `Ircd::dispatch`); `BATCH -<ref>` assembles them (honouring
|
||||
/// `draft/multiline-concat`) and delivers each logical line normally.
|
||||
struct Batch;
|
||||
impl Command for Batch {
|
||||
fn name(&self) -> &'static str {
|
||||
"BATCH"
|
||||
}
|
||||
fn min_params(&self) -> usize {
|
||||
1
|
||||
}
|
||||
fn handle(&self, s: &mut Server, uid: Uid, params: &[String]) -> CmdResult {
|
||||
let tag = ¶ms[0];
|
||||
if let Some(bref) = tag.strip_prefix('+') {
|
||||
if params.get(1).map(|t| t.as_str()) == Some("draft/multiline") {
|
||||
let target = params.get(2).cloned().unwrap_or_default();
|
||||
s.multiline_open(uid, bref, &target);
|
||||
}
|
||||
} else if let Some(bref) = tag.strip_prefix('-') {
|
||||
if let Some((target, notice, lines)) = s.multiline_close(uid, bref) {
|
||||
for line in lines {
|
||||
deliver(s, uid, &[target.clone(), line], notice);
|
||||
}
|
||||
}
|
||||
}
|
||||
CmdResult::Ok
|
||||
}
|
||||
}
|
||||
|
||||
/// METADATA — draft/metadata-2. `METADATA <target> <GET|LIST|SET|CLEAR> [args]`.
|
||||
/// `<target>` is `*` (self), a nick, or a `#channel`. Anyone may GET/LIST; only the
|
||||
/// user themselves or a channel op/oper may SET/CLEAR. Values are public (`*`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue