@grammyjs/conversations
Advanced tools
Comparing version 0.7.3 to 0.7.4
@@ -321,2 +321,6 @@ import { type ApiResponse, Context, type Filter, type FilterQuery, type LazySessionFlavor, type MiddlewareFn, type RawApi, type SessionFlavor, type Update, type User } from "./deps.node.js"; | ||
}>; | ||
/** | ||
* Utilities for building forms. Contains methods that let you wait for | ||
* messages and automatically perform input validation. | ||
*/ | ||
form: ConversationForm<C>; | ||
@@ -323,0 +327,0 @@ /** |
@@ -301,2 +301,6 @@ "use strict"; | ||
// TODO: implement callback, game, and inline query matching | ||
/** | ||
* Utilities for building forms. Contains methods that let you wait for | ||
* messages and automatically perform input validation. | ||
*/ | ||
this.form = new form_js_1.ConversationForm(this); | ||
@@ -450,13 +454,21 @@ // We intercept Bot API calls, returning logged responses while | ||
_resolveAt(index, value) { | ||
var _b, _c; | ||
var _d, _e; | ||
var _b; | ||
var _c; | ||
const r = (0, utils_js_1.resolver)(value); | ||
if (index < 0) | ||
return r.promise; | ||
(_b = (_d = this.replayIndex).resolve) !== null && _b !== void 0 ? _b : (_d.resolve = 0); | ||
((_c = (_e = this.replayIndex).tasks) !== null && _c !== void 0 ? _c : (_e.tasks = []))[index] = r; | ||
while (this.replayIndex.tasks[this.replayIndex.resolve] !== undefined) { | ||
this.replayIndex.tasks[this.replayIndex.resolve].resolve(); | ||
this.replayIndex.resolve++; | ||
} | ||
((_b = (_c = this.replayIndex).tasks) !== null && _b !== void 0 ? _b : (_c.tasks = []))[index] = r; | ||
const resolveNext = () => { | ||
var _b; | ||
var _c; | ||
if (this.replayIndex.tasks === undefined) | ||
return; | ||
(_b = (_c = this.replayIndex).resolve) !== null && _b !== void 0 ? _b : (_c.resolve = 0); | ||
if (this.replayIndex.tasks[this.replayIndex.resolve] !== undefined) { | ||
this.replayIndex.tasks[this.replayIndex.resolve].resolve(); | ||
this.replayIndex.resolve++; | ||
setTimeout(resolveNext, 0); | ||
} | ||
}; | ||
setTimeout(resolveNext, 0); | ||
return r.promise; | ||
@@ -463,0 +475,0 @@ } |
import { type Context } from "./deps.node.js"; | ||
/** | ||
* Form building utilities that are exposed on `conversation.form`. | ||
* | ||
* All methods of this class behave similarly. They all follow these steps: | ||
* 1. Wait for an update. | ||
* 2. Validate the contained data. | ||
* 3. Skip the update if validation fails. | ||
* 4. Extract the data if the validation succeeds, and return the data. | ||
* | ||
* Moreover, you are able to pass a handler to each method that will be called | ||
* if the user sends an update that fails validation. | ||
*/ | ||
export declare class ConversationForm<C extends Context> { | ||
private readonly conversation; | ||
/** This class is constructed internally by the plugin. */ | ||
constructor(conversation: { | ||
@@ -5,0 +18,0 @@ wait: () => Promise<C>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ConversationForm = void 0; | ||
/** | ||
* Form building utilities that are exposed on `conversation.form`. | ||
* | ||
* All methods of this class behave similarly. They all follow these steps: | ||
* 1. Wait for an update. | ||
* 2. Validate the contained data. | ||
* 3. Skip the update if validation fails. | ||
* 4. Extract the data if the validation succeeds, and return the data. | ||
* | ||
* Moreover, you are able to pass a handler to each method that will be called | ||
* if the user sends an update that fails validation. | ||
*/ | ||
class ConversationForm { | ||
/** This class is constructed internally by the plugin. */ | ||
constructor(conversation) { | ||
@@ -27,2 +40,3 @@ this.conversation = conversation; | ||
} | ||
// TODO: add match which returns `ctx.match` after `ctx.hasMatch` | ||
/** | ||
@@ -29,0 +43,0 @@ * Waits until the user sends a number, and returns this number. If the user |
{ | ||
"name": "@grammyjs/conversations", | ||
"description": "Conversational interfaces for grammY", | ||
"version": "0.7.3", | ||
"version": "0.7.4", | ||
"author": "KnorpelSenf", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
@@ -8,4 +8,7 @@ # <h1 align="center">grammY Conversations</h1> | ||
Here is an example for both Deno and Node of how you can use this package. It mainly exports `Conversation`, `ConversationFlavor`, and `createConversation`. | ||
Here is an example for both Deno and Node of how you can use this package. Besides the main plugin function `conversation`, it exports `createConversation` for registering conversations. | ||
Also, it will give you the types `Conversation`, and `ConversationFlavor`. | ||
The API reference is at <https://doc.deno.land/https://deno.land/x/grammy_conversations/mod.ts>. | ||
## Deno | ||
@@ -12,0 +15,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
64668
1400
148