Skip to content

Commit 4464a81

Browse files
committedSep 20, 2022
Fixed nullable
1 parent 7a79e58 commit 4464a81

File tree

5 files changed

+20
-16
lines changed

5 files changed

+20
-16
lines changed
 

‎Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ WORKDIR /bot
44
COPY ./src /bot/src
55
COPY ./package.json /bot/package.json
66
COPY ./package-lock.json /bot/package-lock.json
7+
COPY ./tsconfig.json /bot/tsconfig.json
78

89
RUN apk update
910
RUN apk add wget python3 build-base

‎docker-compose.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
version: '3'
22
services:
33
supportbot:
4-
#build: .
5-
image: "bostrot/telegram-support-bot:4.0.0"
4+
build: .
65
restart: unless-stopped
76
volumes:
87
- ${PWD}/config:/bot/config

‎src/files.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function fileHandler(type: string, bot: TelegramAddon, ctx: Context) {
6363
);
6464
}
6565
// replying to non-ticket
66-
if (userid === null || userid === undefined) {
66+
if (userid == null) {
6767
return;
6868
}
6969
}
@@ -77,10 +77,12 @@ function fileHandler(type: string, bot: TelegramAddon, ctx: Context) {
7777
// }
7878
// if admin
7979
if (ctx.session.admin && userInfo === undefined) {
80-
if (userid == null) {
80+
// null check here
81+
if (userid != null) {
82+
msgId = userid[1];
83+
} else {
8184
return;
8285
}
83-
msgId = userid[1];
8486
}
8587
db.getOpen(
8688
msgId,

‎src/middleware.ts

+12-11
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@ import {Context} from './interfaces';
44

55
// strict escape
66
const strictEscape = function(str: string | any[]) {
7-
let newStr = '';
8-
const chars = ['[', ']', '(', ')', '_', '*', '~', '`'];
9-
for (let i = 0; i < str.length; i++) {
10-
// escape special characters
11-
if (chars.includes(str[i])) {
12-
newStr += '\\' + str[i];
13-
} else {
14-
newStr += str[i];
15-
}
16-
}
17-
return newStr;
7+
// let newStr = '';
8+
// const chars = ['[', ']', '(', ')', '_', '*', '~', '`'];
9+
// for (let i = 0; i < str.length; i++) {
10+
// // escape special characters
11+
// if (chars.includes(str[i])) {
12+
// newStr += '\\' + str[i];
13+
// } else {
14+
// newStr += str[i];
15+
// }
16+
// }
17+
// return newStr;
18+
return str.toString();
1819
};
1920

2021
// escape special characters

‎tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"sourceMap": true,
88
"moduleResolution": "node",
99
"esModuleInterop": true,
10+
"strictNullChecks" : false,
1011
},
1112
"include": [
1213
"./src/**/**/*"

0 commit comments

Comments
 (0)
Please sign in to comment.