diff --git a/.eslintrc.yml b/.eslintrc.yml index ba9678d..e2edcf2 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -10,6 +10,3 @@ parserOptions: plugins: - "@typescript-eslint" - "prettier" -rules: { - linebreak-style: ["error", "windows"] -} diff --git a/Dockerfile b/Dockerfile index bdf2317..6c94f64 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,7 @@ WORKDIR /bot COPY ./src /bot/src COPY ./package.json /bot/package.json COPY ./package-lock.json /bot/package-lock.json +COPY ./tsconfig.json /bot/tsconfig.json RUN apk update RUN apk add wget python3 build-base diff --git a/config/config-sample.yaml b/config/config-sample.yaml index 1ce3f2d..cf0d017 100644 --- a/config/config-sample.yaml +++ b/config/config-sample.yaml @@ -5,7 +5,7 @@ owner_id: 'YOUR_TELEGRAM_ID' spam_time: 5 * 60 * 1000 # time (in MS) in which user may send 5 messages spam_cant_msg: 5 -parse_mode: 'MarkdownV2' # DO NOT CHANGE! +parse_mode: 'Markdown' # Experimental. Do not change unless you know what you are doing. Options: Markdown/MarkdownV2/HTML allow_private: false # Allow / disallow option for staff to chat privately direct_reply: false # Set this to true to just forward staff users to a user chat when allow_private diff --git a/docker-compose.yml b/docker-compose.yml index 8552a70..f5f075e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,8 +1,7 @@ version: '3' services: supportbot: - #build: . - image: "bostrot/telegram-support-bot:4.0.0" + build: . restart: unless-stopped volumes: - ${PWD}/config:/bot/config diff --git a/src/files.ts b/src/files.ts index 46d919f..a121778 100644 --- a/src/files.ts +++ b/src/files.ts @@ -63,7 +63,7 @@ function fileHandler(type: string, bot: TelegramAddon, ctx: Context) { ); } // replying to non-ticket - if (userid === null || userid === undefined) { + if (userid == null) { return; } } @@ -77,7 +77,12 @@ function fileHandler(type: string, bot: TelegramAddon, ctx: Context) { // } // if admin if (ctx.session.admin && userInfo === undefined) { - msgId = userid[1]; + // null check here + if (userid != null) { + msgId = userid[1]; + } else { + return; + } } db.getOpen( msgId, diff --git a/src/middleware.ts b/src/middleware.ts index faf5291..0a42ac8 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -4,17 +4,18 @@ import {Context} from './interfaces'; // strict escape const strictEscape = function(str: string | any[]) { - let newStr = ''; - const chars = ['[', ']', '(', ')', '_', '*', '~', '`']; - for (let i = 0; i < str.length; i++) { - // escape special characters - if (chars.includes(str[i])) { - newStr += '\\' + str[i]; - } else { - newStr += str[i]; - } - } - return newStr; + // let newStr = ''; + // const chars = ['[', ']', '(', ')', '_', '*', '~', '`']; + // for (let i = 0; i < str.length; i++) { + // // escape special characters + // if (chars.includes(str[i])) { + // newStr += '\\' + str[i]; + // } else { + // newStr += str[i]; + // } + // } + // return newStr; + return str.toString(); }; // escape special characters @@ -26,7 +27,7 @@ const escapeText = function(str: string | string[]) { .replace(//g, '>') .replace(/"/g, '"'); - } else { + } else if (cache.config.parse_mode == 'MarkdownV2') { // '[', ']', '(', ')', are skipped as they are usally for urls // '_', '*', '~', '`', are used for actualy markdown const chars = ['>', '#', '+', '-', '=', '|', '{', '}', '.', '!']; @@ -48,6 +49,7 @@ const escapeText = function(str: string | string[]) { } return newStr; } + return str.toString(); }; // handle messages to web socket diff --git a/tsconfig.json b/tsconfig.json index 88eb0f2..2dbb101 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,6 +7,7 @@ "sourceMap": true, "moduleResolution": "node", "esModuleInterop": true, + "strictNullChecks" : false, }, "include": [ "./src/**/**/*"