|
1 |
| -# gramscript |
2 |
| -PowerFull Node js Telegram bot API |
| 1 | +<!-- <p align='center'> |
| 2 | + <img alt="GitHub Sparkline" src="https://github.com/gramscript/gramscript"> |
| 3 | +</p> --> |
| 4 | +<br> |
| 5 | +<p align="center"> |
| 6 | + <img alt="GitHub code size in bytes" src="https://img.shields.io/github/languages/code-size/gramscript/gramscript?logo=files&logoColor=f72585&style=social"> |
| 7 | + <a href="https://www.codefactor.io/repository/github/gramscript/gramscript/overview/main"><img src="https://www.codefactor.io/repository/github/kalanakt/all-url-uploader/badge/main" alt="CodeFactor" /></a> |
| 8 | + <img alt="GitHub issues" src="https://img.shields.io/github/issues-raw/gramscript/gramscript?color=8eecf5&logo=anaconda&logoColor=06d6a0&style=social"> |
| 9 | + <img alt="GitHub" src="https://img.shields.io/github/license/gramscript/gramscript?logo=adguard&logoColor=390099&style=social"> |
| 10 | + <img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/gramscript/gramscript?color=90e0ef&logoColor=ff4d6d&style=social"> |
| 11 | + <img alt="GitHub last commit" src="https://img.shields.io/github/last-commit/gramscript/gramscript?logo=electron&logoColor=89fc00&style=social"> |
| 12 | +</p> |
| 13 | +<br> |
| 14 | + |
| 15 | +## Installation |
| 16 | + |
| 17 | +```consol |
| 18 | +npm install gramscript |
| 19 | +``` |
| 20 | +```consol |
| 21 | +npm i gramscript |
| 22 | +``` |
| 23 | +```consol |
| 24 | +yarn add gramscript |
| 25 | +``` |
| 26 | + |
| 27 | +## Usage |
| 28 | +Creating custom bot Object |
| 29 | + |
| 30 | +```js |
| 31 | +const TeleBot = require('gramscript'); |
| 32 | +const bot = new TeleBot('TELEGRAM_BOT_TOKEN'); |
| 33 | + |
| 34 | +// bot's script here |
| 35 | + |
| 36 | +bot.start(); |
| 37 | +``` |
| 38 | + |
| 39 | +## Quick Examples |
| 40 | + |
| 41 | +### Forwad Same Message Text |
| 42 | + |
| 43 | +```js |
| 44 | +const TeleBot = require('gramscript'); |
| 45 | +const bot = new TeleBot('123yuio456pasd678fghWqaz'); |
| 46 | + |
| 47 | +// bot command |
| 48 | +bot.on('/hello', (msg) => { |
| 49 | + return bot.sendMessage(msg.from.id, `Hello, ${ msg.from.first_name }!`); |
| 50 | +}); |
| 51 | + |
| 52 | +// if user send message text , bot will forward same content |
| 53 | +bot.on('text', (msg) => msg.reply.text(msg.text)); |
| 54 | + |
| 55 | +// if user send sticker, bot will forwad same sticker |
| 56 | +bot.on('sticker', (msg) => { |
| 57 | + return msg.reply.sticker('http://i.imgur.com/VRYdhuD.png', { asReply: true }); |
| 58 | +}); |
| 59 | + |
| 60 | +// also work with multiple events |
| 61 | +bot.on(['/start', 'audio', 'sticker'], msg => { |
| 62 | + return bot.sendMessage(msg.from.id, 'Bam!'); |
| 63 | +}); |
| 64 | + |
| 65 | +bot.start(); |
| 66 | +``` |
0 commit comments