feat(paroxysm): upload queries for all quotes to eta's pastebin

- Currently, asking for all your quotes either stalls the bot, or
  doesn't result in you getting all your quotes, or both. This aims
  to resolve this oversight by shoving them all in a pastebin.
- This uses the lovely `crimp` library by tazjin, which is really
  good at just doing HTTP stuff with minimal fuss. Amazing!
  (although we should probably actually use the depot version)
- Everything is hard coded for now, but we probably don't care.
- Stuff expires after 24 hours, for privacy reasons?
- We also had to add a function to format entries without colours,
  and took the opportunity to clean up the format!() a bit.

Change-Id: I6e75968c7da48a51fff327355b8fa2c025d0db75
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1872
Tested-by: BuildkiteCI
Reviewed-by: glittershark <grfn@gws.fyi>
Reviewed-by: lukegb <lukegb@tvl.fyi>
This commit is contained in:
eta 2020-08-29 00:18:56 +01:00
parent 13088392e2
commit 9e118c6d69
5 changed files with 116 additions and 12 deletions

View file

@ -108,8 +108,12 @@ impl KeywordDetails {
}
pub fn format_entry(&self, idx: usize) -> Option<String> {
self.format_entry_colours(idx, true)
}
pub fn format_entry_colours(&self, idx: usize, with_colours: bool) -> Option<String> {
if let Some(ent) = self.entries.get(idx.saturating_sub(1)) {
let gen_clr = if self.keyword.chan == "*" {
let gen_clr = if self.keyword.chan == "*" && with_colours {
"\x0307"
} else {
""
@ -117,13 +121,18 @@ impl KeywordDetails {
let zwsp_name = Self::add_zwsp_to_name(&self.keyword.name)
.unwrap_or_else(|| self.keyword.name.clone());
Some(format!(
"\x02{}{}\x0f\x0315[{}/{}]\x0f: {} \x0f\x0314[{}]\x0f",
"{}{}{name}{}[{idx}/{total}]{}: {text} {}[{date}]{}",
if with_colours { "\x02" } else { "" },
gen_clr,
zwsp_name,
idx,
self.entries.len(),
ent.text,
ent.creation_ts.date()
if with_colours { "\x0f\x0315" } else { "" },
if with_colours { "\x0f" } else { "" },
if with_colours { "\x0f\x0314" } else { "" },
if with_colours { "\x0f" } else { "" },
name = zwsp_name,
idx = idx,
total = self.entries.len(),
text = ent.text,
date = ent.creation_ts.date()
))
} else {
None