-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMMM-GeminiAIFact.js
46 lines (39 loc) · 1.08 KB
/
MMM-GeminiAIFact.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
Module.register("MMM-GeminiAIFact", {
defaults: {
updateInterval: 3600000, // Run the command every hour
model: "gemini-1.5-flash-8b",
geminiApiKey: "your key here"
},
start: function() {
console.log("Starting module: " + this.name);
this.getCommandOutput();
setInterval(() => {
this.getCommandOutput();
}, this.config.updateInterval);
},
getHeader: function() {
return this.header;
},
getCommandOutput: function() {
this.sendSocketNotification('RUN_COMMAND', this.config);
},
socketNotificationReceived: function(notification, payload) {
if (notification === 'COMMAND_OUTPUT') {
this.fact = payload.text;
this.header = payload.title;
this.updateDom();
}
},
getDom: function() {
const wrapper = document.createElement("div");
const AIfact = document.createElement("div");
AIfact.className = "bright";
if (this.fact) {
AIfact.innerHTML = this.fact;
} else {
AIfact.innerHTML = "Waiting for Gemini AI...";
}
wrapper.appendChild(AIfact);
return wrapper;
}
});