Compare commits
6 Commits
d04200742d
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
| ab43d009b0 | |||
| b18c90996e | |||
| 1f4dec517f | |||
| 1704537a13 | |||
| 69c5a106b5 | |||
| a2966b1475 |
@@ -10,7 +10,7 @@ module.exports = {
|
||||
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",
|
||||
@@ -82,5 +82,7 @@ module.exports = {
|
||||
masto: {
|
||||
url: "https://mastodong.lol",
|
||||
accessToken: process.env.MASTO_TOKEN
|
||||
}
|
||||
},
|
||||
masto_account_id: "108643271047165149",
|
||||
masto_webhook: process.env.DISCORD_WEBHOOK_FOR_MASTO
|
||||
}
|
||||
+1
-1
@@ -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;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
process.title = "lamp discord bot";
|
||||
process.on("unhandledRejection", error => {
|
||||
console.error("Unhandled Rejection:\n" + (error.stack || error));
|
||||
console.error("Unhandled Rejection:\n", error.stack || error);
|
||||
});
|
||||
|
||||
require("./util"); // global variables set in here
|
||||
|
||||
@@ -1,14 +1,38 @@
|
||||
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);
|
||||
module.exports = donger;
|
||||
var stream = await donger.stream.streamUser();
|
||||
stream.on("update", toot => {
|
||||
console.debug("toot", toot); // testing
|
||||
});
|
||||
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);
|
||||
}
|
||||
})();
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user