# telegraf-hears-modules

> hears modules for telegraf

Latest version **1.0.1** (published 2021-02-08) · ISC license · 0 weekly downloads

## Install

```sh
npm install telegraf-hears-modules
pnpm add telegraf-hears-modules
yarn add telegraf-hears-modules
bun add telegraf-hears-modules
```

## 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.0.1 |
| Published | 2021-02-08 |
| First published | 2021-01-31 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 296.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Leystof |
| Maintainers | leystof |
| Keywords | telegraf, telegram, hears, modules, nodejs |

## Links

- npm: https://www.npmjs.com/package/telegraf-hears-modules
- Repository: https://github.com/leystof/telegraf-hears-modules
- Homepage: https://github.com/leystof/telegraf-hears-modules/#readme
- Issues: https://github.com/leystof/telegraf-hears-modules/issues
- npm.io page: https://npm.io/package/telegraf-hears-modules

## Dependencies (1)

- [telegraf](https://npm.io/package/telegraf.md) ^4.0.2

## Recent versions

- 1.0.1 (latest) — 2021-02-08
- 1.0.0 — 2021-01-31

## README

###### Shitcode be like:
# Telegraf hearModules
`npm install telegraf-hears-modules`

![example](https://github.com/leystof/telegraf-hears-modules/blob/master/example/example.png)
- ![#FFCC66](https://via.placeholder.com/15/FFCC66/000000?text=+) Module is disabled `this.disable = true`
- ![#99CC99](https://via.placeholder.com/15/99CC99/000000?text=+) Successful module loading
- ![#F2777A](https://via.placeholder.com/15/F2777A/000000?text=+) Error module loading
## Example
### index.js
```javascript
const { Telegraf } = require("telegraf"); // import telegraf
const { modulesLoad } = require("telegraf-hears-modules"); // import telegraf-hears-modules

const bot = new Telegraf("Your bot token");
modulesLoad(bot, "Folder with modules", data = {
  // Your variables that will be available in the module \ optional
  testField: "Leystof"
}); // Loading modules

bot.launch()
```
### Module file
```javascript
module.exports.Module = function (bot, data) {
  // this.disable = true // if true === module not loading \ Optional field

  this.triggers = [
    /^Field/i,
  ]; // text or regexp

  this.func = async (ctx) => {
    // Here the execution of the command
    return ctx.reply(data.testField)
  };
};
```

## Callback example
```javascript
const { Markup } = require("telegraf");

module.exports.Module = function (bot) {

  this.triggers = [
    /^Test/i,
  ];

  this.callback = "test"

  this.func = async (ctx) => {
    if (ctx.callbackQuery) {
      return ctx.editMessageText("Callback work ✨")
    }

    return ctx.reply(`Test callback`, Markup.inlineKeyboard([
      Markup.button.callback("Click", "test"),
    ]))
  };
};
```
## Tests
```javascript
const { Telegraf } = require("telegraf");
const { testLoad } = require("telegraf-hears-modules");

const bot = new Telegraf("Your token");

testLoad(bot);
```

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