open-index/open-npm huggingface dataset:
npm package: @puregram/prompt
Description: Basic prompt system implemetation for puregram
Author: nitrojs
Latest version: 1.2.0

<div align='center'>
  <img src='https://i.imgur.com/ZzjmE8i.png' />
</div>

<br />

<div align='center'>
  <a href='https://github.com/nitreojs/puregram'><b><code>puregram</code></b></a>
  <span>&nbsp;•&nbsp;</span>
  <a href='#typescript-usage'><b>TypeScript usage</b></a>
  <span>&nbsp;•&nbsp;</span>
  <a href='https://t.me/puregram_chat'><b>Chat</b></a>
  <span>&nbsp;•&nbsp;</span>
  <a href='https://t.me/puregram_channel'><b>Channel</b></a>
</div>

## @puregram/prompt

_Basic prompt system implemetation for `puregram` package_

### Introduction

`@puregram/prompt` can ask user to send some message and will keep that message in `PromptAnswer.context` variable, which you can access and do whatever you want

### Example
```js
const { Telegram } = require('puregram');
const { PromptManager } = require('@puregram/prompt');

const telegram = new Telegram({
  token: process.env.TOKEN
});

const promptManager = new PromptManager();

telegram.updates.use(promptManager.middleware);

telegram.updates.on('message', (context) => {
  let nameAnswer;

  while (!nameAnswer || !nameAnswer.text) {
    nameAnswer = await context.prompt('Hey! Please, enter your name.')
  }

  const name = nameAnswer.text; // also accessible via `nameAnswer.context.text`

  let ageAnswer;

  while (!ageAnswer || !ageAnswer.text || Number.isNaN(+ageAnswer.text)) {
    ageAnswer = await context.prompt('Cool! Now please enter your age.');
  }

  const age = Number.parseInt(ageAnswer.text);

  return context.send(`You're welcome, ${name} ${age} y.o.!`);
});

telegram.updates.startPolling();
```

### Installation

```sh
$ yarn add @puregram/prompt
$ npm i -S @puregram/prompt
```

---

## TypeScript usage

You can extend context's properties by passing `PromptContext` into `Updates.on<T>`:

```ts
telegram.updates.on<PromptContext>('message', (context) => {
  /* Now you have access to `prompt` and `promptReply` methods via types! */
});
```
npm package: @puregram/utils
Description: Package, containing some useful utilities for puregram
Author: nitrojs
Latest version: 1.0.1

<div align='center'>
  <img src='https://i.imgur.com/ZzjmE8i.png' />
</div>

<br />

<div align='center'>
  <a href='https://github.com/nitreojs/puregram'><b><code>puregram</code></b></a>
  <span>&nbsp;•&nbsp;</span>
  <a href='#list-of-methods--getters'><b>Functions</b></a>
  <span>&nbsp;•&nbsp;</span>
  <a href='https://t.me/puregram'><b>Channel</b></a>
  <span>&nbsp;•&nbsp;</span>
  <a href='https://github.com/nitreojs/puregram#faq'><b>FAQ</b></a>
</div>

## @puregram/utils

_Package, containing some useful utilities for `puregram` package_

### Introduction

This package exists only for one main reason: basically not everyone wants to have such utils as `getCasinoValues` and `<insert one more here>` when installing `puregram`, so these functions were moved to separated package

### Example
```js
const { Telegram } = require('puregram');
const { getCasinoValues } = require('@puregram/utils');

const telegram = new Telegram({
  token: process.env.TOKEN
});

telegram.updates.on('message', (context) => {
  if (context.hasDice && context.dice.emoji === '🎰') {
    console.log(getCasinoValues(context.dice.value)); // e.g. ['seven', 'bar', 'grapes']
  }
});

telegram.updates.startPolling();
```

### Installation

```sh
$ yarn add @puregram/utils
$ npm i -S @puregram/utils
```

---

## List of utilities

### `WebApp`

#### `generateSecretKey(token: string)`

_Returns_: `Promise<WebAppGenerateSecretKeyResult>`

Returns _secret key_ generated by the `token`

```js
const { key } = await WebApp.generateSecretKey(BOT_TOKEN)
```

#### `parseInitData(initData: string)`

_Returns_: `string`

Returns _parsed init data_

```js
const data = WebApp.parseInitData(initData)
```

#### `generateInitDataHash(initData: string, key: Buffer)`

_Returns_: `Promise<WebAppGenerateInitDataHashResult>`

Returns _init data hash_ generated by the `key`

```js
const { hash } = await WebApp.generateInitDataHash(initData, secretKey)
```

#### `validate(params: WebAppValidateInitDataParams)`

_Returns_: `Promise<WebAppValidateResult>`

Returns whether `params.initData` is valid or not

```js
const { valid } = await WebApp.validate({ initData, key: secretKey })
```

### `getCasinoValues(value: number | string)`

_Returns_: `SlotMachineValue`

Returns an _array of `CasinoValue`_ detected by `value` in the dice

```js
if (context.hasDice && context.dice.emoji === '🎰') {
  return context.send(`You've got ${getCasinoValues(context.dice.value).join(', ')}!`)
}
```