Skip to content

add some plugins i wrote #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
Binary file added plugins/.DS_Store
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You accidentally committed two macOS files

Binary file not shown.
20 changes: 20 additions & 0 deletions plugins/adminonly.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Author: Mrs Feathers ([email protected])
* Description: This example modual defines a command that is restricted to the staff.
* Originally created for Furry Refuge (https://furryrefuge.com).
*
* License: This work is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License.
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/4.0/.
* Under this license, you are free to share and adapt this work for any non-commercial purpose,
* provided you give appropriate credit to the original author.
*/

'use strict';
const { Composer } = require("telegraf");

const adminCommand = (...args) =>
C.optional(
ctx => ctx.state.isMaster || ctx.state.isAdmin,
C.command(...args))

module.exports = adminCommand('adminonly', C.reply('Hello, This command only works for Furry Refuge staff.'));
28 changes: 28 additions & 0 deletions plugins/banfiles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Author: Mrs Feathers ([email protected])
* Description: This modual warns (but doesnt ban) users who upload forbidden files.
* Originally created for Furry Refuge (https://furryrefuge.com).
*
* License: This work is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License.
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/4.0/.
* Under this license, you are free to share and adapt this work for any non-commercial purpose,
* provided you give appropriate credit to the original author.
*/

'use strict';
const { Composer } = require("telegraf");

const blacklisted_files = ['apk', 'exe', 'scr', 'bat', 'cmd', 'vbs', 'pif'];

module.exports = Composer.mount('document', (ctx, next) =>
ctx.from.status !== 'admin' &&
blacklisted_files.includes(
ctx.message.document.file_name.split('.').pop())
? Promise.all([
ctx.warn({
admin: ctx.botInfo,
reason: 'Blacklisted file.',
userToWarn: ctx.from
}),
ctx.deleteMessage()])
: next());
26 changes: 26 additions & 0 deletions plugins/bansay.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* Author: Mrs Feathers ([email protected])
* Description: Shows a reason why a user was banned if they try to message the bot.
* Originally created for Furry Refuge (https://furryrefuge.com).
*
* License: This work is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License.
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/4.0/.
* Under this license, you are free to share and adapt this work for any non-commercial purpose,
* provided you give appropriate credit to the original author.
*/

'use strict';
const { getUser, verifyCaptcha } = require('../stores/user');
const { Composer } = require('telegraf');
const { logError } = require('../utils/log');
const { lrm } = require('../utils/html');
const { telegram } = require('../bot');
const { config } = require("../utils/config");

module.exports = Composer.on('message', async (ctx, next) => {
const user = await getUser(ctx.from.id);
if (user && user.status === 'banned') {
return ctx.reply(`You were banned for the following reason: ${user.banReason}`);
}
return next();
});
35 changes: 35 additions & 0 deletions plugins/dice.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* Author: Mrs Feathers ([email protected])
* Description: Super quick dice roller.
* Originally created for Furry Refuge (https://furryrefuge.com).
*
* License: This work is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License.
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/4.0/.
* Under this license, you are free to share and adapt this work for any non-commercial purpose,
* provided you give appropriate credit to the original author.
*/

'use strict';
const { Composer } = require("telegraf");

module.exports = Composer.command('roll', (ctx, next) => {
const command = ctx.message.text.trim().split(' ');
if (command.length !== 2 || !/^(\d+)d(\d+)$/.test(command[1])) {
return ctx.reply('Invalid command. Use /roll NdM, where N is the number of dice and M is the number of sides.');
}
const [dice, sides] = command[1].split('d').map(Number);
if (dice > 10) {
return ctx.reply('Cannot roll more than 10 dice at once.');
}
let result = 0;
let rolls = [];
for (let i = 0; i < dice; i++) {
let roll = Math.floor(Math.random() * sides) + 1;
rolls.push(roll);
result += roll;
}
return ctx.reply(`You rolled ${rolls.join(' + ')} for a total of ${result}`);
});



16 changes: 16 additions & 0 deletions plugins/discord.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Author: Mrs Feathers ([email protected])
* Description: Let people know you have a discord. could also be used for other informations.
* Originally created for Furry Refuge (https://furryrefuge.com).
*
* License: This work is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License.
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/4.0/.
* Under this license, you are free to share and adapt this work for any non-commercial purpose,
* provided you give appropriate credit to the original author.
*/

'use strict';
const { Composer } = require("telegraf");

module.exports = Composer.command('discord', (ctx, next) =>
ctx.reply('Our Discord voice chat is located at http://discord.furryrefuge.com'));
25 changes: 25 additions & 0 deletions plugins/hamstatus.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Author: Mrs Feathers ([email protected])
* Description: Show HAM radio status
* Originally created for Furry Refuge (https://furryrefuge.com).
*
* License: This work is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License.
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/4.0/.
* Under this license, you are free to share and adapt this work for any non-commercial purpose,
* provided you give appropriate credit to the original author.
*/

'use strict';
const { Composer } = require("telegraf");

const axios = require('axios');
const { Readable } = require('stream');

module.exports = Composer.command('ham', async (ctx, next) => {
const response = await axios.get('https://www.hamqsl.com/solar101vhf.php', { responseType: 'arraybuffer' });
const buffer = Buffer.from(response.data, 'binary');
const stream = new Readable();
stream.push(buffer);
stream.push(null);
await ctx.replyWithPhoto({ source: stream });
});
68 changes: 68 additions & 0 deletions plugins/ids.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/**
* Author: Mrs Feathers ([email protected])
* Description: get user id from a message or reply. use -g switch for group info.
* Originally created for Furry Refuge (https://furryrefuge.com).
*
* License: This work is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License.
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/4.0/.
* Under this license, you are free to share and adapt this work for any non-commercial purpose,
* provided you give appropriate credit to the original author.
*/

'use strict';
const { Composer } = require("telegraf");

module.exports = Composer.command('getid', (ctx, next) => {
const args = ctx.message.text.split(' ');
const includeGroupInfo = args.length > 1 && (args[1] === '-g' || args[1] === '-G');

if (ctx.from.status !== 'admin') {
return ctx.reply('Admin only');
}

let userId, firstName, lastName, userName, isBot, chatId, chatName, forwardDate;

if (ctx.message.reply_to_message && ctx.message.reply_to_message.forward_from) {
userId = ctx.message.reply_to_message.forward_from.id;
firstName = ctx.message.reply_to_message.forward_from.first_name;
lastName = ctx.message.reply_to_message.forward_from.last_name;
userName = ctx.message.reply_to_message.forward_from.username || '-No Username-';
isBot = ctx.message.reply_to_message.forward_from.is_bot;
if (includeGroupInfo) {
chatId = ctx.message.reply_to_message.chat.id;
chatName = ctx.message.reply_to_message.chat.title;
}
forwardDate = new Date(ctx.message.reply_to_message.forward_date * 1000).toUTCString();
} else if (ctx.message.reply_to_message) {
userId = ctx.message.reply_to_message.from.id;
firstName = ctx.message.reply_to_message.from.first_name;
lastName = ctx.message.reply_to_message.from.last_name;
userName = ctx.message.reply_to_message.from.username || '-No Username-';
isBot = ctx.message.reply_to_message.from.is_bot;
if (includeGroupInfo) {
chatId = ctx.message.reply_to_message.chat.id;
chatName = ctx.message.reply_to_message.chat.title;
}
} else {
userId = ctx.from.id;
firstName = ctx.from.first_name;
lastName = ctx.from.last_name;
userName = ctx.from.username || '-No Username-';
isBot = ctx.from.is_bot;
if (includeGroupInfo) {
chatId = ctx.chat.id;
chatName = ctx.chat.title;
}
}

let replyText = `👤 User Info:\n├ id: ${userId}\n├ first_name: ${firstName}\n├ last_name: ${lastName}\n├ username: ${userName}\n└ is_bot: ${isBot}`;
if (includeGroupInfo) {
replyText += `\n\n👥 Group Info:\n├ id: ${chatId}\n└ group_name: ${chatName}`;
}
if (forwardDate) {
replyText += `\n\n⏳ Other Info:\n└forward_date: ${forwardDate}`;
}
return ctx.reply(replyText);
});


22 changes: 22 additions & 0 deletions plugins/me.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Author: Mrs Feathers ([email protected])
* Description: Super basic roleplay command
* Originally created for Furry Refuge (https://furryrefuge.com).
*
* License: This work is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License.
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/4.0/.
* Under this license, you are free to share and adapt this work for any non-commercial purpose,
* provided you give appropriate credit to the original author.
*/

'use strict';
const { Composer } = require("telegraf");

module.exports = Composer.command('me', async (ctx) => {
const text = ctx.message.text.split(' ').slice(1).join(' ');
if (ctx.message.reply_to_message) {
await ctx.reply(`*${ctx.from.first_name} ${text}*`, { parse_mode: 'Markdown', reply_to_message_id: ctx.message.reply_to_message.message_id });
} else {
await ctx.reply(`*${ctx.from.first_name} ${text}*`, { parse_mode: 'Markdown' });
}
});
41 changes: 41 additions & 0 deletions plugins/morse.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* Author: Mrs Feathers ([email protected])
* Description: Morse code encoder and decoder.
* Originally created for Furry Refuge (https://furryrefuge.com).
*
* License: This work is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License.
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/4.0/.
* Under this license, you are free to share and adapt this work for any non-commercial purpose,
* provided you give appropriate credit to the original author.
*/

'use strict';
const { Composer } = require("telegraf");
const morse = require('./morse.json');

module.exports = Composer.command('morse', (ctx) => {
const input = ctx.message.text.split(' ');
const command = input[1];
const message = input.slice(2).join(' ');

if (command === 'enc') {
let encryptedMessage = '';
for (let i = 0; i < message.length; i++) {
encryptedMessage += morse[message[i].toUpperCase()] + ' ';
}
ctx.reply(encryptedMessage);
} else if (command === 'dec') {
let decryptedMessage = '';
const morseCode = message.split(/ {3,}/); // Any number of spaces more than 2 indicate a new word in Morse code
for (let i = 0; i < morseCode.length; i++) {
const word = morseCode[i].split(' '); // One space indicates a new letter in Morse code
for (let j = 0; j < word.length; j++) {
decryptedMessage += Object.keys(morse).find(key => morse[key] === word[j]);
}
decryptedMessage += ' '; // Add a space after each word
}
ctx.reply(decryptedMessage);
} else {
ctx.reply('Usage: /morse enc [message] to encrypt, /morse dec [message] to decrypt');
}
});
66 changes: 66 additions & 0 deletions plugins/morse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
//currently configured for USA Morse
{
"A": ".-",
"B": "-...",
"C": "-.-.",
"D": "-..",
"E": ".",
"F": "..-.",
"G": "--.",
"H": "....",
"I": "..",
"J": ".---",
"K": "-.-",
"L": ".-..",
"M": "--",
"N": "-.",
"O": "---",
"P": ".--.",
"Q": "--.-",
"R": ".-.",
"S": "...",
"T": "-",
"U": "..-",
"V": "...-",
"W": ".--",
"X": "-..-",
"Y": "-.--",
"Z": "--..",
"1": ".----",
"2": "..---",
"3": "...--",
"4": "....-",
"5": ".....",
"6": "-....",
"7": "--...",
"8": "---..",
"9": "----.",
"0": "-----",
" ": " ",
".": ".-.-.-",
",": "--..--",
"?": "..--..",
"'": ".----.",
"!": "-.-.--",
"/": "-..-.",
"(": "-.--.",
")": "-.--.-",
"&": ".-...",
":": "---...",
";": "-.-.-.",
"=": "-...-",
"+": ".-.-.",
"-": "-....-",
"\"": ".-..-.",
"@": ".--.-.",
"Ä": ".-.-",
"Å": ".-.-",
"Ą": ".-.-",
"Æ": ".-.-",
"É": "..-..",
"Ñ": "--.--",
"Ö": "---.",
"Ü": "..--",
"Š": "----",
" ": " "
}
21 changes: 21 additions & 0 deletions plugins/ping.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Author: Mrs Feathers ([email protected])
* Description: A Classic.
* Originally created for Furry Refuge (https://furryrefuge.com).
*
* License: This work is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License.
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/4.0/.
* Under this license, you are free to share and adapt this work for any non-commercial purpose,
* provided you give appropriate credit to the original author.
*/

'use strict';
const { Composer } = require("telegraf");

module.exports = Composer.command('ping', async (ctx, next) => {
const start = new Date();
await ctx.reply('Pong!');
const end = new Date();
const ms = end - start;
await ctx.reply(`Response time: ${ms} ms`);
});
Loading