Compare commits
15 Commits
5c5718bc1c
...
main
Author | SHA1 | Date | |
---|---|---|---|
2ca39208d9 | |||
7cf9689420 | |||
1d5c29564f | |||
e3a5f1a67b | |||
7ea30c8c71 | |||
cd374090f2 | |||
|
8274ab0980 | ||
3177a1a444 | |||
80a0dbd2d3 | |||
04268d9e22 | |||
41ae943913 | |||
579bf67576 | |||
bdf52331b1 | |||
63dbcba4d8 | |||
5ededd535f |
@@ -13,4 +13,6 @@ roleplay gifs. Once you have an instance of Ugoki (and optionally
|
||||
- `export BOT_API_KEY="your-token-for-bot"`
|
||||
- `export FEEDBACK_ID="chat-id-where-feedback-is-forwarded-to"`
|
||||
- `export UGOKI_ROOT="https://root.of.ugoki.api/server/"`
|
||||
- `export RATE_TIMEFRAME=5000 # rate limit time interval in milliseconds`
|
||||
- `export RATE_LIMIT=5 # number of requests allowed in the timeframe`
|
||||
- `npm start`
|
||||
|
9
bot.js
9
bot.js
@@ -1,12 +1,19 @@
|
||||
const { Telegraf } = require("telegraf");
|
||||
const { BOT_API_KEY, FEEDBACK_ID, UGOKI_ROOT } = process.env;
|
||||
const { BOT_API_KEY, FEEDBACK_ID, UGOKI_ROOT, RATE_TIMEFRAME, RATE_LIMIT } = process.env;
|
||||
const fs = require("fs").promises;
|
||||
const commands = require("./commands");
|
||||
const axios = require("axios");
|
||||
const roleplay = require("./static/roleplay.json");
|
||||
const { limit } = require("@grammyjs/ratelimiter");
|
||||
|
||||
const bot = new Telegraf(BOT_API_KEY);
|
||||
bot.catch((err) => console.log(err));
|
||||
bot.use(limit({
|
||||
// default config: 1 message per 1 second
|
||||
timeFrame: RATE_TIMEFRAME ?? 1000,
|
||||
limit: RATE_LIMIT ?? 1,
|
||||
keyGenerator: (ctx) => ctx.chat?.id.toString() ?? ctx.from?.id.toString(),
|
||||
}))
|
||||
|
||||
const data = [
|
||||
"questions",
|
||||
|
@@ -1,14 +1,27 @@
|
||||
module.exports = (feedback_id) => (ctx) => {
|
||||
module.exports = (bot, feedback_id) => (ctx) => {
|
||||
|
||||
const message = ctx.message.text.replace(/^[^ ]+/, "");
|
||||
if (message) {
|
||||
|
||||
ctx.forwardMessage(feedback_id);
|
||||
return "Thanks for the feedback";
|
||||
const from = ctx.message.from;
|
||||
let contactable = "The developer might contact you regarding your feedback.";
|
||||
let message;
|
||||
if (from.username) {
|
||||
|
||||
message = `Feedback from: @${from.username}`;
|
||||
|
||||
} else {
|
||||
|
||||
return "To send feedback type in /feedback followed by the feedback";
|
||||
contactable = "The developer might not be able to contact you due to lack of your username.";
|
||||
message = `Feedback from User ${from.id}`;
|
||||
|
||||
}
|
||||
bot.telegram.sendMessage(feedback_id, `${message} ${ctx.message.text}`).catch(console.log);
|
||||
return `Thanks for the feedback! ${contactable}`;
|
||||
|
||||
} else {
|
||||
|
||||
return "To send feedback type in /feedback followed by the feedback. Note that developers may contact you regarding the feedback.";
|
||||
|
||||
}
|
||||
|
||||
|
@@ -21,7 +21,7 @@ module.exports = (bot, [ questions, kys, insults, commands_list, words, roleplay
|
||||
.then(bot_user => {
|
||||
|
||||
const default_text = (command, text) => `Do you want to ${text} `
|
||||
+ `yourself?\nIf no, reply to someone with /${command} to kill`
|
||||
+ `yourself?\nIf no, reply to someone with /${command} to ${command}`
|
||||
+ ` them or run /${command} username/name.\nYou can suggest `
|
||||
+ `more /${command} replies using /feedback`;
|
||||
|
||||
@@ -55,7 +55,7 @@ module.exports = (bot, [ questions, kys, insults, commands_list, words, roleplay
|
||||
"Markdown"}));
|
||||
bot.command("weebify", (ctx) => ctx.reply(weebify()(ctx)));
|
||||
bot.command("absurdify", (ctx) => ctx.reply(absurdify()(ctx)));
|
||||
bot.command("feedback", (ctx) => ctx.reply(feedback(feedback_id)(ctx)));
|
||||
bot.command("feedback", (ctx) => ctx.reply(feedback(bot, feedback_id)(ctx)));
|
||||
bot.command("wiki", (ctx) => media_wiki(axios,
|
||||
"https://en.wikipedia.org/w/api.php")(ctx).then(x => ctx.reply(x,
|
||||
{parse_mode: "HTML"})));
|
||||
@@ -65,9 +65,6 @@ module.exports = (bot, [ questions, kys, insults, commands_list, words, roleplay
|
||||
bot.command("info", (ctx) => ctx.reply(info()(ctx), {parse_mode: "Markdown"}));
|
||||
bot.command("expand", (ctx) => ctx.reply(expand(words)(ctx)));
|
||||
bot.command("start", (ctx) => ctx.reply("Hi! I'm Octanite. Sibling of @quadnite_bot. My creator @ceda_ei created me as 'another option' to users who want the bot in their groups to have privacy mode enabled. \n\nPrivacy mode? Wut is that?\n- Well basically disabling privacy mode enables a bot to read all the messages. @quadnite_bot has that disabled. Enabling privacy mode causes the bot to not recieve messages at some times. To circumvet that, you need to append @octanite_bot to your commands or simply use @quadnite_bot. \n\n[P.S. - My creator doesn't store any messages or personal data. It's safe to use any of the two bots.]\nTo give feedback, use /feedback"));
|
||||
bot.command("donate", (ctx) => ctx.reply("Thanks for considering to donate."
|
||||
+ " To support the development and hosting of Quadnite Bot, you can "
|
||||
+ "donate here: https://liberapay.com/ceda_ei/"));
|
||||
bot.hears(/^\/?(\d*)d(\d+)(@\w+)?(\s*([-+])\s*(\d+))?$/i, dice());
|
||||
|
||||
function getGetGif(command) {
|
||||
|
@@ -38,7 +38,7 @@ module.exports = (forms, getGif) => (ctx) => {
|
||||
reply = forms.none
|
||||
.replace("{}", user);
|
||||
|
||||
getGif()
|
||||
return getGif()
|
||||
.then(gif => ctx.replyWithAnimation(gif.data.url, {caption: reply}));
|
||||
|
||||
};
|
||||
|
11
package-lock.json
generated
11
package-lock.json
generated
@@ -9,12 +9,18 @@
|
||||
"version": "2.0.0",
|
||||
"license": "GPL-3.0",
|
||||
"dependencies": {
|
||||
"@grammyjs/ratelimiter": "^1.2.0",
|
||||
"axios": "^0.21.0",
|
||||
"fluent-ffmpeg": "^2.1.2",
|
||||
"form-data": "^4.0.0",
|
||||
"telegraf": "^4.15.3"
|
||||
}
|
||||
},
|
||||
"node_modules/@grammyjs/ratelimiter": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@grammyjs/ratelimiter/-/ratelimiter-1.2.0.tgz",
|
||||
"integrity": "sha512-xBkH/ATJsuv5JgVYX9yQM9DNg75Qqjw+gh82lVsBn4j+d0DkxxC+kuy6WFoB96Cb6oifQfaBJL8CTikdYG4v0A=="
|
||||
},
|
||||
"node_modules/@telegraf/types": {
|
||||
"version": "6.9.1",
|
||||
"resolved": "https://registry.npmjs.org/@telegraf/types/-/types-6.9.1.tgz",
|
||||
@@ -288,6 +294,11 @@
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@grammyjs/ratelimiter": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@grammyjs/ratelimiter/-/ratelimiter-1.2.0.tgz",
|
||||
"integrity": "sha512-xBkH/ATJsuv5JgVYX9yQM9DNg75Qqjw+gh82lVsBn4j+d0DkxxC+kuy6WFoB96Cb6oifQfaBJL8CTikdYG4v0A=="
|
||||
},
|
||||
"@telegraf/types": {
|
||||
"version": "6.9.1",
|
||||
"resolved": "https://registry.npmjs.org/@telegraf/types/-/types-6.9.1.tgz",
|
||||
|
@@ -22,6 +22,7 @@
|
||||
},
|
||||
"homepage": "https://gitlab.com/ceda_ei/Quadnite-Bot#readme",
|
||||
"dependencies": {
|
||||
"@grammyjs/ratelimiter": "^1.2.0",
|
||||
"axios": "^0.21.0",
|
||||
"fluent-ffmpeg": "^2.1.2",
|
||||
"form-data": "^4.0.0",
|
||||
|
@@ -54,10 +54,10 @@ twerk wag
|
||||
wave wink
|
||||
yes
|
||||
</code>
|
||||
<b>Miscallenous</b>
|
||||
<b>Miscellaneous</b>
|
||||
|
||||
help - Need help? Go here
|
||||
feedback - Send feedback, suggestion for kys, insult text
|
||||
feedback - Send feedback, suggestions for kys, insult text
|
||||
rate - Rate me on TGDR
|
||||
|
||||
<b>Dice</b>
|
||||
|
Reference in New Issue
Block a user