Compare commits

...

10 commits

Author SHA1 Message Date
baalajimaestro 55849a5847
Upgrade to Nim 2.0
Signed-off-by: baalajimaestro <me@baalajimaestro.me>
2023-08-21 15:05:53 +05:30
baalajimaestro 11742447a4
Fixup b7fb137def
Signed-off-by: baalajimaestro <me@baalajimaestro.me>
2023-06-04 15:29:26 +05:30
baalajimaestro ad0eaf0612
Add missing libressl parameter
Signed-off-by: baalajimaestro <me@baalajimaestro.me>
2023-05-31 11:22:12 +05:30
baalajimaestro f56c7e2ac8
Add a bit of comments
Signed-off-by: baalajimaestro <me@baalajimaestro.me>
2023-05-31 11:03:17 +05:30
baalajimaestro 12aa976a20
Use libressl instead of openssl
Signed-off-by: baalajimaestro <me@baalajimaestro.me>
2023-05-31 11:01:57 +05:30
baalajimaestro 5eab571e37
Include upstream patch to fix libressl
Signed-off-by: baalajimaestro <me@baalajimaestro.me>
2023-05-31 10:58:08 +05:30
baalajimaestro eea438b3ab
Build nim from source instead of prebuilts
Signed-off-by: baalajimaestro <me@baalajimaestro.me>
2023-05-31 10:57:11 +05:30
baalajimaestro 364d2a9121
Uprev botapi
Signed-off-by: baalajimaestro <me@baalajimaestro.me>
2023-05-31 08:18:55 +05:30
baalajimaestro 9d1c116643
Update copyright for 2023
Signed-off-by: baalajimaestro <me@baalajimaestro.me>
2023-05-25 11:24:12 +05:30
baalajimaestro b7fb137def
Fix deeplinks on ios
Signed-off-by: baalajimaestro <me@baalajimaestro.me>
2023-05-25 11:23:51 +05:30
3 changed files with 58 additions and 36 deletions

View file

@ -1,37 +1,57 @@
FROM nimlang/nim:alpine as builder FROM nimlang/nim:2.0.0-alpine as builder
RUN apk update && apk add git \ RUN apk update && apk add autoconf \
build-base \ automake \
curl \
bash \ bash \
openssl \ build-base \
openssl-dev \ cmake \
openssl-libs-static \ curl \
git \
libtool \
ninja \
perl \
sqlite-dev \ sqlite-dev \
sqlite-static sqlite-static
ENV LIBRESSL_VERSION v3.8.0
# Compile LibreSSL Portable from source
RUN git clone https://github.com/libressl/portable --depth=1 -b ${LIBRESSL_VERSION} libressl && \
cd libressl && \
./autogen.sh && \
mkdir build-ninja && \
cd build-ninja && \
cmake -G"Ninja" .. && \
ninja
COPY . /app COPY . /app
WORKDIR /app WORKDIR /app
RUN nimble install nimble --accept
# Build with necessary params to enable statically linking openssl, glibc and sqlite3 # Build with necessary params to enable statically linking openssl, glibc and sqlite3
RUN /root/.nimble/bin/nimble build --passL:-L/usr/lib \ RUN nimble build --passL:-L/usr/lib \
-d:ssl \ -d:ssl \
-p:. \ -d:libressl \
--dynlibOverride:ssl \ -p:. \
--dynlibOverride:crypto \ --dynlibOverride:ssl \
--dynlibOverride:sqlite3 \ --dynlibOverride:crypto \
--passl:-lssl \ --dynlibOverride:sqlite3 \
--passl:-lsqlite3 \ --dynlibOverride:tls \
--passl:-lcrypto \ --passl:-lssl \
--passL:-static \ --passl:-lsqlite3 \
--passL:"-flto" \ --passl:-lcrypto \
-d:release \ --passl:-ltls \
--opt:speed \ --passL:-L/libressl/build-ninja/ssl \
--mm:orc \ --passL:-L/libressl/build-ninja/crypto \
--deepcopy=on \ --passL:-L/libressl/build-ninja/tls \
--accept --passL:-static \
--passL:"-flto" \
-d:release \
--opt:speed \
--mm:orc \
--threadAnalysis:off \
--deepcopy=on \
--accept
RUN strip -s /app/nim_censor_bot && \ RUN strip -s /app/nim_censor_bot && \
strip -R .comment -R .note -R .note.ABI-tag /app/nim_censor_bot strip -R .comment -R .note -R .note.ABI-tag /app/nim_censor_bot

View file

@ -1,6 +1,6 @@
# Package # Package
version = "0.2.0" version = "0.3.0"
author = "baalajimaestro" author = "baalajimaestro"
description = "Censor Bot for Telegram written in Nim" description = "Censor Bot for Telegram written in Nim"
license = "AGPL-3.0-or-later" license = "AGPL-3.0-or-later"
@ -10,6 +10,6 @@ bin = @["nim_censor_bot"]
# Dependencies # Dependencies
requires "nim >= 1.6.0" requires "nim >= 2.0.0"
requires "telebot >= 2023.04.13" requires "telebot >= 2023.08.20"
requires "norm >= 2.8.0" requires "norm >= 2.8.1"

View file

@ -1,6 +1,6 @@
# #
# Copyright © 2022 Maestro Creativescape # Copyright © 2022-23 Maestro Creativescape
# #
# SPDX-License-Identifier: AGPL-3.0-or-later # SPDX-License-Identifier: AGPL-3.0-or-later
# #
@ -209,8 +209,8 @@ proc inlineHandler(b: Telebot, u: InlineQuery): Future[bool]{.gcsafe, async.} =
res.inputMessageContent = InputMessageContent(kind: TextMessage, res.inputMessageContent = InputMessageContent(kind: TextMessage,
messageText:"*NSFW " & messageText:"*NSFW " &
capitalizeAscii(ftype) & capitalizeAscii(ftype) &
"*\n\n[Tap to View](tg://resolve?domain=" & "*\n\n[Tap to View](https://t.me/" &
b.username & "&start=" & b.username & "?start=" &
u.query & u.query &
")", ")",
parseMode: some("Markdown")).some parseMode: some("Markdown")).some
@ -274,12 +274,13 @@ proc updateHandler(b: Telebot, u: Update): Future[bool] {.async, gcsafe.} =
discard await b.sendMessage(response.chat.id, discard await b.sendMessage(response.chat.id,
"*NSFW " & "*NSFW " &
"Album" & "Album" &
"*\n\n[Tap to View](tg://resolve?domain=" & "*\n\n[Tap to View](https://t.me/" &
b.username & b.username &
"&start=" & "?start=" &
filehash & filehash &
")", ")",
replyMarkup = replymark, replyMarkup = replymark,
disableWebPagePreview=true,
parseMode="Markdown") parseMode="Markdown")
else: else:
let filehash = GroupMedia[parseInt(response.mediaGroupId.get)] let filehash = GroupMedia[parseInt(response.mediaGroupId.get)]
@ -297,12 +298,13 @@ proc updateHandler(b: Telebot, u: Update): Future[bool] {.async, gcsafe.} =
discard await b.sendMessage(response.chat.id, discard await b.sendMessage(response.chat.id,
"*NSFW " & "*NSFW " &
capitalizeAscii(ftype) & capitalizeAscii(ftype) &
"*\n\n[Tap to View](tg://resolve?domain=" & "*\n\n[Tap to View](https://t.me/" &
b.username & b.username &
"&start=" & "?start=" &
filehash & filehash &
")", ")",
replyMarkup = replymark, replyMarkup = replymark,
disableWebPagePreview=true,
parseMode="Markdown") parseMode="Markdown")
OldDataCleanup() OldDataCleanup()