const { getInput} = require("@actions/core") const { existsSync, readFileSync } = require("fs") const zulipInit = require("zulip-js"); // Pass the path to your zuliprc file here. const config = { username: getInput("email"), apiKey: getInput("key"), realm: getInput("url") }; console.log(config); (async () => { const client = await zulipInit(config); let content = getInput("text").split(/\\n/).join("\n"); if( getInput("type")=="file"){ const path = getInput("path") if(!existsSync(path)){ console.log("IO ERROR: can't find "+path) return } if(content&&content.trim().length){ content += "\r\n\n"; } content += readFileSync(path).toString() } console.log(content) // Send a stream message let params = { to: getInput("stream"), type: "stream", topic: getInput("topic"), content, }; console.log(params); console.log(await client.messages.send(params)); })();