Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@grammyjs/auto-chat-action
Advanced tools
Readme
This plugin provides a middleware to automatically send an appropriate
chat action.
For example sends the "sending video" chat action when sendVideo
is called.
npm i @grammyjs/auto-chat-action
import { autoChatAction } from "https://deno.land/x/grammy_auto_chat_action/mod.ts";
import {
autoChatAction,
AutoChatActionFlavor,
} from "@grammyjs/auto-chat-action";
// Extend the context
const bot = new Bot<Context & AutoChatActionFlavor>("");
// Install the plugin
bot.use(autoChatAction());
import { Bot, Context } from "grammy";
import {
autoChatAction,
AutoChatActionFlavor,
} from "@grammyjs/auto-chat-action";
type MyContext = Context & AutoChatActionFlavor;
// Create a bot.
const bot = new Bot<MyContext>("token");
// Install the plugin
bot.use(autoChatAction());
bot.command("start", (ctx) => {
// Starts sending "typing" chat action in a loop
ctx.chatAction = "typing";
// Some long-running operations...
return ctx.reply("42!");
});
bot.command("photo", (ctx) => {
// Sending the "upload_photo" chat action until the media is uploaded
return ctx.replyWithPhoto(
new InputFile("/tmp/picture.jpg"),
);
});
bot.start();
Automatic sending of a chat action starts under the following conditions:
Sending of a chat action stops under one of the following conditions:
sendChatAction
request caused an error.// Set the action to be sent until the update is processed
ctx.chatAction = "typing";
// To stop sending, simply set the chat action to null
ctx.chatAction = null;
// You can change the chat action during update processing
ctx.chatAction = "choose_sticker";
Sending other requests that require sending a chat action will interrupt the sending of the current chat action.
ctx.chatAction = "typing";
await ctx.reply("Hi!");
// Sends "upload_photo" while file is uploading
await ctx.replyWithPhoto(
new InputFile("/tmp/kitten.png"),
);
// Now there is no sending chat action
// ctx.chatAction is null
import { chatAction } from "@grammyjs/auto-chat-action";
bot.command("start", chatAction("typing"), (ctx) => {
// Some long-running operations...
return ctx.reply("42!");
});
You need to pass bot.api
explicitly to use the plugin with conversations.
// Pass API instance to the plugin
bot.use(autoChatAction(bot.api));
async function greeting(conversation: Conversation<Context>, ctx: Context) {
await ctx.reply("Hi there! What is your name?");
const { message } = await conversation.wait();
ctx.chatAction = "typing";
await conversation.sleep(1000);
await ctx.reply(`Welcome to the chat, ${message.text}!`);
}
FAQs
A plugin for automatic sending a chat action
The npm package @grammyjs/auto-chat-action receives a total of 1,214 weekly downloads. As such, @grammyjs/auto-chat-action popularity was classified as popular.
We found that @grammyjs/auto-chat-action demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.