I can get the art to display, but i can never get anything to happen from the content of the mod, i dont get the initial " fetching notes..." console log to display, it doesnt save the test file to the cache, etc.
I have created a package.json containing the misskey-js node module
I have restarted the docker.
mods/misskey/misskey.js
/* jslint node: true */
'use strict';
// Dependencies
const https = require('https');
const fs = require('fs');
const paths = require('path');
const async = require('async');
const url = require('url');
const Misskey = require('misskey.js'); // Import the Misskey library
// Create a Misskey client using your API key
const misskey = new Misskey({
apiKey: 'XXX', // Replace with your Misskey API key
apiUrl: 'https://misskey.org/api', // Replace with your Misskey API URL
});
// Define a function to fetch notes from Misskey
function fetchLatestNotes(cb) {
misskey.notes.timeline({ limit: 10 }) // You can customize the limit as needed
.then(notes => {
return cb(null, notes);
})
.catch(err => {
return cb(err);
});
}
// Define a function to download notes to a cache directory
function downloadNotesToCacheDir(cacheDir, notes, cb) {
async.each(notes, (note, next) => {
const fileName = `${note.id}.json`;
const filePath = paths.join(cacheDir, fileName);
// Check if the note is already downloaded
fs.stat(filePath, (err, stats) => {
if (err && err.code !== 'ENOENT') {
return next(err);
} else if (stats && stats.isFile()) {
return next();
}
// Download the note as JSON and save it to the cache directory
const noteData = JSON.stringify(note);
fs.writeFile(filePath, noteData, () => {
return next();
});
});
}, err => {
return cb(err);
});
}
// Define a function to display the notes on the screen
function displayNotes(notes) {
notes.forEach((note, index) => {
console.log(`Note ${index + 1}:`);
console.log(`Author: ${note.user.username}`);
console.log(`Content: ${note.text}`);
console.log('---');
});
}
exports.misskey = misskey;
// Export the Misskey module
function misskey(args, cb) {
console.log('Fetching notes...');
let cacheDir = paths.join(__dirname, './cache/');
if (args.length > 0) {
cacheDir = args[0];
}
// Specify the content for the test file
const testContent = "This is a test file.";
// Specify the file path for the test file within the cache directory
const testFilePath = path.join(cacheDir, 'test.txt');
// Create the test file
fs.writeFile(testFilePath, testContent, (err) => {
if (err) {
return cb(err);
}
// Log a message to indicate that the file has been created
console.log('Test file created.');
// Fetch Misskey notes and perform other actions here
// Call the callback to indicate that the function has completed
return cb(null);
});
// Fetch the latest notes from Misskey
fetchLatestNotes((err, notes) => {
if (err) {
return cb(err);
}
// Download the notes to the cache directory
downloadNotesToCacheDir(cacheDir, notes, err => {
if (err) {
return cb(err);
}
// Display the downloaded notes on the screen
displayNotes(notes);
return cb(null);
});
});
};
Describe the Bug
@NuSkooler I cannot get the basic "fetch married bob" mod example to work. https://github.com/NuSkooler/enigma-bbs-married_bob_evt/blob/master/married_bob_evt.js
My main menu has this entry next to all the other ones:
I can get the art to display, but i can never get anything to happen from the content of the mod, i dont get the initial " fetching notes..." console log to display, it doesnt save the test file to the cache, etc.
I have created a package.json containing the misskey-js node module I have restarted the docker.
mods/misskey/misskey.js
What am I doing wrong?
Thanks!