Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
Built and signed on GitHub Actions
latest
gramiojs/splitThis package can split messages which reach the Telegram limit into multiple parts (messages). This package also split entities so you don't need to do it manually.
This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers




JSR Score
76%
Published
2 months ago (0.0.1)
@gramio/split
This package can split messages which reach the Telegram limit into multiple parts (messages). This package also split entities so you don't need to do it manually.
Usage
import { splitMessage } from "@gramio/split"; const bot = new Bot(process.env.BOT_TOKEN!).command( "start", async (context) => { const messages = await splitMessage( format`${bold("a".repeat(4096 * 2))}`, (str) => context.send(str) // be worry. if u wants provide an context.send without function wrapper // you should use context.send.bind(context) it is required because otherwise it will lose context data ); console.log(messages); // messages is array of second argument results } ); await bot.start();
You can also use it in other frameworks.
import { splitMessage } from "@gramio/split"; const messages = await splitMessage( format`${bold("a".repeat(4096 * 2))}`, ({ text, entities }) => { return someOtherFramework.sendMessage(text, { entities }); } );
Configuration
You can also configure maximum text length. By default it's 4096
symbols, but sendPhoto
caption has limit 1024
symbols.
const messages = await splitMessage( format`${bold("a".repeat(4096))}`, ({ text, entities }) => { return context.sendPhoto(PHOTO, { caption: text, caption_entities: entities, }); }, 1024 );
Note
This package mostly in the WIP stage.
TODO:
- More tests
- Plugin with auto-split
- Split mode by entities
- Auto split action strategies (like
sendPhoto
caption next splits tosendMessage
text)
Built and signed on
GitHub Actions
Add Package
deno add jsr:@gramio/split
Import symbol
import * as split from "@gramio/split";
Import directly with a jsr specifier
import * as split from "jsr:@gramio/split";
Add Package
pnpm i jsr:@gramio/split
pnpm dlx jsr add @gramio/split
Import symbol
import * as split from "@gramio/split";
Add Package
yarn add jsr:@gramio/split
yarn dlx jsr add @gramio/split
Import symbol
import * as split from "@gramio/split";
Add Package
vlt install jsr:@gramio/split
Import symbol
import * as split from "@gramio/split";
Add Package
npx jsr add @gramio/split
Import symbol
import * as split from "@gramio/split";
Add Package
bunx jsr add @gramio/split
Import symbol
import * as split from "@gramio/split";