• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

popstas / telegram-functions-bot / 16128555753

07 Jul 2025 09:44PM UTC coverage: 80.968% (+0.05%) from 80.915%
16128555753

push

github

web-flow
fix: preserve prettyText punctuation and audio progress (#110)

646 of 987 branches covered (65.45%)

Branch coverage included in aggregate %.

17 of 18 new or added lines in 2 files covered. (94.44%)

8 existing lines in 2 files now uncovered.

1830 of 2071 relevant lines covered (88.36%)

4.39 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.0
/src/utils/text.ts
1
export function splitBigMessage(text: string) {
2
  const msgs: string[] = [];
3✔
3
  const sizeLimit = 4096;
3✔
4
  let msg = "";
3✔
5

6
  for (const line of text.split("\n")) {
3✔
7
    if (line.length >= sizeLimit) {
6✔
8
      // If we have accumulated some text, push it first
9
      if (msg) {
1!
UNCOV
10
        msgs.push(msg);
×
UNCOV
11
        msg = "";
×
12
      }
13
      // Split the long line into chunks of sizeLimit
14
      for (let i = 0; i < line.length; i += sizeLimit) {
1✔
15
        const chunk = line.slice(i, i + sizeLimit);
2✔
16
        msgs.push(chunk);
2✔
17
      }
18
    } else if (msg.length + line.length + 1 > sizeLimit) {
5✔
19
      if (msg) msgs.push(msg);
1✔
20
      msg = line + "\n";
1✔
21
    } else {
22
      msg += line + "\n";
4✔
23
    }
24
  }
25

26
  // Handle any remaining text in the buffer
27
  if (msg) {
3✔
28
    // Remove trailing newline if present
29
    const trimmedMsg = msg.endsWith("\n") ? msg.slice(0, -1) : msg;
2!
30
    if (trimmedMsg) msgs.push(trimmedMsg);
2✔
31
  }
32

33
  return msgs;
3✔
34
}
35

36
export function prettyText(text: string) {
37
  if (!text) return "";
8✔
38

39
  const paragraphs: string[] = [];
7✔
40
  const sentences = text.match(/[^.?!]+[.?!]?/g) || [];
7!
41

42
  let paragraph = "";
7✔
43
  for (let sentence of sentences) {
7✔
44
    sentence = sentence.trim();
14✔
45
    if (!/[.?!]$/.test(sentence)) sentence += ".";
14✔
46

47
    paragraph += sentence + " ";
14✔
48
    paragraph = paragraph.replace(/\.\. $/, ". ");
14✔
49

50
    if (paragraph.length > 200) {
14✔
51
      paragraphs.push(paragraph.trim());
1✔
52
      paragraph = "";
1✔
53
    }
54
  }
55

56
  if (paragraph.trim()) {
7✔
57
    paragraphs.push(paragraph.trim());
7✔
58
  }
59

60
  return paragraphs.join("\n\n");
7✔
61
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc