Compare commits
23 Commits
vrchat-hac
...
master
Author | SHA1 | Date | |
---|---|---|---|
ab43d009b0 | |||
b18c90996e | |||
1f4dec517f | |||
1704537a13 | |||
69c5a106b5 | |||
a2966b1475 | |||
d04200742d | |||
fbb082fee8 | |||
bb80d22568 | |||
721435f039 | |||
e85d88de69 | |||
a4730289a0 | |||
02be479a15 | |||
1b2df7a1cb | |||
7eb01dda9d | |||
c130ef1506 | |||
660234acfd | |||
c0470e89b6 | |||
823c398a5a | |||
9b84e4ff7c | |||
e19f11acae | |||
0fcd5f125c | |||
1316460838 |
117
commands.js
117
commands.js
@ -38,32 +38,6 @@ var commands = module.exports = [
|
||||
i.reply(owo);
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "archive",
|
||||
description: "Delete a channel without actually deleting it",
|
||||
options: [
|
||||
{
|
||||
name: "channel",
|
||||
description: "channel",
|
||||
type: "CHANNEL",
|
||||
required: true
|
||||
}
|
||||
],
|
||||
defaultPermission: false,
|
||||
permissions: [
|
||||
{
|
||||
id: config.admin_role,
|
||||
type: "ROLE",
|
||||
permission: true
|
||||
}
|
||||
],
|
||||
exec: async i => {
|
||||
let channel = i.options.getChannel("channel");
|
||||
await channel.setParent(config.archive_category);
|
||||
await channel.lockPermissions();
|
||||
await i.reply({content: channel.toString()});
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "avatar",
|
||||
description: "View a user's original avatar (and save permanently as attachment)",
|
||||
@ -123,7 +97,7 @@ var commands = module.exports = [
|
||||
exec: i => commands.find(x => x.name == "steal").exec(i)
|
||||
},
|
||||
{
|
||||
name: "setbanner",
|
||||
name: "setserverbanner",
|
||||
description: "Set the server banner image",
|
||||
options: [
|
||||
{
|
||||
@ -150,6 +124,86 @@ var commands = module.exports = [
|
||||
await i.reply(error.message);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "setservericon",
|
||||
description: "Change the server icon",
|
||||
options: [
|
||||
{
|
||||
name: "url",
|
||||
description: "HTTP(S) URL to an image",
|
||||
type: "STRING"
|
||||
}
|
||||
],
|
||||
exec: async i => {
|
||||
var url = i.options.getString("url");
|
||||
try {
|
||||
if (!url) {
|
||||
await i.guild.setIcon(null);
|
||||
await i.reply("cleared the server icon");
|
||||
} else {
|
||||
if (/^https?:\/\//i.test(url)) {
|
||||
await i.guild.setIcon(url);
|
||||
await i.reply(url);
|
||||
} else {
|
||||
await i.reply("http image url only!");
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
await i.reply(error.message);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "getemoji",
|
||||
description: "Generate a URL for an emoji",
|
||||
options: [
|
||||
{
|
||||
name: "emoji",
|
||||
description: "The emoji (code) or the name of the emoji (case-sensitive)",
|
||||
type: "STRING",
|
||||
required: true
|
||||
},
|
||||
{
|
||||
name: "format",
|
||||
description: "choose image format",
|
||||
type: "STRING",
|
||||
choices: [
|
||||
{name: "PNG", value: "png"},
|
||||
{name: "JPG", value: "jpg"},
|
||||
{name: "WEBP", value: "webp"},
|
||||
{name: "GIF", value: "gif"}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "size",
|
||||
description: "choose image size",
|
||||
type: "INTEGER",
|
||||
choices: "16,20,22,24,28,32,40,44,48,56,60,64,80,96,100,128".split(',').map(s => ({name: s, value: Number(s)}))
|
||||
}
|
||||
],
|
||||
exec: i => {
|
||||
var emojiname = i.options.getString("emoji");
|
||||
if (emojiname.startsWith('<') && emojiname.endsWith('>')) emoji = Discord.Util.parseEmoji(emojiname);
|
||||
else {
|
||||
if (emojiname.startsWith(':')) emojiname = emojiname.slice(1);
|
||||
if (emojiname.endsWith(':')) emojiname = emojiname.slice(-1);
|
||||
var emoji = client.emojis.cache.find(e => e.name == emojiname);
|
||||
if (!emoji) emoji = client.emojis.cache.find(e => e.name.toLowerCase() == emojiname.toLowerCase());
|
||||
if (!emoji) return void i.reply(`could not find emoji named ${emojiname}`);
|
||||
}
|
||||
if (!emoji.id) return void i.reply(`invalid input`);
|
||||
var qs = [];
|
||||
var size = i.options.getInteger("size");
|
||||
if (size) qs.push(`size=${size}`);
|
||||
var format = i.options.getString("format");
|
||||
if (!format) format = emoji.animated ? "gif" : "png";
|
||||
if (format == "gif" && !emoji.animated) return void i.reply(`Non-animated emoji is not available as GIF.`);
|
||||
if (format == "webp") qs.push(`quality=lossless`);
|
||||
var url = `https://media.discordapp.net/emojis/${emoji.id}.${format}`;
|
||||
if (qs.length > 0) url += '?' + qs.join('&');
|
||||
i.reply(`${emoji.name}.${format}\n${url}`);
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
@ -162,14 +216,5 @@ client.once("ready", async () => {
|
||||
let guild_commands = commands.filter(x => !x.global);
|
||||
let guild = client.guilds.resolve(config.guild);
|
||||
await guild.commands.set(guild_commands);
|
||||
await guild.commands.permissions.set({
|
||||
fullPermissions: guild_commands.map(local_command => {
|
||||
let discord_command = guild.commands.cache.find(discord_command => local_command.name == discord_command.name);
|
||||
return {
|
||||
id: discord_command.id,
|
||||
permissions: local_command.permissions || []
|
||||
}
|
||||
})
|
||||
});
|
||||
await client.application.commands.set(global_commands);
|
||||
});
|
11
config.js
11
config.js
@ -8,8 +8,9 @@ module.exports = {
|
||||
human_role: "672956630962274306",
|
||||
bot_role: "673671040010027034",
|
||||
inactive_role: "892869309603389500",
|
||||
verified_role: "949064806030254130",
|
||||
view_archived_channels_role: "916056534402863125",
|
||||
eval_undefined_emoji: "707729833601531935",
|
||||
eval_undefined_emoji: "🅱️",
|
||||
mi_emoji: "887931046086185060",
|
||||
ki_emoji: "887935846710394910",
|
||||
default_channel: "949831184957980722",
|
||||
@ -77,5 +78,11 @@ module.exports = {
|
||||
vrchat_configuration: {
|
||||
username: process.env.VRCHAT_USERNAME,
|
||||
password: process.env.VRCHAT_PASSWORD
|
||||
}
|
||||
},
|
||||
masto: {
|
||||
url: "https://mastodong.lol",
|
||||
accessToken: process.env.MASTO_TOKEN
|
||||
},
|
||||
masto_account_id: "108643271047165149",
|
||||
masto_webhook: process.env.DISCORD_WEBHOOK_FOR_MASTO
|
||||
}
|
@ -7,9 +7,12 @@ client.on("guildMemberAdd", member => {
|
||||
// add role
|
||||
member.roles.add(member.user.bot ? config.bot_role : config.human_role);
|
||||
// welcome message
|
||||
client.channels.resolve(config.default_channel)?.send(
|
||||
`Welcome ${member}. Please tell from where you entered this server and some other info about yourself in order to gain access to message history.`
|
||||
);
|
||||
/*setTimeout(() => {
|
||||
client.channels.resolve(config.default_channel)?.send(
|
||||
`Welcome ${member}. Please tell from where you entered this server and some other info about yourself in order to gain access to message history.`
|
||||
);
|
||||
}, 3000);*/
|
||||
member.roles.add(config.verified_role);
|
||||
});
|
||||
// join message
|
||||
/*client.on("messageDelete", message => {
|
||||
@ -73,4 +76,6 @@ client.on("emojiDelete", emoji => {
|
||||
content: "emoji deleted",
|
||||
files: [{attachment: emoji.url, name: `${emoji.name}.${emoji.url.split('.').pop()}`}]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
//g=setInterval(() => client.guilds.resolve(config.guild)?.setIcon(`mf/${Math.floor(Math.random()*14548)}.png`), 1800000);
|
@ -9,7 +9,7 @@ client.on("messageCreate", async function (message) {
|
||||
if (message.content.startsWith("!>")) {
|
||||
with (message) {
|
||||
try {
|
||||
var x = await eval(message.content.substr(2).trim());
|
||||
var x = await eval(message.content.substring(2).trim());
|
||||
} catch(e) {
|
||||
var x = e.message;
|
||||
}
|
||||
|
4
index.js
4
index.js
@ -1,6 +1,6 @@
|
||||
process.title = "lamp discord bot";
|
||||
process.on("unhandledRejection", error => {
|
||||
console.error("Unhandled Rejection:\n" + error.stack);
|
||||
console.error("Unhandled Rejection:\n", error.stack || error);
|
||||
});
|
||||
|
||||
require("./util"); // global variables set in here
|
||||
@ -18,4 +18,4 @@ require("./activitytracker");
|
||||
require("./vocabularygame");
|
||||
require("./pixiv-subscribe");
|
||||
require("./count-cmd");
|
||||
require("./vrchat");
|
||||
require("./masto");
|
39
masto.js
Normal file
39
masto.js
Normal file
@ -0,0 +1,39 @@
|
||||
var {login} = require("masto");
|
||||
var config = require("./config");
|
||||
var client = require("./client");
|
||||
var {WebhookClient} = require("discord.js");
|
||||
|
||||
var webhook = new WebhookClient({url: config.masto_webhook});
|
||||
module.exports.webhook = webhook;
|
||||
|
||||
client.once("ready", async () => {
|
||||
var donger = await login(config.masto);
|
||||
console.log("donger logged in");
|
||||
module.exports.donger = donger;
|
||||
(async function openStream() {
|
||||
try {
|
||||
var stream = await donger.stream.streamUser();
|
||||
module.exports.stream = stream;
|
||||
stream.on("update", toot => {
|
||||
|
||||
if (toot.account.id != config.masto_account_id) return;
|
||||
if (toot.visibility != "public") return;
|
||||
if (toot.inReplyToAccountId && toot.inReplyToAccountId != toot.account.id) return;
|
||||
|
||||
webhook.send(toot.url || toot.reblog.url); //todo maybe custom embed
|
||||
|
||||
//todo maybe handle deletes
|
||||
});
|
||||
stream.ws.on("close", () => {
|
||||
console.log("donger stream closed");
|
||||
setTimeout(openStream, 10000);
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("donger stream", error.message);
|
||||
setTimeout(openStream, 60000);
|
||||
}
|
||||
})();
|
||||
});
|
||||
|
||||
|
||||
|
661
package-lock.json
generated
661
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -8,7 +8,7 @@
|
||||
"kuroshiro": "^1.2.0",
|
||||
"kuroshiro-analyzer-kuromoji": "^1.1.0",
|
||||
"libsodium-wrappers": "^0.7.9",
|
||||
"node-fetch": "^2.6.1",
|
||||
"vrchat": "^1.6.9"
|
||||
"masto": "^4.4.0",
|
||||
"node-fetch": "^2.6.1"
|
||||
}
|
||||
}
|
||||
|
@ -17,9 +17,10 @@ async function check(tag, channel) {
|
||||
} else break;
|
||||
}
|
||||
for (let i = newPosts.length - 1; i >= 0; i--) {
|
||||
let url = `https://www.pixiv.net/en/artworks/${newPosts[i].id}`;
|
||||
await embedPixiv(
|
||||
client.channels.resolve(channel),
|
||||
[`https://www.pixiv.net/en/artworks/${newPosts[i].id}`],
|
||||
[url],
|
||||
undefined,
|
||||
true
|
||||
);
|
||||
|
71
vrchat.js
71
vrchat.js
@ -1,71 +0,0 @@
|
||||
var vrchat = require("vrchat");
|
||||
var client = require("./client");
|
||||
var config = require("./config");
|
||||
var commands = require("./commands");
|
||||
var fs = require("fs");
|
||||
|
||||
var configuration = new vrchat.Configuration(config.vrchat_configuration);
|
||||
|
||||
var authenticationApi = new vrchat.AuthenticationApi(configuration);
|
||||
authenticationApi.getCurrentUser().then(console.log);
|
||||
|
||||
var usersApi = new vrchat.UsersApi(configuration);
|
||||
|
||||
var status2icon = {
|
||||
"join me": '🔵',
|
||||
"active": '🟢',
|
||||
"ask me": '🟠',
|
||||
"busy": '🔴',
|
||||
"offline": '⚫'
|
||||
}
|
||||
|
||||
try {
|
||||
var vrcul = JSON.parse(fs.readFileSync("data/vrcul.json"), "utf8");
|
||||
} catch(error) {
|
||||
var vrcul = [];
|
||||
}
|
||||
|
||||
async function updateUserStatuses() {
|
||||
for (let {channel, userId} of vrcul) {
|
||||
try {
|
||||
channel = client.channels.resolve(channel);
|
||||
let user = (await usersApi.getUser(userId)).data;
|
||||
let status_icon = user.state == "online" ? status2icon(user.status) : '⚫';
|
||||
let nn = `${status_icon} ${user.displayName}`;
|
||||
if (nn != channel.name)
|
||||
await channel.setName(nn);
|
||||
} catch (error) {
|
||||
console.error("vrcus", error.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.interval = setInterval(updateUserStatuses, 1000*60*5);
|
||||
|
||||
commands.push({
|
||||
name: "addvru",
|
||||
description: "Add VRChat user to status monitor",
|
||||
options: [
|
||||
{
|
||||
name: "user",
|
||||
description: "User ID or username",
|
||||
type: "STRING",
|
||||
required: true
|
||||
}
|
||||
],
|
||||
exec: async i => {
|
||||
try {
|
||||
let u = i.options.getString("user");
|
||||
let user = (await usersApi[u.startsWith("usr_") ? 'getUser' : 'getUserByName'](u)).data;
|
||||
let status_icon = user.state == "online" ? status2icon(user.status) : '⚫';
|
||||
let nn = `${status_icon} ${user.displayName}`;
|
||||
let channel = await client.channels.resolve(config.vrchat_status_category).createChannel(nn);
|
||||
vrcul.push({channel: channel.id, userId: user.id});
|
||||
fs.writeFileSync("data/vrcul.json", JSON.stringify(vrcul));
|
||||
await i.reply(channel.toString());
|
||||
} catch (error) {
|
||||
i.reply(error.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user