# telegraf-layoutfixer

> Layout fixing middleware for Telegram bots

Latest version **1.1.1** (published 2021-09-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install telegraf-layoutfixer
pnpm add telegraf-layoutfixer
yarn add telegraf-layoutfixer
bun add telegraf-layoutfixer
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2021-09-13 |
| First published | 2021-08-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8 |
| Dependencies | 1 |
| Unpacked size | 8.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Art Ginzburg |
| Maintainers | artginzburg |
| Keywords | telegraf, telegram, bot, middleware, api, layout, convert, fix |

## Links

- npm: https://www.npmjs.com/package/telegraf-layoutfixer
- Repository: https://github.com/artginzburg/telegraf-layoutfixer
- Homepage: https://github.com/artginzburg/telegraf-layoutfixer#readme
- Issues: https://github.com/artginzburg/telegraf-layoutfixer/issues
- Funding: https://www.buymeacoffee.com/artginzburg
- npm.io page: https://npm.io/package/telegraf-layoutfixer

## Dependencies (1)

- [convert-layout](https://npm.io/package/convert-layout.md) ^0.10.0

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.1.1 (latest) — 2021-09-13
- 1.1.0 — 2021-08-14
- 1.0.7 — 2021-08-13
- 1.0.6 — 2021-08-13
- 1.0.5 — 2021-08-12
- 1.0.4 — 2021-08-11
- 1.0.3 — 2021-08-08
- 1.0.2 — 2021-08-08
- 1.0.1 — 2021-08-08
- 1.0.0 — 2021-08-08

## README

<h1 align="center">

  [telegraf][telegraf]-layoutfixer
</h1>

[![Dependencies](https://status.david-dm.org/gh/artginzburg/telegraf-layoutfixer.svg)](https://david-dm.org/artginzburg/telegraf-layoutfixer)
<a href="https://www.npmjs.com/package/telegraf-layoutfixer?activeTab=versions"><img align="right" alt="npm" src="https://img.shields.io/npm/dw/telegraf-layoutfixer?labelColor=white&color=cd0d0d&logo=npm"></a>

<div align="center">

  Suggests layout typo fixes in Telegram chats (`.рудз` => `/help`)
</div>

## Quick start

First, run `npm i telegraf-layoutfixer`. Then, in your [Telegraf][telegraf] app:

```js
const { Telegraf } = require('telegraf')
const layoutfixer = require('telegraf-layoutfixer')

const bot = new Telegraf(process.env.BOT_TOKEN)

// ...

bot.use(layoutfixer())

bot.launch()
```

> layoutfixer should be connected last, after all the other text-related middlewares

## Preview

<img width="300" alt="preview" src="misc/preview.jpg">

## Options

[Defaults](https://github.com/artginzburg/telegraf-layoutfixer/blob/main/defaultConfig.js) are shown below:

```js
require('telegraf-layoutfixer')({
  allowUnlistedCommands: false,
  validator: /^\w+$/,
  validInitiators: ['/', '.', '?', '÷', '\\', '|', '«', '»'],
  commands: undefined,
});
```

### allowUnlistedCommands (_default: `false`_)

Sets whether the bot should suggest fixes for commands that are not shown when the user starts typing `/`

### validator (_default: `/^\w+$/`_)

Sets a RegEx for validating layout-converted message as a command. Allows only words by default (a-z, A-Z, 0-9, _)

### validInitiators (_default: `['/', '.', '?', '÷', '\\', '|', '«', '»']`_)

Defines the first symbol of a message that tells layoutfixer the text should be interpreted as a command.

### commands (_default: `ctx.telegram.getMyCommands()`_)

Sets the commands that count as listed (if `allowUnlistedCommands` is `false`). Gets the bot's currently specified commands by default.

## Caught a Bug?

1. [Fork](https://help.github.com/articles/fork-a-repo/) this [repository](https://github.com/artginzburg/telegraf-layoutfixer/fork) to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device
2. Link the package to the global module directory: `npm link`
3. Within the Telegraf app you want to test your local development instance of telegraf-layoutfixer, just link it to the dependencies: `npm link telegraf-layoutfixer`. Instead of the default one from npm, Node.js will now use your clone of the middleware!

[telegraf]: https://www.npmjs.com/package/telegraf

---
_Source: https://npm.io/package/telegraf-layoutfixer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
