Secured command to prevent spam from regular users.
All checks were successful
Main / build-and-push-docker-image (20.x) (pull_request) Successful in 3m1s
All checks were successful
Main / build-and-push-docker-image (20.x) (pull_request) Successful in 3m1s
This commit is contained in:
@@ -15,7 +15,16 @@ feature.hears(
|
||||
logHandle("bot-info-command"),
|
||||
async (ctx: Context) => {
|
||||
// Checks if the context includes a message property.
|
||||
if (ctx.msg) {
|
||||
if (ctx.msg && ctx.chat && ctx.msg.from) {
|
||||
// Doesn't respond to regular users in groups. This is to prevent users spamming the command.
|
||||
if (ctx.chat.type !== "private") {
|
||||
const chatMember = await ctx.getChatMember(ctx.msg.from.id);
|
||||
|
||||
if (!["creator", "administrator"].includes(chatMember.status)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Replies to the message.
|
||||
await ctx.reply(
|
||||
`I am a bot designed to delete any Twitter/X and Meta links along with corresponding reformatting services\\. I now check embedded links\\!`,
|
||||
|
||||
@@ -16,10 +16,10 @@ feature.hears(/^\/help/, logHandle("help"), async (ctx: Context) => {
|
||||
: undefined;
|
||||
|
||||
// Checks there is a chat and msg property in the context.
|
||||
if (ctx.chat && ctx.msg) {
|
||||
if (ctx.chat && ctx.msg && ctx.msg.from) {
|
||||
// Checks if the chat is private
|
||||
if (ctx.chat.type === "private") {
|
||||
// Responds with the command list.
|
||||
// Responds with message.
|
||||
await ctx.reply(
|
||||
`Currently I have no commands for the public beta\\. I require no configuration\\. Simply add me to a group and make me an admin with the permission to delete messages\\. From there I will start deleting any Twitter\\/X and Meta links I detect\\. I also check embeds and forwards\\. Use /\\botInfo to learn more about my mission and why I was created\\.`,
|
||||
{
|
||||
@@ -29,14 +29,27 @@ feature.hears(/^\/help/, logHandle("help"), async (ctx: Context) => {
|
||||
);
|
||||
}
|
||||
|
||||
// Checks if chat is a group.
|
||||
if (ctx.chat.type !== "private") {
|
||||
await ctx.reply(
|
||||
`Currently I have no commands for the public beta\\. I require no configuration\\. If I am not working\\, make sure I have an admin role with the permission to delete messages\\. I should already be deleting any Twitter\\/X and Meta links I detect\\. I also check embeds and forwards\\. Use /\\botInfo to learn more about my mission and why I was created\\.`,
|
||||
{
|
||||
parse_mode: "MarkdownV2",
|
||||
reply_parameters: { message_id: ctx.msg.message_id }
|
||||
}
|
||||
);
|
||||
const chatMember = await ctx.getChatMember(ctx.msg.from.id);
|
||||
|
||||
// Checks if the user is an admin.
|
||||
if (["creator", "administrator"].includes(chatMember.status)) {
|
||||
// Respond with message.
|
||||
await ctx.reply(
|
||||
`Currently I have no commands for the public beta\\. I require no configuration\\. If I am not working\\, make sure I have an admin role with the permission to delete messages\\. I should already be deleting any Twitter\\/X and Meta links I detect\\. I also check embeds and forwards\\. Use /\\botInfo to learn more about my mission and why I was created\\.`,
|
||||
{
|
||||
parse_mode: "MarkdownV2",
|
||||
reply_parameters: { message_id: ctx.msg.message_id }
|
||||
}
|
||||
);
|
||||
} else {
|
||||
/**
|
||||
* Doesn't respond to regular users in groups. This is to prevent users spamming the command.
|
||||
* Especially since this one includes some political opinions/messages.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
await ctx.reply(
|
||||
@@ -48,7 +61,7 @@ feature.hears(/^\/help/, logHandle("help"), async (ctx: Context) => {
|
||||
);
|
||||
|
||||
return await ctx.reply(
|
||||
`Down with fascism\\! Fuck MAGA\\! Fuck Trump\\! Fuck Nazis\\! Trans rights are human rights\\! Trans women are women\\! Trans men and men\\! Never let them take awy your happiness\\!`,
|
||||
`Down with fascism\\! Fuck MAGA\\! Fuck Trump\\! Fuck Nazis\\! Trans rights are human rights\\! Trans women are women\\! Trans men are men\\! Never let them take away your happiness\\!`,
|
||||
{
|
||||
parse_mode: "MarkdownV2",
|
||||
reply_parameters: { message_id: ctx.msg.message_id }
|
||||
|
||||
Reference in New Issue
Block a user