Hi @Christian thanks for making this amazing plug-in!
I know nothing about Javascript (I know a bit of Python) but wanted to create a macro that can pull new messages from my Telegram bot and append it to my current note.
I would really appreciate any help! Hopefully others will find this macro useful too!
.js macro
'use-strict';
import { fetch } from './node_modules/node-fetch';
export async function getMsg() {
let response = await fetch('https://api.telegram.org/bot[BOT_TOKEN]/getupdates');
let data = await response.json()
let jsn = data.result
console.log(jsn)
var count = jsn.length;
for (var i = 0; i < count; i++) {
var message_item = jsn[i];
var msg_text = message_item.message.text
console.log(msg_text)
}
return data;
}
getMsg()
Error message:
The node-modules folder is in the same directory as the script
Things I’ve tried:
- Including
"type": "module";
in local package.json - Used a different import method -
var fetch = import('./node_modules/node-fetch')
andvar fetch = require('./node_modules/node-fetch')
Sorry if this is really basic, I’m completely lost when it comes to JS. Would appreciate any help!