Skip to content

Commit

Permalink
sendMediaGroup, error handling, InputMedia types
Browse files Browse the repository at this point in the history
  • Loading branch information
Alper Kürşat committed Jan 10, 2022
1 parent 1c2b2ed commit 920a053
Show file tree
Hide file tree
Showing 34 changed files with 3,395 additions and 431 deletions.
37 changes: 37 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"env": {
"browser": true,
"commonjs": true,
"es2021": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 12
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"indent": [
"error",
2
],
"@typescript-eslint/no-var-requires": "ignore",
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"never"
]
}
}
10 changes: 10 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#

## 2022

### January 10th

+ _download_ method now returns extension and size of downloaded file
+ support for exceptional method [sendMediaGroup](https://github.com/botocrats/telegram/issues)
+ Missing _InputMedia_ types added
+ Better error handling
22 changes: 16 additions & 6 deletions README.MD
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Telegram Client
# Telegram Bot Client

[![npm version](https://badge.fury.io/js/@botocrat%2Ftelegram.svg)](https://npmjs.com/package/@botocrat/telegram)

A fuss-free, light-weight wrapper Telegram Client for Node.js.

Expand All @@ -9,12 +11,11 @@ Tested Node version: [15.4.0](https://github.com/nodejs/node/releases/tag/v15.4.
## What's the difference?

- You don't have to think about the order of the arguments, same as official API
- Smallest size(< 4 kb)
- Smallest size(< 5 kb)
- Minimal dependencies
- Future-proof (Only types will added on Telegram API changes)
- [Bent](https://github.com/mikeal/bent) as http requester


## Getting started

```bash
Expand Down Expand Up @@ -42,19 +43,28 @@ const sent = await client.sendMessage(Message)

```

### Extra: Download File From Telegram
### Extra Feature: Download File From Telegram

```typescript
...

const file = await client
const [data, ext, size] = await client
.getFile(incomingMessage.photo)
.then(client.download) // Buffer

fs.writeFileSync("fileName.ext", file)
fs.writeFileSync("fileName." + ext, data)
...
```

## Client options

| Param | Description | Default |
|-|-|-|
| token | Telegram bot token | *Required* |
| debug | Debug function | () => void|
| baseUri | Telegram API url | _https://api.telegram.org_ |
| fileSizeLimit | Size limiter for .download() method | Infinity (no limit) |

No need for extra documentation, methods and parameters explained in Official Telegram Bot API Documentation

## Resources
Expand Down
Loading

0 comments on commit 920a053

Please sign in to comment.