Skip to content

Commit 3db1bbe

Browse files
authored
Compilling for C & C++
1 parent c39038d commit 3db1bbe

File tree

6 files changed

+66
-49
lines changed

6 files changed

+66
-49
lines changed

Dockerfile

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,6 @@
11
FROM bipinkrish/file-converter:latest
22

3-
RUN apt install curl -y
4-
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
5-
RUN apt-get update
6-
RUN apt-get install -y cargo clang-format z3 clang
7-
RUN apt -y install rustfmt golang-go
8-
RUN apt-get install openctm-tools libzbar0 -y
9-
10-
RUN curl -fsSL -o /tmp/warp-packer \
11-
https://github.com/dgiagio/warp/releases/download/v0.3.0/linux-x64.warp-packer \
12-
&& install -D \
13-
--mode=755 \
14-
--owner=root \
15-
--group=root \
16-
/tmp/warp-packer \
17-
/usr/local/bin \
18-
&& rm /tmp/warp-packer
19-
COPY warp4j /usr/local/bin/
20-
RUN chmod 777 /usr/local/bin/warp4j
21-
RUN wget https://www.jflap.org/jflaptmp/july27-18/JFLAP7.1.jar && warp4j JFLAP7.1.jar && rm -r warped/ && warp4j JFLAP7.1.jar --no-optimize && rm -r warped/ && rm JFLAP7.1.jar
3+
RUN apt install build-essential -y
224

235
COPY . .
246
RUN pip install --no-cache-dir -r requirements.txt

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,10 @@
3030

3131
**Subtitles**: *TTML, SCC, SRT, VTT*
3232

33-
**Programming Languages**: *C, CPP, PY, RS, JL, KT, NIM, DART, GO, JAVA, JS, TS*
33+
**Programming Languages**: *C, CPP, PY, RS, JL, KT, NIM, DART, GO, JAVA, JS, TS, JAR*
3434

3535
**3D Files**: *CTM, PLY, STL, 3DS, DAE, OBJ, LWO, OFF, WRL*
3636

37-
**Executables**: *JAR*
38-
3937
---
4038

4139
## Special Features
@@ -56,6 +54,8 @@
5654

5755
**SCAN** - *Get Scanned Data from QR Codes and Bar Codes*
5856

57+
**COMPILE** - *Get Self-Contained Linux Executable*
58+
5959
---
6060

6161
## Extra Features

buttons.py

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@
1313
ARC = ("ZIP","RAR","7Z","TAR","XZ","GZ","BZ")
1414
TOR = ("TORRENT","MAGNET")
1515
SUB = ("TTML","SCC","SRT","VTT")
16-
PRO = ('C','CPP','PY','RS','JL','KT','NIM','DART','GO','JAVA','JS','TS')
16+
PRO = ('C','CPP','PY','RS','JL','KT','NIM','DART','GO','JAVA','JS','TS','JAR')
1717
T3D = ('CTM','PLY','STL','3DS','DAE','OBJ','LWO','OFF','WRL')
18-
BIN = ('JAR')
1918

2019

2120
# buttons
@@ -158,26 +157,28 @@
158157
SUBboard = ReplyKeyboard(row_width=3,one_time_keyboard=True,placeholder="convert to",resize_keyboard=True,selective=True)
159158
SUBboard.add(
160159
ReplyButton("TTML"),
161-
ReplyButton("SCC"),
160+
#ReplyButton("SCC"),
162161
ReplyButton("SRT"),
163162
ReplyButton("VTT")
164163
)
165164

166165
PROboard = ReplyKeyboard(row_width=3,one_time_keyboard=True,placeholder="convert to",resize_keyboard=True,selective=True)
167166
PROboard.add(
168-
ReplyButton('C'),
167+
#ReplyButton('C'),
169168
ReplyButton('CPP'),
170-
ReplyButton('PY'),
169+
#ReplyButton('PY'),
171170
ReplyButton('RS'),
172171
ReplyButton('JL'),
173172
ReplyButton('KT'),
174173
ReplyButton('NIM'),
175174
ReplyButton('DART'),
176175
ReplyButton('GO'),
177-
ReplyButton('JAVA'),
176+
#ReplyButton('JAVA'),
178177
ReplyButton('TS'),
179178
ReplyButton('JS'),
180-
ReplyButton('READ')
179+
#ReplyButton('JAR'),
180+
ReplyButton('READ'),
181+
ReplyButton('COMPILE')
181182
)
182183

183184
T3Dboard = ReplyKeyboard(row_width=3,one_time_keyboard=True,placeholder="convert to",resize_keyboard=True,selective=True)
@@ -190,12 +191,7 @@
190191
ReplyButton('OBJ'),
191192
ReplyButton('LWO'),
192193
ReplyButton('OFF'),
193-
ReplyButton('WRL')
194-
)
195-
196-
BINboard = ReplyKeyboard(row_width=3,one_time_keyboard=True,placeholder="convert to",resize_keyboard=True,selective=True)
197-
BINboard.add(
198-
ReplyButton('COMPILE')
194+
#ReplyButton('WRL')
199195
)
200196

201197

@@ -212,11 +208,9 @@
212208
SUB_TEXT = helperfunctions.give_name(SUB)
213209
PRO_TEXT = helperfunctions.give_name(PRO)
214210
T3D_TEXT = helperfunctions.give_name(T3D)
215-
BIN_TEXT = "JAR"#helperfunctions.give_name(BIN)
216211

217212

218213
START_TEXT = f'**Images** 📷 \n__{IMG_TEXT}__\n\n\
219-
**Special** 🎁 \n__COLORIZE, POSITIVE, UPSCALE, TEXT-to-SPEECH, SPEECH-to-TEXT, AI IMAGE & AI VIDEO__\n\n\
220214
**Videos/Audios** 📹 / 🔊 \n__{VA_TEXT}__\n\n\
221215
**Documents** 💼 \n__{LBW_TEXT},{LBI_TEXT},{LBC_TEXT}__\n\n\
222216
**Fonts** 🔤 \n__{FF_TEXT}__\n\n\
@@ -226,5 +220,5 @@
226220
**Subtitles** 🗯️ \n__{SUB_TEXT}__\n\n\
227221
**Programming Languages** 👨‍💻 \n__{PRO_TEXT}__\n\n\
228222
**3D Files** 💠 \n__{T3D_TEXT}__\n\n\
229-
**Executables** 🎛️ \n__{BIN_TEXT}__'
223+
**Special** 🎁 \n__COLORIZE, POSITIVE, UPSCALE, TEXT-to-SPEECH, SPEECH-to-TEXT, AI IMAGE, AI VIDEO, SCAN & COMPILE__'
230224

dockerbuildfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,25 @@ RUN apt update && apt-get upgrade -y
2828
RUN apt install -y p7zip-full p7zip-rar
2929
RUN apt-get install -y python3-numpy python3-pydot python3-matplotlib python3-opencv python3-graphviz python3-toolz
3030
RUN wget https://github.com/bipinkrish/Colorize-Positive-Bot/releases/download/Model/model.zip && unzip model.zip && rm model.zip
31+
32+
RUN pip install --no-cache-dir bs4 ttconv py2many pyzbar
33+
34+
RUN apt install curl -y
35+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
36+
RUN apt-get update
37+
RUN apt-get install -y cargo clang-format z3 clang
38+
RUN apt -y install rustfmt golang-go
39+
RUN apt-get install openctm-tools libzbar0 -y
40+
41+
RUN curl -fsSL -o /tmp/warp-packer \
42+
https://github.com/dgiagio/warp/releases/download/v0.3.0/linux-x64.warp-packer \
43+
&& install -D \
44+
--mode=755 \
45+
--owner=root \
46+
--group=root \
47+
/tmp/warp-packer \
48+
/usr/local/bin \
49+
&& rm /tmp/warp-packer
50+
COPY warp4j /usr/local/bin/
51+
RUN chmod 777 /usr/local/bin/warp4j
52+
RUN wget https://www.jflap.org/jflaptmp/july27-18/JFLAP7.1.jar && warp4j JFLAP7.1.jar && rm -r warped/ && warp4j JFLAP7.1.jar --no-optimize && rm -r warped/ && rm JFLAP7.1.jar

helperfunctions.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@
1212
telegraph.create_account(short_name='file-converter')
1313

1414

15+
# g++ compile command
16+
def gppcommand(inputt):
17+
filename = inputt.split("/")[-1].split(".")[0]
18+
cmd = f'g++ -o {filename} {inputt}'
19+
return cmd, filename
20+
21+
1522
# scan qr and barcode
1623
def scanner(file):
1724
data = decode(Image.open(file))

main.py

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,8 @@ def compile(message,oldm):
509509
ext = message.document.file_name.split(".")[-1]
510510
file = app.download_media(message)
511511

512+
513+
# jar compilation
512514
if ext.upper() == "JAR":
513515
cmd,folder,files = helperfunctions.warpcommand(file,message)
514516
os.system(cmd)
@@ -525,9 +527,25 @@ def compile(message,oldm):
525527
os.remove(ele)
526528
shutil.rmtree(folder)
527529
else:
528-
app.send_message(message.chat.id,"__Error while Conversion__", reply_to_message_id=message.id)
530+
app.send_message(message.chat.id,"__Error while Compiling__", reply_to_message_id=message.id)
531+
532+
533+
# c and c++ compilation
534+
elif ext.upper() in ['C','CPP']:
535+
cmd,output = helperfunctions.gppcommand(file)
536+
os.system(cmd)
537+
os.remove(file)
538+
if os.path.exists(output) and os.path.getsize(output) > 0:
539+
app.send_document(message.chat.id,document=output, caption="__Linux Executable__", force_document=True, reply_to_message_id=message.id)
540+
os.remove(output)
541+
else:
542+
app.send_message(message.chat.id,"__Error while Compiling__", reply_to_message_id=message.id)
543+
544+
else:
545+
app.send_message(message.chat.id,"__At this time Compilation only supports from JAR, C and CPP Files__", reply_to_message_id=message.id)
529546

530547

548+
# delete message
531549
app.delete_messages(message.chat.id,message_ids=[oldm.id])
532550

533551

@@ -1019,7 +1037,7 @@ def documnet(client: pyrogram.client.Client, message: pyrogram.types.messages_an
10191037
# IMG
10201038
elif message.document.file_name.upper().endswith(IMG):
10211039
app.send_message(message.chat.id,
1022-
f'__Detected Extension:__ **{dext}** 📷\n__Now send extension to Convert to...__\n\n--**Available formats**-- \n\n__{IMG_TEXT}__\n\n**SPECIAL** 🎁\n__COLORIZE, POSITIVE & UPSCALE__\n\n{message.from_user.mention} __choose or click /cancel to Cancel or use /rename to Rename__',
1040+
f'__Detected Extension:__ **{dext}** 📷\n__Now send extension to Convert to...__\n\n--**Available formats**-- \n\n__{IMG_TEXT}__\n\n**SPECIAL** 🎁\n__COLORIZE, POSITIVE, UPSCALE & SCAN__\n\n{message.from_user.mention} __choose or click /cancel to Cancel or use /rename to Rename__',
10231041
reply_markup=IMGboard, reply_to_message_id=message.id)
10241042

10251043
# LBW
@@ -1082,12 +1100,6 @@ def documnet(client: pyrogram.client.Client, message: pyrogram.types.messages_an
10821100
f'__Detected Extension:__ **{dext}** 💠 \n__Now send extension to Convert to...__\n\n--**Available formats**-- \n\n__{T3D_TEXT}__\n\n{message.from_user.mention} __choose or click /cancel to Cancel or use /rename to Rename__',
10831101
reply_markup=T3Dboard, reply_to_message_id=message.id)
10841102

1085-
# BIN
1086-
elif message.document.file_name.upper().endswith(BIN):
1087-
app.send_message(message.chat.id,
1088-
f'__Detected Extension:__ **{dext}** 🎛️\n__Do you want to Compile it ?__\n\n{message.from_user.mention} __choose or click /cancel to Cancel or use /rename to Rename__',
1089-
reply_markup=BINboard, reply_to_message_id=message.id)
1090-
10911103
# else
10921104
else:
10931105
app.send_message(message.chat.id,'__No Available Conversions found.\n\nYou can use:__\n**/rename new-filename** __to Rename__\n**/read** __to Read the File__')
@@ -1165,7 +1177,7 @@ def photo(client: pyrogram.client.Client, message: pyrogram.types.messages_and_m
11651177
with open(f'{message.from_user.id}.json', 'wb') as handle:
11661178
pickle.dump(message, handle)
11671179
app.send_message(message.chat.id,
1168-
f'__Detected Extension:__ **JPG** 📷\n__Now send extension to Convert to...__\n\n--**Available formats**-- \n\n__{IMG_TEXT}__\n\n**SPECIAL** 🎁\n__COLORIZE, POSITIVE & UPSCALE__\n\n{message.from_user.mention} __choose or click /cancel to Cancel or use /rename to Rename__',
1180+
f'__Detected Extension:__ **JPG** 📷\n__Now send extension to Convert to...__\n\n--**Available formats**-- \n\n__{IMG_TEXT}__\n\n**SPECIAL** 🎁\n__COLORIZE, POSITIVE, UPSCALE & SCAN__\n\n{message.from_user.mention} __choose or click /cancel to Cancel or use /rename to Rename__',
11691181
reply_markup=IMGboard, reply_to_message_id=message.id)
11701182

11711183

@@ -1176,11 +1188,11 @@ def sticker(client: pyrogram.client.Client, message: pyrogram.types.messages_and
11761188
pickle.dump(message, handle)
11771189
if not message.sticker.is_animated and not message.sticker.is_video:
11781190
app.send_message(message.chat.id,
1179-
f'__Detected Extension:__ **WEBP** 📷\n__Now send extension to Convert to...__\n\n--**Available formats**-- \n\n__{IMG_TEXT}__\n\n**SPECIAL** 🎁\n__COLORIZE, POSITIVE & UPSCALE__\n\n{message.from_user.mention} __choose or click /cancel to Cancel or use /rename to Rename__',
1191+
f'__Detected Extension:__ **WEBP** 📷\n__Now send extension to Convert to...__\n\n--**Available formats**-- \n\n__{IMG_TEXT}__\n\n**SPECIAL** 🎁\n__COLORIZE, POSITIVE, UPSCALE & SCAN__\n\n{message.from_user.mention} __choose or click /cancel to Cancel or use /rename to Rename__',
11801192
reply_markup=IMGboard, reply_to_message_id=message.id)
11811193
else:
11821194
app.send_message(message.chat.id,
1183-
f'__Detected Extension:__ **TGS** 📷\n__Now send extension to Convert to...__\n\n--**Available formats**-- \n\n__{IMG_TEXT}__\n\n**SPECIAL** 🎁\n__COLORIZE, POSITIVE & UPSCALE__\n\n{message.from_user.mention} __choose or click /cancel to Cancel or use /rename to Rename__',
1195+
f'__Detected Extension:__ **TGS** 📷\n__Now send extension to Convert to...__\n\n--**Available formats**-- \n\n__{IMG_TEXT}__\n\n**SPECIAL** 🎁\n__COLORIZE, POSITIVE, UPSCALE & SCAN__\n\n{message.from_user.mention} __choose or click /cancel to Cancel or use /rename to Rename__',
11841196
reply_markup=IMGboard, reply_to_message_id=message.id)
11851197

11861198

0 commit comments

Comments
 (0)