Log_service/app/utils/sendMessToZulip.ts

33 lines
719 B
TypeScript

import zulip from "zulip-js";
export const sendMessToZulip = async (type, to, topic, content) => {
try {
const config = {
username: "networktool-bot@zulip.ipsupply.com.au",
apiKey: "0jMAmOuhfLvBqKJikv5oAkyNM4RIEoAM",
realm: "https://zulip.ipsupply.com.au",
};
const client = await zulip(config);
if(type === "private"){
let params = {
type: type,
to: to,
content: content
};
await client.messages.send(params);
}else{
let params = {
type: type,
to: to,
topic: topic,
content: content
};
await client.messages.send(params);
}
} catch (error) {
console.log(error);
}
};