fix-startup #77
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@@ -34,6 +34,8 @@ jobs:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ env.OWNER }}
|
||||
password: ${{ secrets.TOKEN }}
|
||||
- name: Docker Hub Login
|
||||
run: echo "${{ secrets.DOCKER_HUB_TOKEN }}" | docker login -u "${{ secrets.DOCKER_HUB_USERNAME }}" --password-stdin
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
- name: Setup Docker buildx
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
{
|
||||
"name": "no-twitter-bot",
|
||||
"type": "module",
|
||||
"version": "2.1.0",
|
||||
"version": "3.0.0",
|
||||
"private": true,
|
||||
"packageManager": "yarn@4.9.2",
|
||||
"description": "This grammY powered Telegram bot is designed to delete Twitter/X links and reformat services from whitelisted groups. This one is the main bot for the LCM Telegram groups/communities.",
|
||||
"imports": {
|
||||
"#root/*": "./build/src/*"
|
||||
},
|
||||
"author": "Lucid Kobold (Lucid Creations Media) <social@lucidcreations.media>",
|
||||
"author": "Lucid (Werewolf Kid Creations) <social@werewolfkid.monster>",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=20.0.0",
|
||||
|
||||
@@ -4,21 +4,42 @@ import { logHandle } from "#root/bot/helpers/logging.js";
|
||||
|
||||
const composer = new Composer<Context>();
|
||||
|
||||
const feature = composer.chatType(["private"]);
|
||||
const feature = composer.chatType(["private", "group", "supergroup"]);
|
||||
|
||||
/**
|
||||
* What triggers this feature and adds to the log when it has been triggered.
|
||||
* The trigger is the command "/botInfo"
|
||||
*/
|
||||
feature.hears(
|
||||
"/botInfo",
|
||||
feature.command(
|
||||
"botInfo",
|
||||
logHandle("bot-info-command"),
|
||||
async (ctx: Context) => {
|
||||
// Checks if the context includes a message property.
|
||||
if (ctx.msg) {
|
||||
// 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\\!`,
|
||||
{
|
||||
parse_mode: "MarkdownV2",
|
||||
reply_parameters: { message_id: ctx.msg.message_id }
|
||||
}
|
||||
);
|
||||
await ctx.reply(
|
||||
`[Lucid](https://werewolfkid.monster) made this bot as a protest against the enshittification of Twitter and Nazi\\-fication of it\\ ever since Elon Must did a Nazi salute at a Trump Rally celebrating Trump\\'s second inauguration\\.`,
|
||||
{
|
||||
parse_mode: "MarkdownV2",
|
||||
reply_parameters: { message_id: ctx.msg.message_id }
|
||||
}
|
||||
);
|
||||
await ctx.reply(
|
||||
`Recently there have been reports of extremist right\\-wing individuals targeting anyone left of center to doxx and harass\\. The victims of these doxxes have also come out to state that they have had several accounts hacked into\\, including accounts that have unique passwords\\. So it is clear these asshole are using some script kiddie malware to capture\\/steal credentials and possibly even stored passwords\\.`,
|
||||
{
|
||||
parse_mode: "MarkdownV2",
|
||||
reply_parameters: { message_id: ctx.msg.message_id }
|
||||
}
|
||||
);
|
||||
return await ctx.reply(
|
||||
`I am a bot designed to delete any Twitter/X and Meta links along with corresponding reformatting services within whitelisted groups\\. I now check embedded links\\! By default I only work with whitelisted group IDs\\.\n\nYou can fork me from this link: https://github\\.com/lucid\\-creations\\-media/no\\-twitter\\-bot and deploy me for use in your own groups\\!`,
|
||||
`Lucid decided it was time to make a statement\\. Twitter\\/X is not safe anymore\\. The fandom doesn\\'t need it\\. It should be boycotted and not allowed anymore\\.`,
|
||||
{
|
||||
parse_mode: "MarkdownV2",
|
||||
reply_parameters: { message_id: ctx.msg.message_id }
|
||||
|
||||
@@ -10,8 +10,8 @@ const feature = composer.chatType(["group", "supergroup"]);
|
||||
* What triggers this feature and adds to the log when it has been triggered.
|
||||
* The trigger is the command "/botInfo"
|
||||
*/
|
||||
feature.hears(
|
||||
"/getGroupID",
|
||||
feature.command(
|
||||
"getGroupID",
|
||||
logHandle("get-group-id"),
|
||||
async (ctx: Context) => {
|
||||
// Pulling the group IDs from the env variables.
|
||||
|
||||
@@ -10,18 +10,18 @@ const feature = composer.chatType(["group", "supergroup", "private"]);
|
||||
* What triggers this feature and adds to the log when it has been triggered.
|
||||
* The trigger is the command "/help"
|
||||
*/
|
||||
feature.hears("/help", logHandle("help"), async (ctx: Context) => {
|
||||
feature.command("help", logHandle("help"), async (ctx: Context) => {
|
||||
const GROUP_IDS = process.env.GROUP_IDS
|
||||
? process.env.GROUP_IDS.split(",")
|
||||
: undefined;
|
||||
|
||||
// Checks there is a chat and msg property in the context.
|
||||
if (ctx.chat && ctx.msg) {
|
||||
// CHecks if the chat is private
|
||||
// Checks if the chat is private
|
||||
if (ctx.chat.type === "private") {
|
||||
// Responds with the command list.
|
||||
return await ctx.reply(
|
||||
`**Here are the available commands you can use:**\n\n/getGroupID _ADMIN ONLY | Only available in groups_\\- Replies with the ID of the group I am in\\.\n\n/isWKCGRoup _ADMIN ONLY_ \\- Checks if this group's ID is on the whitelist and responds accordingly\\.\n\n/botInfo _Private Command_\\- Info about me and how to fork me to deploy for your own use\\.\n\n/help\\- Displays this help message\\.`,
|
||||
`Currently I have no commands for the public beta\\. I require no configuration\\. Simply add me to a group and 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\\.`,
|
||||
{
|
||||
parse_mode: "MarkdownV2",
|
||||
reply_parameters: { message_id: ctx.msg.message_id }
|
||||
@@ -29,57 +29,65 @@ feature.hears("/help", logHandle("help"), async (ctx: Context) => {
|
||||
);
|
||||
}
|
||||
|
||||
return await ctx.reply(
|
||||
`Currently I have no commands for the public beta\\. I require no configuration\\. 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 }
|
||||
}
|
||||
);
|
||||
|
||||
// Checks if the whitelist is set up.
|
||||
if (GROUP_IDS !== undefined) {
|
||||
const groupID = ctx.chat.id;
|
||||
const flag = GROUP_IDS.includes(`${groupID}`);
|
||||
// if (GROUP_IDS !== undefined) {
|
||||
// const groupID = ctx.chat.id;
|
||||
// const flag = GROUP_IDS.includes(`${groupID}`);
|
||||
|
||||
// Checks if the chat is in the whitelist.
|
||||
if (flag) {
|
||||
// Responds with the command list.
|
||||
return await ctx.reply(
|
||||
`**Here are the available commands you can use:**\n\n/getGroupID _ADMIN ONLY_ \\- Replies with the ID of the group I am in\\.\n\n/isWKCGRoup _ADMIN ONLY_ \\- Checks if this group's ID is on the whitelist and responds accordingly\\.\n\n/botInfo _Private Command_\\- Info about me and how to fork me to deploy for your own use\\.\n\n/help\\- Displays this help message\\.`,
|
||||
{
|
||||
parse_mode: "MarkdownV2",
|
||||
reply_parameters: { message_id: ctx.msg.message_id }
|
||||
}
|
||||
);
|
||||
}
|
||||
// // Checks if the chat is in the whitelist.
|
||||
// if (flag) {
|
||||
// // Responds with the command list.
|
||||
// return await ctx.reply(
|
||||
// `**Here are the available commands you can use:**\n\n/getGroupID _ADMIN ONLY_ \\- Replies with the ID of the group I am in\\.\n\n/isWKCGRoup _ADMIN ONLY_ \\- Checks if this group's ID is on the whitelist and responds accordingly\\.\n\n/botInfo _Private Command_\\- Info about me and how to fork me to deploy for your own use\\.\n\n/help\\- Displays this help message\\.`,
|
||||
// {
|
||||
// parse_mode: "MarkdownV2",
|
||||
// reply_parameters: { message_id: ctx.msg.message_id }
|
||||
// }
|
||||
// );
|
||||
// }
|
||||
|
||||
// Checks if the chat is not in the whitelist.
|
||||
if (!flag) {
|
||||
await ctx
|
||||
// Responds with the command list with a warning that the available commands are limited.
|
||||
.reply(
|
||||
`**Since this is not a whitelisted group the features are limited\\!\\!**\n\nHere are the available commands you can use:\n\n/isWKCGRoup _ADMIN ONLY_\\- Checks if this group's ID is on the whitelist and responds accordingly\\.\n\n/botInfo _Private Command_\\- Info about me and how to fork me to deploy for your own use\\.\n\n/help \\- Displays this help message\\.`,
|
||||
{
|
||||
parse_mode: "MarkdownV2",
|
||||
reply_parameters: { message_id: ctx.msg.message_id }
|
||||
}
|
||||
)
|
||||
.then(() => {});
|
||||
// Sends a follow-up message with information about the bot.
|
||||
return await ctx.reply(
|
||||
`This group is NOT in the whitelisted and is NOT a part of the WKC Telegram groups/communities\\. I am a bot designed to delete any Twitter/X and Meta links along with corresponding reformatting services within whitelisted groups\\. You can fork me from this link: https://github\\.com/lucid\\-creations\\-media/no\\-twitter\\-bot and deploy me for use in your own groups\\!`,
|
||||
{
|
||||
parse_mode: "MarkdownV2",
|
||||
reply_parameters: { message_id: ctx.msg.message_id }
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
// Checks if the chat is not in the whitelist.
|
||||
// if (!flag) {
|
||||
// await ctx
|
||||
// // Responds with the command list with a warning that the available commands are limited.
|
||||
// .reply(
|
||||
// `**Since this is not a whitelisted group the features are limited\\!\\!**\n\nHere are the available commands you can use:\n\n/isWKCGRoup _ADMIN ONLY_\\- Checks if this group's ID is on the whitelist and responds accordingly\\.\n\n/botInfo _Private Command_\\- Info about me and how to fork me to deploy for your own use\\.\n\n/help \\- Displays this help message\\.`,
|
||||
// {
|
||||
// parse_mode: "MarkdownV2",
|
||||
// reply_parameters: { message_id: ctx.msg.message_id }
|
||||
// }
|
||||
// )
|
||||
// .then(() => {});
|
||||
// // Sends a follow-up message with information about the bot.
|
||||
// return await ctx.reply(
|
||||
// `This group is NOT in the whitelisted and is NOT a part of the WKC Telegram groups/communities\\. I am a bot designed to delete any Twitter/X and Meta links along with corresponding reformatting services within whitelisted groups\\. You can fork me from this link: https://github\\.com/lucid\\-creations\\-media/no\\-twitter\\-bot and deploy me for use in your own groups\\!`,
|
||||
// {
|
||||
// parse_mode: "MarkdownV2",
|
||||
// reply_parameters: { message_id: ctx.msg.message_id }
|
||||
// }
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
// Checks if the whitelist is not set up.
|
||||
if (!GROUP_IDS) {
|
||||
// Sends a warning that the whitelist is not set up or the bot cannot access it.
|
||||
return await ctx.reply(
|
||||
`There was a problem retrieving the whitelist\\. Check the env variables and try again\\.`,
|
||||
{
|
||||
parse_mode: "MarkdownV2",
|
||||
reply_parameters: { message_id: ctx.msg.message_id }
|
||||
}
|
||||
);
|
||||
}
|
||||
// if (!GROUP_IDS) {
|
||||
// // Sends a warning that the whitelist is not set up or the bot cannot access it.
|
||||
// return await ctx.reply(
|
||||
// `There was a problem retrieving the whitelist\\. Check the env variables and try again\\.`,
|
||||
// {
|
||||
// parse_mode: "MarkdownV2",
|
||||
// reply_parameters: { message_id: ctx.msg.message_id }
|
||||
// }
|
||||
// );
|
||||
// }
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@ const feature = composer.chatType(["group", "supergroup"]);
|
||||
* What triggers this feature and adds to the log when it has been triggered.
|
||||
* The trigger is the command "/isWKCGroup"
|
||||
*/
|
||||
feature.hears(
|
||||
"/isWKCGroup",
|
||||
feature.command(
|
||||
"isWKCGroup",
|
||||
logHandle("is-WKC-group"),
|
||||
async (ctx: Context) => {
|
||||
// Pulling the group IDs from the env variables.
|
||||
|
||||
@@ -21,35 +21,46 @@ feature.hears(
|
||||
: undefined;
|
||||
|
||||
if (ctx.chat && ctx.msg) {
|
||||
if (GROUP_IDS !== undefined) {
|
||||
// Checking if the message is from a whitelisted group.
|
||||
const groupID = ctx.chat.id;
|
||||
const flag = GROUP_IDS.includes(`${groupID}`);
|
||||
const username = ctx.msg.from?.username;
|
||||
|
||||
if (flag) {
|
||||
// Deletes the offending message.
|
||||
ctx.msg.delete();
|
||||
// Replies to the user informing them of the action.
|
||||
return await ctx.reply(
|
||||
`@${username} Facebook and meta links along with with links to meta\\-owned services are not allowed here\\. Please consider sharing the media directly or from other social media sources or websites\\. No administration action was taken against you other than the message being deleted\\.`,
|
||||
{ parse_mode: "MarkdownV2" }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// If the env variables are misconfigured an error is sent to the group.
|
||||
if (!GROUP_IDS) {
|
||||
console.info("Group IDS:", process.env.GROUP_IDS);
|
||||
return await ctx.reply(
|
||||
`There was a problem retrieving the whitelist\\. Check the env variables and try again\\.`,
|
||||
{
|
||||
parse_mode: "MarkdownV2",
|
||||
reply_parameters: { message_id: ctx.msg.message_id }
|
||||
}
|
||||
);
|
||||
}
|
||||
const username = ctx.msg.from?.username;
|
||||
// Deletes the offending message.
|
||||
ctx.msg.delete();
|
||||
// Replies to the user informing them of the action.
|
||||
return await ctx.reply(
|
||||
`@${username} Facebook and meta links along with with links to meta\\-owned services are not allowed here\\. Please consider sharing the media directly or from other social media sources or websites\\. No administration action was taken against you other than the message being deleted\\.`,
|
||||
{ parse_mode: "MarkdownV2" }
|
||||
);
|
||||
}
|
||||
|
||||
// if (ctx.chat && ctx.msg) {
|
||||
// if (GROUP_IDS !== undefined) {
|
||||
// // Checking if the message is from a whitelisted group.
|
||||
// const groupID = ctx.chat.id;
|
||||
// const flag = GROUP_IDS.includes(`${groupID}`);
|
||||
// const username = ctx.msg.from?.username;
|
||||
|
||||
// if (flag) {
|
||||
// // Deletes the offending message.
|
||||
// ctx.msg.delete();
|
||||
// // Replies to the user informing them of the action.
|
||||
// return await ctx.reply(
|
||||
// `@${username} Facebook and meta links along with with links to meta\\-owned services are not allowed here\\. Please consider sharing the media directly or from other social media sources or websites\\. No administration action was taken against you other than the message being deleted\\.`,
|
||||
// { parse_mode: "MarkdownV2" }
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
// // If the env variables are misconfigured an error is sent to the group.
|
||||
// if (!GROUP_IDS) {
|
||||
// console.info("Group IDS:", process.env.GROUP_IDS);
|
||||
// return await ctx.reply(
|
||||
// `There was a problem retrieving the whitelist\\. Check the env variables and try again\\.`,
|
||||
// {
|
||||
// parse_mode: "MarkdownV2",
|
||||
// reply_parameters: { message_id: ctx.msg.message_id }
|
||||
// }
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -21,40 +21,51 @@ feature.hears(
|
||||
: undefined;
|
||||
|
||||
if (ctx.chat && ctx.msg) {
|
||||
if (GROUP_IDS !== undefined) {
|
||||
// Checking if the message is from a whitelisted group.
|
||||
const groupID = ctx.chat.id;
|
||||
const flag = GROUP_IDS.includes(`${groupID}`);
|
||||
const username = ctx.msg.from?.username;
|
||||
|
||||
if (flag) {
|
||||
// Deletes the offending message.
|
||||
ctx.msg.delete();
|
||||
// Replies to the user informing them of the action.
|
||||
return await ctx.reply(
|
||||
`@${username} Twitter and X links along with reformatting services for Twitter posts are not allowed here\\. Please consider sharing the media directly or from other social media sources or websites\\. No administration action was taken against you other than the message being deleted\\.`,
|
||||
{ parse_mode: "MarkdownV2" }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// If the env variables are misconfigured an error is sent to the group.
|
||||
if (!GROUP_IDS) {
|
||||
console.info(
|
||||
"Group IDS:",
|
||||
process.env.GROUP_IDS,
|
||||
GROUP_IDS,
|
||||
GROUP_IDS !== undefined
|
||||
);
|
||||
return await ctx.reply(
|
||||
`There was a problem retrieving the whitelist\\. Check the env variables and try again\\.`,
|
||||
{
|
||||
parse_mode: "MarkdownV2",
|
||||
reply_parameters: { message_id: ctx.msg.message_id }
|
||||
}
|
||||
);
|
||||
}
|
||||
const username = ctx.msg.from?.username;
|
||||
// Deletes the offending message.
|
||||
ctx.msg.delete();
|
||||
// Replies to the user informing them of the action.
|
||||
return await ctx.reply(
|
||||
`@${username} Twitter and X links along with reformatting services for Twitter posts are not allowed here\\. Please consider sharing the media directly or from other social media sources or websites\\. No administration action was taken against you other than the message being deleted\\.`,
|
||||
{ parse_mode: "MarkdownV2" }
|
||||
);
|
||||
}
|
||||
|
||||
// if (ctx.chat && ctx.msg) {
|
||||
// if (GROUP_IDS !== undefined) {
|
||||
// // Checking if the message is from a whitelisted group.
|
||||
// const groupID = ctx.chat.id;
|
||||
// const flag = GROUP_IDS.includes(`${groupID}`);
|
||||
// const username = ctx.msg.from?.username;
|
||||
|
||||
// if (flag) {
|
||||
// // Deletes the offending message.
|
||||
// ctx.msg.delete();
|
||||
// // Replies to the user informing them of the action.
|
||||
// return await ctx.reply(
|
||||
// `@${username} Twitter and X links along with reformatting services for Twitter posts are not allowed here\\. Please consider sharing the media directly or from other social media sources or websites\\. No administration action was taken against you other than the message being deleted\\.`,
|
||||
// { parse_mode: "MarkdownV2" }
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
// // If the env variables are misconfigured an error is sent to the group.
|
||||
// if (!GROUP_IDS) {
|
||||
// console.info(
|
||||
// "Group IDS:",
|
||||
// process.env.GROUP_IDS,
|
||||
// GROUP_IDS,
|
||||
// GROUP_IDS !== undefined
|
||||
// );
|
||||
// return await ctx.reply(
|
||||
// `There was a problem retrieving the whitelist\\. Check the env variables and try again\\.`,
|
||||
// {
|
||||
// parse_mode: "MarkdownV2",
|
||||
// reply_parameters: { message_id: ctx.msg.message_id }
|
||||
// }
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ const feature = composer.chatType("private");
|
||||
feature.command("start", logHandle("command-start"), ctx => {
|
||||
// Responds with information about the bot.
|
||||
return ctx.reply(
|
||||
`Welcome\\! I am a bot created by Lucid for [Werewolf Kid Creations Media groups\\.](https://community.lucidcreations.media/) I am designed to delete any Twitter/X and Meta links along with corresponding reformatting services within the WKC groups\\. I now check embedded links\\! By default I only work with whitelisted group IDs\\. You can fork me from this link: https://github\\.com/lucid\\-creations\\-media/no\\-twitter\\-bot and deploy me for use in your own groups\\!\n\nLucid would consider hosting this bot for public use if crowd\\-funding would cover the hosting cost of the bot\\. Reach out if you would like to help\\.`,
|
||||
`Welcome\\! I am a bot created by Lucid for [Werewolf Kid Creations](https://werewolfkid.monster/) I am designed to delete any Twitter/X and Meta links along with corresponding reformatting services within groups\\. I now check embedded links\\! I am currently in a public beta mode\\! I require no configuration\\. Simply add me to a group and I should start deleting any Twitter\\/X and Meta links I detect\\.`,
|
||||
{ parse_mode: "MarkdownV2" }
|
||||
);
|
||||
});
|
||||
|
||||
@@ -71,8 +71,8 @@ export function createBot(
|
||||
|
||||
// Commands
|
||||
protectedBot.use(botInfoCommand);
|
||||
protectedBot.use(getGroupIDCommand);
|
||||
protectedBot.use(isWKCGroup);
|
||||
// protectedBot.use(getGroupIDCommand);
|
||||
// protectedBot.use(isWKCGroup);
|
||||
protectedBot.use(helpCommand);
|
||||
|
||||
// Blacklist Feature
|
||||
|
||||
38
src/main.ts
38
src/main.ts
@@ -64,21 +64,31 @@ async function startWebhook(config: WebhookConfig) {
|
||||
// to prevent receiving updates before the bot is ready
|
||||
await bot.init();
|
||||
|
||||
// start server
|
||||
const info = await serverManager.start();
|
||||
logger.info({
|
||||
msg: "Server started",
|
||||
url: info.url
|
||||
});
|
||||
const setWebhook = async (): Promise<void> => {
|
||||
// set webhook
|
||||
return await bot.api
|
||||
.setWebhook(config.botWebhook, {
|
||||
allowed_updates: config.botAllowedUpdates,
|
||||
secret_token: config.botWebhookSecret
|
||||
})
|
||||
.then(() => {
|
||||
logger.info({
|
||||
msg: "Webhook was set",
|
||||
url: config.botWebhook
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// set webhook
|
||||
await bot.api.setWebhook(config.botWebhook, {
|
||||
allowed_updates: config.botAllowedUpdates,
|
||||
secret_token: config.botWebhookSecret
|
||||
});
|
||||
logger.info({
|
||||
msg: "Webhook was set",
|
||||
url: config.botWebhook
|
||||
// start server
|
||||
const info = await serverManager.start().then(async info => {
|
||||
logger.info({
|
||||
msg: "Server started",
|
||||
url: info.url
|
||||
});
|
||||
|
||||
setTimeout(async () => {
|
||||
await setWebhook();
|
||||
}, 10000);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user