Spaces:
Sleeping
Sleeping
Captain Ezio
commited on
Commit
·
8fb35a7
1
Parent(s):
1476bad
Update complete
Browse files- Powers/__init__.py +17 -0
- Powers/plugins/utils.py +16 -6
- Powers/vars.py +2 -0
- app.json +5 -0
- requirements.txt +1 -0
Powers/__init__.py
CHANGED
@@ -8,6 +8,8 @@ from sys import stdout, version_info
|
|
8 |
from time import time
|
9 |
from traceback import format_exc
|
10 |
|
|
|
|
|
11 |
LOG_DATETIME = datetime.now().strftime("%d_%m_%Y-%H_%M_%S")
|
12 |
LOGDIR = f"{__name__}/logs"
|
13 |
|
@@ -56,7 +58,22 @@ LOGGER.info("------------------------")
|
|
56 |
LOGGER.info(f"Version: {Config.VERSION}")
|
57 |
LOGGER.info(f"Owner: {str(Config.OWNER_ID)}")
|
58 |
LOGGER.info("Source Code: https://github.com/Gojo-Bots/Gojo_Satoru\n")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
|
|
|
|
|
|
|
|
|
|
|
60 |
# Account Related
|
61 |
BOT_TOKEN = Config.BOT_TOKEN
|
62 |
API_ID = Config.API_ID
|
|
|
8 |
from time import time
|
9 |
from traceback import format_exc
|
10 |
|
11 |
+
import lyricsgenius
|
12 |
+
|
13 |
LOG_DATETIME = datetime.now().strftime("%d_%m_%Y-%H_%M_%S")
|
14 |
LOGDIR = f"{__name__}/logs"
|
15 |
|
|
|
58 |
LOGGER.info(f"Version: {Config.VERSION}")
|
59 |
LOGGER.info(f"Owner: {str(Config.OWNER_ID)}")
|
60 |
LOGGER.info("Source Code: https://github.com/Gojo-Bots/Gojo_Satoru\n")
|
61 |
+
LOGGER.info("Checking lyrics genius api...")
|
62 |
+
if Config.GENIUS_API_TOKEN:
|
63 |
+
LOGGER.info("Found genius api token initialising client")
|
64 |
+
genius_lyrics = lyricsgenius.Genius(
|
65 |
+
"VOT0IxuOq2CzSfAF1xwerHFNpKGyivUxZtWyHPm1ucjM4iWb1LxG-aKSE-YuG5e46ZMRg6yUUtsBcz_OGKPzug",
|
66 |
+
skip_non_songs=True,
|
67 |
+
excluded_terms=["(Remix)", "(Live)"],
|
68 |
+
remove_section_headers=True,
|
69 |
+
)
|
70 |
+
is_genius_lyrics = True
|
71 |
|
72 |
+
genius_lyrics.verbose = False
|
73 |
+
LOGGER.info("Client setup complete")
|
74 |
+
elif not Config.GENIUS_API_TOKEN:
|
75 |
+
LOGGER.error("Genius api not found lyrics command will not work")
|
76 |
+
is_genius_lyrics = False
|
77 |
# Account Related
|
78 |
BOT_TOKEN = Config.BOT_TOKEN
|
79 |
API_ID = Config.API_ID
|
Powers/plugins/utils.py
CHANGED
@@ -80,12 +80,13 @@ async def gdpr_remove(_, m: Message):
|
|
80 |
)
|
81 |
await m.stop_propagation()
|
82 |
|
83 |
-
|
84 |
-
'''
|
85 |
@Gojo.on_message(
|
86 |
command("lyrics") & (filters.group | filters.private),
|
87 |
)
|
88 |
async def get_lyrics(_, m: Message):
|
|
|
|
|
|
|
89 |
if len(m.text.split()) <= 1:
|
90 |
await m.reply_text(text="Please check help on how to use this this command.")
|
91 |
return
|
@@ -97,16 +98,24 @@ async def get_lyrics(_, m: Message):
|
|
97 |
return
|
98 |
song_name = query
|
99 |
em = await m.reply_text(text=f"Finding lyrics for <code>{song_name}<code>...")
|
100 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
if song:
|
102 |
if song.lyrics:
|
103 |
-
reply = song.
|
|
|
|
|
104 |
else:
|
105 |
reply = "Couldn't find any lyrics for that song!"
|
106 |
else:
|
107 |
reply = "Song not found!"
|
108 |
try:
|
109 |
-
await em.edit_text(reply)
|
110 |
except MessageTooLong:
|
111 |
with BytesIO(str.encode(await remove_markdown_and_html(reply))) as f:
|
112 |
f.name = "lyrics.txt"
|
@@ -115,7 +124,7 @@ async def get_lyrics(_, m: Message):
|
|
115 |
)
|
116 |
await em.delete()
|
117 |
return
|
118 |
-
|
119 |
|
120 |
|
121 |
@Gojo.on_message(
|
@@ -345,6 +354,7 @@ Some utils provided by bot to make your tasks easy!
|
|
345 |
• /id: Get the current group id. If used by replying to a message, get that user's id.
|
346 |
• /info: Get information about a user.
|
347 |
• /gifid: Reply to a gif to me to tell you its file ID.
|
|
|
348 |
• /wiki: `<query>`: wiki your query.
|
349 |
• /tr `<language>`: Translates the text and then replies to you with the language you have specifed, works as a reply to message.
|
350 |
• /git `<username>`: Search for the user using github api!
|
|
|
80 |
)
|
81 |
await m.stop_propagation()
|
82 |
|
|
|
|
|
83 |
@Gojo.on_message(
|
84 |
command("lyrics") & (filters.group | filters.private),
|
85 |
)
|
86 |
async def get_lyrics(_, m: Message):
|
87 |
+
if not is_genius_lyrics:
|
88 |
+
await m.reply_text("Genius lyrics api is missing")
|
89 |
+
return
|
90 |
if len(m.text.split()) <= 1:
|
91 |
await m.reply_text(text="Please check help on how to use this this command.")
|
92 |
return
|
|
|
98 |
return
|
99 |
song_name = query
|
100 |
em = await m.reply_text(text=f"Finding lyrics for <code>{song_name}<code>...")
|
101 |
+
try:
|
102 |
+
song = genius_lyrics.search_song(query)
|
103 |
+
except Exception as e:
|
104 |
+
await em.delete()
|
105 |
+
await m.reply_text("Connection error try again after sometime")
|
106 |
+
return
|
107 |
+
|
108 |
if song:
|
109 |
if song.lyrics:
|
110 |
+
reply = song.lyrics
|
111 |
+
reply = reply.split("\n",1)[1]
|
112 |
+
artist = song.artist
|
113 |
else:
|
114 |
reply = "Couldn't find any lyrics for that song!"
|
115 |
else:
|
116 |
reply = "Song not found!"
|
117 |
try:
|
118 |
+
await em.edit_text(f"**{query.capitalize()} by {artist}**\n`{reply}`")
|
119 |
except MessageTooLong:
|
120 |
with BytesIO(str.encode(await remove_markdown_and_html(reply))) as f:
|
121 |
f.name = "lyrics.txt"
|
|
|
124 |
)
|
125 |
await em.delete()
|
126 |
return
|
127 |
+
|
128 |
|
129 |
|
130 |
@Gojo.on_message(
|
|
|
354 |
• /id: Get the current group id. If used by replying to a message, get that user's id.
|
355 |
• /info: Get information about a user.
|
356 |
• /gifid: Reply to a gif to me to tell you its file ID.
|
357 |
+
• /lyrics `<song name>` : Find your song and give the lyrics of the song
|
358 |
• /wiki: `<query>`: wiki your query.
|
359 |
• /tr `<language>`: Translates the text and then replies to you with the language you have specifed, works as a reply to message.
|
360 |
• /git `<username>`: Search for the user using github api!
|
Powers/vars.py
CHANGED
@@ -37,6 +37,7 @@ class Config:
|
|
37 |
default="1344569458",
|
38 |
).split(" ")
|
39 |
]
|
|
|
40 |
DB_URI = config("DB_URI", default="")
|
41 |
DB_NAME = config("DB_NAME", default="")
|
42 |
NO_LOAD = config("NO_LOAD", default="").split()
|
@@ -66,6 +67,7 @@ class Development:
|
|
66 |
DB_URI = "" # Your mongo DB URI
|
67 |
DB_NAME = "" # Your DB name
|
68 |
NO_LOAD = []
|
|
|
69 |
PREFIX_HANDLER = ["!", "/"]
|
70 |
SUPPORT_GROUP = "SUPPORT_GROUP"
|
71 |
SUPPORT_CHANNEL = "SUPPORT_CHANNEL"
|
|
|
37 |
default="1344569458",
|
38 |
).split(" ")
|
39 |
]
|
40 |
+
GENIUS_API_TOKEN = config("GENIUS_API")
|
41 |
DB_URI = config("DB_URI", default="")
|
42 |
DB_NAME = config("DB_NAME", default="")
|
43 |
NO_LOAD = config("NO_LOAD", default="").split()
|
|
|
67 |
DB_URI = "" # Your mongo DB URI
|
68 |
DB_NAME = "" # Your DB name
|
69 |
NO_LOAD = []
|
70 |
+
GENIUS_API_TOKEN = ""
|
71 |
PREFIX_HANDLER = ["!", "/"]
|
72 |
SUPPORT_GROUP = "SUPPORT_GROUP"
|
73 |
SUPPORT_CHANNEL = "SUPPORT_CHANNEL"
|
app.json
CHANGED
@@ -82,6 +82,11 @@
|
|
82 |
"required": false,
|
83 |
"value": " "
|
84 |
},
|
|
|
|
|
|
|
|
|
|
|
85 |
"WORKERS": {
|
86 |
"description": "Number of workers to run the bot.",
|
87 |
"required": false,
|
|
|
82 |
"required": false,
|
83 |
"value": " "
|
84 |
},
|
85 |
+
"GENIUS_API" : {
|
86 |
+
"description": "Your Lyrics Genius Api Token. To fetch lyrics of songs",
|
87 |
+
"required": false,
|
88 |
+
"value": ""
|
89 |
+
},
|
90 |
"WORKERS": {
|
91 |
"description": "Number of workers to run the bot.",
|
92 |
"required": false,
|
requirements.txt
CHANGED
@@ -9,6 +9,7 @@ charset-normalizer==2.1.0; python_version >= "3.7" and python_version < "4" and
|
|
9 |
dnspython==2.2.1; python_version >= "3.6" and python_version < "4.0"
|
10 |
google==3.0.0
|
11 |
gpytranslate==1.4.0; python_version >= "3.6"
|
|
|
12 |
lxml==4.9.1; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0"
|
13 |
prettyconf==2.2.1
|
14 |
pyaes==1.6.1; python_version >= "3.6" and python_version < "4.0"
|
|
|
9 |
dnspython==2.2.1; python_version >= "3.6" and python_version < "4.0"
|
10 |
google==3.0.0
|
11 |
gpytranslate==1.4.0; python_version >= "3.6"
|
12 |
+
lyricsgenius==3.0.1
|
13 |
lxml==4.9.1; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0"
|
14 |
prettyconf==2.2.1
|
15 |
pyaes==1.6.1; python_version >= "3.6" and python_version < "4.0"
|