瀏覽代碼

strip html for discord

Joystream Stats 3 年之前
父節點
當前提交
4e4a423046

+ 1 - 0
community-contributions/joystreamtelegrambot/package.json

@@ -27,6 +27,7 @@
     "discord.js": "^12.5.3",
     "moment": "^2.29.1",
     "node-telegram-bot-api": "^0.51.0",
+    "string-strip-html": "^8.3.0",
     "ws": "^7.4.1"
   },
   "devDependencies": {

+ 4 - 1
community-contributions/joystreamtelegrambot/src/bot.ts

@@ -8,6 +8,7 @@ import {
   proposalDelay,
   wsLocation,
 } from "../config";
+import { stripHtml } from "string-strip-html";
 
 // types
 import { Block, Council, Options, Proposals } from "./types";
@@ -69,8 +70,10 @@ const sendTelegram = (msg: string) => {
 };
 const sendDiscord = (msg: string, channel: any) => {
   if (!channel) return;
+  const stripped: string = stripHtml(msg).result;
+  if (!stripped.length) return;
   try {
-    channel.send(msg);
+    channel.send(stripped);
   } catch (e) {
     console.log(e);
   }