Feat: Add native Telegram Bot integration with Voice transcription via Whisper and Monica CRM synchronization
All checks were successful
Build & Push Friends Image to Gitea Registry / build-and-push (push) Successful in 10s

This commit is contained in:
Kroonk
2026-05-22 18:06:50 +02:00
parent 9f62eebed6
commit eccee059cf
3 changed files with 361 additions and 5 deletions

View File

@@ -3,6 +3,7 @@ import express from "express";
import fs from "node:fs/promises";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { startTelegramBot } from "./telegram.js";
dotenv.config();
@@ -228,7 +229,7 @@ app.post("/api/save", async (req, res) => {
res.json(localRecord);
});
async function monicaFetch(apiPath, options = {}) {
export async function monicaFetch(apiPath, options = {}) {
const response = await fetch(`${monicaBaseUrl}${apiPath}`, {
...options,
headers: {
@@ -249,7 +250,7 @@ async function monicaFetch(apiPath, options = {}) {
return payload;
}
async function writeToMonica(entry) {
export async function writeToMonica(entry) {
const results = [];
if (entry.journal?.enabled && entry.journal?.title && entry.journal?.post) {
@@ -297,7 +298,7 @@ async function monicaWrite(type, apiPath, body) {
}
}
function analyzeText(text, mode = "auto", contactsList = []) {
export function analyzeText(text, mode = "auto", contactsList = []) {
const normalized = text.replace(/\s+/g, " ").trim();
const contacts = mode === "journal" ? [] : inferContacts(normalized, contactsList);
const reminder = inferReminder(normalized);
@@ -519,7 +520,7 @@ function demoContacts(query) {
return contacts.filter((contact) => contact.name.toLowerCase().includes(query.toLowerCase()));
}
async function appendLocalRecord(record) {
export async function appendLocalRecord(record) {
await fs.mkdir(dataDir, { recursive: true });
const file = path.join(dataDir, "entries.json");
let entries = [];
@@ -534,10 +535,15 @@ async function appendLocalRecord(record) {
await fs.writeFile(file, JSON.stringify(entries.slice(0, 500), null, 2));
}
function cryptoRandomId() {
export function cryptoRandomId() {
return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
}
app.listen(port, () => {
console.log(`Friends listening on http://localhost:${port}`);
if (process.env.TELEGRAM_BOT_TOKEN) {
startTelegramBot();
} else {
console.log("Telegram Bot not started: TELEGRAM_BOT_TOKEN is not configured in .env");
}
});