Spaces:
Paused
Paused
Captain Ezio
commited on
Commit
·
52af1ce
1
Parent(s):
fe886a1
updated few thing
Browse filesHave to update lyrics cmd
- Powers/plugins/utils.py +50 -30
Powers/plugins/utils.py
CHANGED
|
@@ -1,9 +1,10 @@
|
|
| 1 |
import re
|
| 2 |
import aiofiles
|
|
|
|
| 3 |
from Powers import *
|
| 4 |
from os import remove
|
| 5 |
from io import BytesIO
|
| 6 |
-
from tswift import Song
|
| 7 |
from wikipedia import summary
|
| 8 |
from traceback import format_exc
|
| 9 |
from Powers.bot_class import Gojo
|
|
@@ -14,9 +15,10 @@ from Powers.utils.http_helper import *
|
|
| 14 |
from Powers.database.users_db import Users
|
| 15 |
from Powers.utils.chat_type import chattype
|
| 16 |
from Powers.utils.parser import mention_html
|
| 17 |
-
from search_engine_parser import GoogleSearch
|
| 18 |
from Powers.utils.custom_filters import command
|
| 19 |
from Powers.utils.extract_user import extract_user
|
|
|
|
| 20 |
from pyrogram.errors import PeerIdInvalid, MessageTooLong
|
| 21 |
from Powers.utils.clean_file import remove_markdown_and_html
|
| 22 |
from wikipedia.exceptions import PageError, DisambiguationError
|
|
@@ -82,7 +84,7 @@ async def gdpr_remove(_, m: Message):
|
|
| 82 |
)
|
| 83 |
await m.stop_propagation()
|
| 84 |
|
| 85 |
-
|
| 86 |
@Gojo.on_message(
|
| 87 |
command("lyrics") & (filters.group | filters.private),
|
| 88 |
)
|
|
@@ -165,7 +167,7 @@ async def id_info(c: Gojo, m: Message):
|
|
| 165 |
else:
|
| 166 |
await m.reply_text(text=f"This Group's ID is <code>{m.chat.id}</code>")
|
| 167 |
return
|
| 168 |
-
|
| 169 |
|
| 170 |
@Gojo.on_message(
|
| 171 |
command("gifid") & (filters.group | filters.private),
|
|
@@ -183,31 +185,50 @@ async def get_gifid(_, m: Message):
|
|
| 183 |
|
| 184 |
|
| 185 |
@Gojo.on_message(
|
| 186 |
-
command("github") & (filters.group | filters.private),
|
| 187 |
)
|
| 188 |
-
async def github(_,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
try:
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
gett = message.text.split(None, 1)[1]
|
| 194 |
-
text = gett + ' "site:github.com"'
|
| 195 |
-
gresults = await GoogleSearch().async_search(text, 1)
|
| 196 |
-
result = ""
|
| 197 |
-
for i in range(4):
|
| 198 |
-
try:
|
| 199 |
-
title = gresults["titles"][i].replace("\n", " ")
|
| 200 |
-
source = gresults["links"][i]
|
| 201 |
-
description = gresults["descriptions"][i]
|
| 202 |
-
result += f"[{title}]({source})\n"
|
| 203 |
-
result += f"`{description}`\n\n"
|
| 204 |
-
except IndexError:
|
| 205 |
-
pass
|
| 206 |
-
await message.reply_text(result, disable_web_page_preview=True)
|
| 207 |
except Exception as e:
|
| 208 |
-
await message.reply_text(
|
| 209 |
-
|
| 210 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 211 |
|
| 212 |
|
| 213 |
# paste here
|
|
@@ -324,9 +345,9 @@ _DISABLE_CMDS_ = [
|
|
| 324 |
"wiki",
|
| 325 |
"id",
|
| 326 |
"gifid",
|
| 327 |
-
"lyrics",
|
| 328 |
"tr",
|
| 329 |
"github",
|
|
|
|
| 330 |
]
|
| 331 |
__alt_name__ = ["util", "misc", "tools"]
|
| 332 |
|
|
@@ -340,9 +361,8 @@ Some utils provided by bot to make your tasks easy!
|
|
| 340 |
* /gifid: Reply to a gif to me to tell you its file ID.
|
| 341 |
* /wiki: `<query>`: wiki your query.
|
| 342 |
* /tr `<language>`: Translates the text and then replies to you with the language you have specifed, works as a reply to message.
|
| 343 |
-
* /github `<username>`: Search for the user using github api!
|
| 344 |
-
* /lyrics `<song>`: Get the lyrics of the song you specify!
|
| 345 |
* /weebify `<text>` or `<reply to message>`: To weebify the text.
|
| 346 |
|
| 347 |
**Example:**
|
| 348 |
-
`/
|
|
|
|
| 1 |
import re
|
| 2 |
import aiofiles
|
| 3 |
+
import asyncio
|
| 4 |
from Powers import *
|
| 5 |
from os import remove
|
| 6 |
from io import BytesIO
|
| 7 |
+
# from tswift import Song
|
| 8 |
from wikipedia import summary
|
| 9 |
from traceback import format_exc
|
| 10 |
from Powers.bot_class import Gojo
|
|
|
|
| 15 |
from Powers.database.users_db import Users
|
| 16 |
from Powers.utils.chat_type import chattype
|
| 17 |
from Powers.utils.parser import mention_html
|
| 18 |
+
# from search_engine_parser import GoogleSearch
|
| 19 |
from Powers.utils.custom_filters import command
|
| 20 |
from Powers.utils.extract_user import extract_user
|
| 21 |
+
from Powers.utils.http_helper import get
|
| 22 |
from pyrogram.errors import PeerIdInvalid, MessageTooLong
|
| 23 |
from Powers.utils.clean_file import remove_markdown_and_html
|
| 24 |
from wikipedia.exceptions import PageError, DisambiguationError
|
|
|
|
| 84 |
)
|
| 85 |
await m.stop_propagation()
|
| 86 |
|
| 87 |
+
'''
|
| 88 |
@Gojo.on_message(
|
| 89 |
command("lyrics") & (filters.group | filters.private),
|
| 90 |
)
|
|
|
|
| 167 |
else:
|
| 168 |
await m.reply_text(text=f"This Group's ID is <code>{m.chat.id}</code>")
|
| 169 |
return
|
| 170 |
+
'''
|
| 171 |
|
| 172 |
@Gojo.on_message(
|
| 173 |
command("gifid") & (filters.group | filters.private),
|
|
|
|
| 185 |
|
| 186 |
|
| 187 |
@Gojo.on_message(
|
| 188 |
+
command(["github", "git"]) & (filters.group | filters.private),
|
| 189 |
)
|
| 190 |
+
async def github(_, m: Message):
|
| 191 |
+
if len(m.text.split()) == 2:
|
| 192 |
+
username = m.text.split(maxsplit=1)[1]
|
| 193 |
+
LOGGER.info(f"{m.from_user.id} used github cmd in {m.chat.id}")
|
| 194 |
+
else:
|
| 195 |
+
await m.reply_text(
|
| 196 |
+
f"Usage: <code>{Config.PREFIX_HANDLER}github username</code>",
|
| 197 |
+
)
|
| 198 |
+
return
|
| 199 |
+
|
| 200 |
+
URL = f"https://api.github.com/users/{username}"
|
| 201 |
try:
|
| 202 |
+
r = await get(URL, timeout=5)
|
| 203 |
+
except asyncio.TimeoutError:
|
| 204 |
+
return await message.reply_text("request timeout")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 205 |
except Exception as e:
|
| 206 |
+
return await message.reply_text(f"ERROR: `{e}`")
|
| 207 |
+
|
| 208 |
+
|
| 209 |
+
url = r.get("html_url", None)
|
| 210 |
+
name = r.get("name", None)
|
| 211 |
+
company = r.get("company", None)
|
| 212 |
+
followers = r.get("followers", 0)
|
| 213 |
+
following = r.get("following", 0)
|
| 214 |
+
public_repos = r.get("public_repos", 0)
|
| 215 |
+
bio = r.get("bio", None)
|
| 216 |
+
created_at = r.get("created_at", "Not Found")
|
| 217 |
+
|
| 218 |
+
REPLY = (
|
| 219 |
+
f"<b>GitHub Info for @{username}:</b>"
|
| 220 |
+
f"\n<b>Name:</b> <code>{name}</code>\n"
|
| 221 |
+
f"<b>Bio:</b> <code>{bio}</code>\n"
|
| 222 |
+
f"<b>URL:</b> {url}\n"
|
| 223 |
+
f"<b>Public Repos:</b> {public_repos}\n"
|
| 224 |
+
f"<b>Followers:</b> {followers}\n"
|
| 225 |
+
f"<b>Following:</b> {following}\n"
|
| 226 |
+
f"<b>Company:</b> <code>{company}</code>\n"
|
| 227 |
+
f"<b>Created at:</b> <code>{created_at}</code>"
|
| 228 |
+
)
|
| 229 |
+
|
| 230 |
+
await m.reply_text(REPLY, quote=True, disable_web_page_preview=True)
|
| 231 |
+
return
|
| 232 |
|
| 233 |
|
| 234 |
# paste here
|
|
|
|
| 345 |
"wiki",
|
| 346 |
"id",
|
| 347 |
"gifid",
|
|
|
|
| 348 |
"tr",
|
| 349 |
"github",
|
| 350 |
+
"git"
|
| 351 |
]
|
| 352 |
__alt_name__ = ["util", "misc", "tools"]
|
| 353 |
|
|
|
|
| 361 |
* /gifid: Reply to a gif to me to tell you its file ID.
|
| 362 |
* /wiki: `<query>`: wiki your query.
|
| 363 |
* /tr `<language>`: Translates the text and then replies to you with the language you have specifed, works as a reply to message.
|
| 364 |
+
* /github or /git `<username>`: Search for the user using github api!
|
|
|
|
| 365 |
* /weebify `<text>` or `<reply to message>`: To weebify the text.
|
| 366 |
|
| 367 |
**Example:**
|
| 368 |
+
`/git @iamgojoof6eyes`: this fetches the information about a user from the database."""
|