forked from xditya/TeleBot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,7 @@ pytz | |
qrcode | ||
regex | ||
requests>=2.18.4 | ||
rextester_py | ||
search-engine-parser>=0.4.2 | ||
selenium | ||
spamwatch | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# TeleBot - UserBot | ||
# Copyright (C) 2020 TeleBot | ||
|
||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
|
||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
|
||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
# by @its_xditya | ||
|
||
from rextester_py import rexec | ||
from . import CMD_HELP | ||
|
||
@telebot.on(admin_cmd(pattern="rex")) | ||
async def _(event): | ||
if event.fwd_from: | ||
return | ||
await event.edit("Processing ...") | ||
evtxt = event.text.split(" ", maxsplit=1)[1] | ||
try: | ||
lang = evtxt.split("//", maxsplit=1)[0] | ||
cmd = evtxt.split("//", maxsplit=1)[1] | ||
except: | ||
return await event.edit(f"Syntax - \n`{Var.CMD_HNDLR}rex language//code`\nLanguages can be found [here](https://github.com/nitanmarcel/rextester_py#languages).") | ||
|
||
try: | ||
res = rexec(lang, cmd, None).results | ||
err = rexec(lang, cmd, None).errors | ||
wrns = rexec(lang, cmd, None).warnings | ||
# statt = rexec(lang, cmd, None).stats | ||
except Exception as e: | ||
if str(e) == "Unknown language": | ||
return await event.edit("**ERROR**:\n`Unknown Language!!\nCheck available languages `[here](https://github.com/nitanmarcel/rextester_py#languages)") | ||
return await event.edit(f"**ERROR:**\n`{str(e)}`") | ||
out = f"**- Rextester**\n\n**Language:** `{lang}`\n**Code:** `{cmd}`\n\n**Output:** `{res}`\n\n" | ||
if err is not None: | ||
out += f"**Error:** `{err}`\n\n" | ||
if wrns is not None: | ||
out += f"**Warnings:** `{wrns}`\n\n" | ||
# reducing time taken... | ||
# out += f"**Stats:** `{statt}`" | ||
|
||
await event.edit(out) | ||
|
||
CMD_HELP.update( | ||
{ | ||
"rextester": ".rex <language>//<codes>\ | ||
\nUse - Run codes of any language inside telegram. Available languages can be found [here](https://github.com/nitanmarcel/rextester_py#languages)." | ||
} | ||
) |