Skip to content

Commit

Permalink
Fixed nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
bostrot committed Sep 20, 2022
1 parent 7a79e58 commit 4464a81
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 16 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 5 additions & 3 deletions src/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand All @@ -77,10 +77,12 @@ function fileHandler(type: string, bot: TelegramAddon, ctx: Context) {
// }
// if admin
if (ctx.session.admin && userInfo === undefined) {
if (userid == null) {
// null check here
if (userid != null) {
msgId = userid[1];
} else {
return;
}
msgId = userid[1];
}
db.getOpen(
msgId,
Expand Down
23 changes: 12 additions & 11 deletions src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"sourceMap": true,
"moduleResolution": "node",
"esModuleInterop": true,
"strictNullChecks" : false,
},
"include": [
"./src/**/**/*"
Expand Down

0 comments on commit 4464a81

Please sign in to comment.