Преглед изворни кода

Changed compiler to G++ and removed Telegraph

thehamkercat пре 5 година
родитељ
комит
079a31190e
4 измењених фајлова са 8 додато и 81 уклоњено
  1. 0 1
      requirements.txt
  2. 0 5
      wbb/__init__.py
  3. 0 69
      wbb/modules/telegraph.py
  4. 8 6
      wbb/modules/userbot.py

+ 0 - 1
requirements.txt

@@ -18,7 +18,6 @@ requests
 search_engine_parser
 search_engine_parser
 speedtest-cli
 speedtest-cli
 TgCrypto
 TgCrypto
-telegraph
 uvloop
 uvloop
 youtube_dl
 youtube_dl
 bs4
 bs4

+ 0 - 5
wbb/__init__.py

@@ -32,7 +32,6 @@ from motor.motor_asyncio import AsyncIOMotorClient as MongoClient
 from pyrogram import Client
 from pyrogram import Client
 from pyromod import listen
 from pyromod import listen
 from Python_ARQ import ARQ
 from Python_ARQ import ARQ
-from telegraph import Telegraph
 
 
 is_config = path.exists("config.py")
 is_config = path.exists("config.py")
 if is_config:
 if is_config:
@@ -89,10 +88,6 @@ else:
 # Bot client
 # Bot client
 print("[INFO]: INITIALIZING BOT CLIENT")
 print("[INFO]: INITIALIZING BOT CLIENT")
 app = Client("wbb", bot_token=BOT_TOKEN, api_id=API_ID, api_hash=API_HASH)
 app = Client("wbb", bot_token=BOT_TOKEN, api_id=API_ID, api_hash=API_HASH)
-# Telegraph client
-print("[INFO]: INITIALIZING TELEGRAPH")
-telegraph = Telegraph()
-telegraph.create_account(short_name="wbb")
 # Aiohttp Client
 # Aiohttp Client
 print("[INFO]: INITIALZING AIOHTTP SESSION")
 print("[INFO]: INITIALZING AIOHTTP SESSION")
 aiohttpsession = ClientSession()
 aiohttpsession = ClientSession()

+ 0 - 69
wbb/modules/telegraph.py

@@ -1,69 +0,0 @@
-# Written by MaskedVirus | github.com/swatv3nub for William and SupMeta_bot
-# Kang with Proper Credits
-# Part of Pull Req #2 by @MaskedVirus | github.com/swatv3nub
-
-import os
-
-from pyrogram import filters
-from telegraph import upload_file
-
-from wbb import app
-from wbb.core.decorators.errors import capture_err
-
-__MODULE__ = "Telegraph"
-__HELP__ = """
-Paste Photo and Video to Telegraph
-Usage:
-/tgphoto - reply to a photo
-/tgvideo - reply to a Video
-"""
-
-
-@app.on_message(filters.command("tgphoto"))
-@capture_err
-async def tgphoto(client, message):
-    if not message.reply_to_message:
-        return await message.reply_text("Reply to a photo.")
-    if not message.reply_to_message.photo:
-        return await message.reply_text("Works only for Photos")
-    msg = await message.reply_text("`Uploading to Telegraph...`")
-    userid = str(message.chat.id)
-    path = f"./DOWNLOADS/{userid}.jpg"
-    path = await client.download_media(
-        message=message.reply_to_message, file_name=path
-    )
-    try:
-        tlink = upload_file(path)
-    except Exception:
-        await msg.edit_text("Something went Wrong.")
-    else:
-        await msg.edit_text(
-            f"Successfully Uploaded to [Telegraph](https://telegra.ph{tlink[0]})"
-        )
-        os.remove(path)
-
-
-@app.on_message(filters.command("tgvideo"))
-@capture_err
-async def tgvideo(client, message):
-    if not message.reply_to_message:
-        return await message.reply_text("Reply to a Video.")
-    if not message.reply_to_message.video:
-        return await message.reply_text("Works only for Videos")
-    if message.reply_to_message.video.file_size < 5242880:
-        msg = await message.reply_text("Uploading to Telegraph...")
-        userid = str(message.chat.id)
-        vid_path = f"./DOWNLOADS/{userid}.mp4"
-        vid_path = await client.download_media(
-            message=message.reply_to_message, file_name=vid_path
-        )
-        try:
-            tlink = upload_file(vid_path)
-            await msg.edit_text(
-                f"Successfully Uploaded to [Telegraph](https://telegra.ph{tlink[0]})"
-            )
-            os.remove(vid_path)
-        except Exception:
-            await msg.edit_text("Something went Wrong.")
-    else:
-        await message.reply_text("Size Should Be Less Than 5 mb")

+ 8 - 6
wbb/modules/userbot.py

@@ -174,7 +174,7 @@ async def shellrunner(client, message: Message):
         )
         )
 
 
 
 
-""" C Eval """
+""" C and CPP Eval """
 
 
 
 
 async def sendFile(message: Message, text: str):
 async def sendFile(message: Message, text: str):
@@ -186,13 +186,15 @@ async def sendFile(message: Message, text: str):
 
 
 
 
 @app2.on_message(
 @app2.on_message(
-    filters.command("c", prefixes=USERBOT_PREFIX) & filters.user(SUDOERS)
+    filters.command(["c", "cpp"], prefixes=USERBOT_PREFIX) & filters.user(SUDOERS)
 )
 )
-async def cEval(_, message: Message):
+async def c_cpp_eval(_, message: Message):
     code = message.text.strip()[3:]
     code = message.text.strip()[3:]
     file = "exec.c"
     file = "exec.c"
-    cmdCompile = ["gcc", "-g", "exec.c", "-o", "exec"]
-    cmdRun = ["./exec"]
+    compiler = "g++"
+    out = "exec"
+    cmdCompile = [compiler, "-g", file, "-o", out]
+    cmdRun = [f"./{out}"]
     async with aiofiles.open(file, mode="w+") as f:
     async with aiofiles.open(file, mode="w+") as f:
         await f.write(code)
         await f.write(code)
     t1 = time()
     t1 = time()
@@ -212,7 +214,7 @@ async def cEval(_, message: Message):
         return await edit_or_reply(message, text=text)
         return await edit_or_reply(message, text=text)
     pRun = subprocess.run(cmdRun, capture_output=True)
     pRun = subprocess.run(cmdRun, capture_output=True)
     t2 = time()
     t2 = time()
-    os.remove("exec")
+    os.remove(out)
     err = pRun.stderr.decode()
     err = pRun.stderr.decode()
     out = pRun.stdout.decode()
     out = pRun.stdout.decode()
     err = f"**RUNTIME ERROR:**\n```{escape(err)}```" if err else None
     err = f"**RUNTIME ERROR:**\n```{escape(err)}```" if err else None