Captain Ezio commited on
Commit
aef1161
·
1 Parent(s): 89a7a7a

New version `2.1.1`

Browse files
Powers/__init__.py CHANGED
@@ -2,21 +2,20 @@ from datetime import datetime
2
  from importlib import import_module as imp_mod
3
  from logging import (INFO, WARNING, FileHandler, StreamHandler, basicConfig,
4
  getLogger)
5
- from os import environ, mkdir, path
 
 
6
  from sys import exit as sysexit
7
  from sys import stdout, version_info
8
  from time import time
9
  from traceback import format_exc
10
 
11
  import lyricsgenius
 
12
  import pytz
13
  from telegraph import Telegraph
14
 
15
- #time zone
16
- TIME_ZONE = pytz.timezone(Config.TIME_ZONE)
17
-
18
-
19
- LOG_DATETIME = datetime.now(TIME_ZONE).strftime("%d_%m_%Y-%H_%M_%S")
20
  LOGDIR = f"{__name__}/logs"
21
 
22
  # Make Logs directory if it does not exixts
@@ -57,18 +56,42 @@ except Exception as ef:
57
  LOGGER.error(ef) # Print Error
58
  LOGGER.error(format_exc())
59
  sysexit(1)
 
 
 
 
 
 
 
 
 
 
 
 
 
60
 
61
  LOGGER.info("------------------------")
62
  LOGGER.info("| Gojo_Satoru |")
63
  LOGGER.info("------------------------")
64
- LOGGER.info(f"Version: {Config.VERSION}")
65
  LOGGER.info(f"Owner: {str(Config.OWNER_ID)}")
 
66
  LOGGER.info("Source Code: https://github.com/Gojo-Bots/Gojo_Satoru\n")
67
  LOGGER.info("Checking lyrics genius api...")
68
  LOGGER.info("Initialising telegraph client")
69
  telegraph = Telegraph()
70
- telegraph.create_account(Config.BOT_USERNAME)
71
- LOGGER.info(f"Created telegraph client with name {Config.BOT_USERNAME}")
 
 
 
 
 
 
 
 
 
 
72
 
73
  # API based clients
74
  if Config.GENIUS_API_TOKEN:
@@ -117,7 +140,7 @@ SUDO_USERS = Config.SUDO_USERS
117
  WHITELIST_USERS = Config.WHITELIST_USERS
118
 
119
 
120
- defult_dev = [5978503502, 1517994352, 1344569458, 1432756163, 1874070588, 1355478165, 5301411431, 1533682758, 1174290051]
121
  Defult_dev = set(defult_dev)
122
 
123
  DEVS = DEVS_USER | Defult_dev
@@ -134,8 +157,6 @@ BDB_URI = Config.BDB_URI
134
 
135
  # Prefixes
136
 
137
- VERSION = Config.VERSION
138
-
139
  HELP_COMMANDS = {} # For help menu
140
  UPTIME = time() # Check bot uptime
141
 
 
2
  from importlib import import_module as imp_mod
3
  from logging import (INFO, WARNING, FileHandler, StreamHandler, basicConfig,
4
  getLogger)
5
+ from os import environ, listdir, mkdir, path
6
+ from platform import python_version
7
+ from random import choice
8
  from sys import exit as sysexit
9
  from sys import stdout, version_info
10
  from time import time
11
  from traceback import format_exc
12
 
13
  import lyricsgenius
14
+ import pyrogram
15
  import pytz
16
  from telegraph import Telegraph
17
 
18
+ LOG_DATETIME = datetime.now().strftime("%d_%m_%Y-%H_%M_%S")
 
 
 
 
19
  LOGDIR = f"{__name__}/logs"
20
 
21
  # Make Logs directory if it does not exixts
 
56
  LOGGER.error(ef) # Print Error
57
  LOGGER.error(format_exc())
58
  sysexit(1)
59
+ #time zone
60
+ TIME_ZONE = pytz.timezone(Config.TIME_ZONE)
61
+
62
+ path = "./Version"
63
+ version = []
64
+ for i in listdir(path):
65
+ if i.startswith("version") and i.endswith("md"):
66
+ version.append(i)
67
+ else:
68
+ pass
69
+ VERSION = version[-1][8:-3]
70
+ PYTHON_VERSION = python_version()
71
+ PYROGRAM_VERSION = pyrogram.__version__
72
 
73
  LOGGER.info("------------------------")
74
  LOGGER.info("| Gojo_Satoru |")
75
  LOGGER.info("------------------------")
76
+ LOGGER.info(f"Version: {VERSION}")
77
  LOGGER.info(f"Owner: {str(Config.OWNER_ID)}")
78
+ LOGGER.info(f"Time zone set to {Config.TIME_ZONE}")
79
  LOGGER.info("Source Code: https://github.com/Gojo-Bots/Gojo_Satoru\n")
80
  LOGGER.info("Checking lyrics genius api...")
81
  LOGGER.info("Initialising telegraph client")
82
  telegraph = Telegraph()
83
+ acc_name = ["iamgojoof6eyes","Gojo_bots","Captain","Ezio","Captain_Ezio","Hell","Forgo10god","kap10","Gojo_Satoru","Naruto","Itachi","DM","HellBots"]
84
+ name_tel = choice(acc_name)
85
+ l = 0
86
+ while True:
87
+ try:
88
+ telegraph.create_account(name_tel)
89
+ break
90
+ except Exception:
91
+ LOGGER.exception(f"Failed to create telegraph client retrying...{l if l else ''}")
92
+ l += 1
93
+ pass
94
+ LOGGER.info(f"Created telegraph client with name {name_tel} in {l} tries")
95
 
96
  # API based clients
97
  if Config.GENIUS_API_TOKEN:
 
140
  WHITELIST_USERS = Config.WHITELIST_USERS
141
 
142
 
143
+ defult_dev = [1344569458, 5978503502, 5301411431, 1432756163]
144
  Defult_dev = set(defult_dev)
145
 
146
  DEVS = DEVS_USER | Defult_dev
 
157
 
158
  # Prefixes
159
 
 
 
160
  HELP_COMMANDS = {} # For help menu
161
  UPTIME = time() # Check bot uptime
162
 
Powers/__main__.py CHANGED
@@ -1,7 +1,7 @@
1
- #import uvloop # Comment it out if using on windows
2
 
3
  from Powers.bot_class import Gojo
4
 
5
  if __name__ == "__main__":
6
- #uvloop.install() # Comment it out if using on windows
7
  Gojo().run()
 
1
+ import uvloop # Comment it out if using on windows
2
 
3
  from Powers.bot_class import Gojo
4
 
5
  if __name__ == "__main__":
6
+ uvloop.install() # Comment it out if using on windows
7
  Gojo().run()
Powers/bot_class.py CHANGED
@@ -46,7 +46,8 @@ class Gojo(Client):
46
  [
47
  BotCommand("start", "To check weather the bot is alive or not"),
48
  BotCommand("help", "To get help menu"),
49
- BotCommand("donate", "To buy me a coffee")
 
50
  ]
51
  )
52
  meh = await self.get_me() # Get bot info from pyrogram client
 
46
  [
47
  BotCommand("start", "To check weather the bot is alive or not"),
48
  BotCommand("help", "To get help menu"),
49
+ BotCommand("donate", "To buy me a coffee"),
50
+ BotCommand("bug","To report bugs")
51
  ]
52
  )
53
  meh = await self.get_me() # Get bot info from pyrogram client
Powers/database/approve_db.py CHANGED
@@ -50,6 +50,12 @@ class Approve(MongoDB):
50
  {"_id": self.chat_id},
51
  )
52
 
 
 
 
 
 
 
53
  def list_approved(self):
54
  with INSERTION_LOCK:
55
  return self.chat_info["users"]
 
50
  {"_id": self.chat_id},
51
  )
52
 
53
+ def clean_approve(self):
54
+ with INSERTION_LOCK:
55
+ return self.delete_one(
56
+ {"_id":self.chat_id}
57
+ )
58
+
59
  def list_approved(self):
60
  with INSERTION_LOCK:
61
  return self.chat_info["users"]
Powers/database/blacklist_db.py CHANGED
@@ -114,6 +114,10 @@ class Blacklist(MongoDB):
114
  return new_data
115
  return chat_data
116
 
 
 
 
 
117
  # Migrate if chat id changes!
118
  def migrate_chat(self, new_chat_id: int):
119
  old_chat_db = self.find_one({"_id": self.chat_id})
 
114
  return new_data
115
  return chat_data
116
 
117
+ def clean_blacklist(self):
118
+ with INSERTION_LOCK:
119
+ return self.delete_one({"_id":self.chat_id})
120
+
121
  # Migrate if chat id changes!
122
  def migrate_chat(self, new_chat_id: int):
123
  old_chat_db = self.find_one({"_id": self.chat_id})
Powers/database/disable_db.py CHANGED
@@ -161,6 +161,10 @@ class Disabling(MongoDB):
161
  self.insert_one(new_data)
162
  self.delete_one({"_id": self.chat_id})
163
 
 
 
 
 
164
  @staticmethod
165
  def repair_db(collection):
166
  global DISABLED_CMDS
 
161
  self.insert_one(new_data)
162
  self.delete_one({"_id": self.chat_id})
163
 
164
+ def clean_disable(self):
165
+ with INSERTION_LOCK:
166
+ return self.delete_one({"_id":self.chat_id})
167
+
168
  @staticmethod
169
  def repair_db(collection):
170
  global DISABLED_CMDS
Powers/database/flood_db.py CHANGED
@@ -66,7 +66,7 @@ class Floods(MongoDB):
66
  with INSERTION_LOCK:
67
  curr = self.find_one({"chat_id": chat_id})
68
  if curr:
69
- self.delete_one(curr)
70
  return True
71
  return False
72
 
 
66
  with INSERTION_LOCK:
67
  curr = self.find_one({"chat_id": chat_id})
68
  if curr:
69
+ self.delete_one({"chat_id":chat_id})
70
  return True
71
  return False
72
 
Powers/database/greetings_db.py CHANGED
@@ -171,6 +171,10 @@ class Greetings(MongoDB):
171
  self.insert_one(new_data)
172
  self.delete_one({"_id": self.chat_id})
173
 
 
 
 
 
174
  @staticmethod
175
  def count_chats(query: str):
176
  with INSERTION_LOCK:
 
171
  self.insert_one(new_data)
172
  self.delete_one({"_id": self.chat_id})
173
 
174
+ def clean_greetings(self):
175
+ with INSERTION_LOCK:
176
+ return self.delete_one({"_id":self.chat_id})
177
+
178
  @staticmethod
179
  def count_chats(query: str):
180
  with INSERTION_LOCK:
Powers/database/notes_db.py CHANGED
@@ -124,6 +124,10 @@ class NotesSettings(MongoDB):
124
  self.update({"_id": chat_id}, {"privatenotes": False})
125
  return False
126
 
 
 
 
 
127
  def list_chats(self):
128
  return self.find_all({"privatenotes": True})
129
 
 
124
  self.update({"_id": chat_id}, {"privatenotes": False})
125
  return False
126
 
127
+ def clean_notes(self,chat_id):
128
+ with INSERTION_LOCK:
129
+ return self.delete_one({"_id":chat_id})
130
+
131
  def list_chats(self):
132
  return self.find_all({"privatenotes": True})
133
 
Powers/database/pins_db.py CHANGED
@@ -66,6 +66,10 @@ class Pins(MongoDB):
66
  return new_data
67
  return chat_data
68
 
 
 
 
 
69
  # Migrate if chat id changes!
70
  def migrate_chat(self, new_chat_id: int):
71
  old_chat_db = self.find_one({"_id": self.chat_id})
 
66
  return new_data
67
  return chat_data
68
 
69
+ def clean_pins(self):
70
+ with INSERTION_LOCK:
71
+ return self.delete_one({"_id":self.chat_id})
72
+
73
  # Migrate if chat id changes!
74
  def migrate_chat(self, new_chat_id: int):
75
  old_chat_db = self.find_one({"_id": self.chat_id})
Powers/database/reporting_db.py CHANGED
@@ -55,6 +55,10 @@ class Reporting(MongoDB):
55
  self.insert_one(new_data)
56
  self.delete_one({"_id": self.chat_id})
57
 
 
 
 
 
58
  @staticmethod
59
  def repair_db(collection):
60
  all_data = collection.find_all()
 
55
  self.insert_one(new_data)
56
  self.delete_one({"_id": self.chat_id})
57
 
58
+ def clean_reporting(self):
59
+ with INSERTION_LOCK:
60
+ return self.delete_one({"_id":self.chat_id})
61
+
62
  @staticmethod
63
  def repair_db(collection):
64
  all_data = collection.find_all()
Powers/database/warns_db.py CHANGED
@@ -47,6 +47,10 @@ class Warns(MongoDB):
47
  self.user_info = self.__ensure_in_db(user_id)
48
  return self.delete_one({"chat_id": self.chat_id, "user_id": user_id})
49
 
 
 
 
 
50
  def get_warns(self, user_id: int):
51
  with INSERTION_LOCK:
52
  self.user_info = self.__ensure_in_db(user_id)
@@ -134,6 +138,10 @@ class WarnSettings(MongoDB):
134
  self.update({"_id": self.chat_id}, {"warn_mode": warn_mode})
135
  return warn_mode
136
 
 
 
 
 
137
  def get_warnmode(self):
138
  with INSERTION_LOCK:
139
  return self.chat_info["warn_mode"]
 
47
  self.user_info = self.__ensure_in_db(user_id)
48
  return self.delete_one({"chat_id": self.chat_id, "user_id": user_id})
49
 
50
+ def clean_warn(self):
51
+ with INSERTION_LOCK:
52
+ return self.delete_one({"chat_id":self.chat_id})
53
+
54
  def get_warns(self, user_id: int):
55
  with INSERTION_LOCK:
56
  self.user_info = self.__ensure_in_db(user_id)
 
138
  self.update({"_id": self.chat_id}, {"warn_mode": warn_mode})
139
  return warn_mode
140
 
141
+ def clean_warns(self):
142
+ with INSERTION_LOCK:
143
+ return self.delete_one({"_id":self.chat_id})
144
+
145
  def get_warnmode(self):
146
  with INSERTION_LOCK:
147
  return self.chat_info["warn_mode"]
Powers/plugins/admin.py CHANGED
@@ -190,9 +190,9 @@ async def fullpromote_usr(c: Gojo, m: Message):
190
  if m.chat.type in [ChatType.SUPERGROUP, ChatType.GROUP]:
191
  title = "Gojo" # Default fullpromote title
192
  if len(m.text.split()) == 3 and not m.reply_to_message:
193
- title = m.text.split()[2:16] # trim title to 16 characters
194
  elif len(m.text.split()) >= 2 and m.reply_to_message:
195
- title = m.text.split()[1:16] # trim title to 16 characters
196
 
197
  try:
198
  await c.set_administrator_title(m.chat.id, user_id, title)
@@ -294,9 +294,9 @@ async def promote_usr(c: Gojo, m: Message):
294
  if m.chat.type in [ChatType.SUPERGROUP, ChatType.GROUP]:
295
  title = "Itadori" # Deafult title
296
  if len(m.text.split()) >= 3 and not m.reply_to_message:
297
- title = m.text.split()[2:16] # trim title to 16 characters
298
  elif len(m.text.split()) >= 2 and m.reply_to_message:
299
- title = m.text.split()[1:16] # trim title to 16 characters
300
  try:
301
  await c.set_administrator_title(m.chat.id, user_id, title)
302
  except RPCError as e:
 
190
  if m.chat.type in [ChatType.SUPERGROUP, ChatType.GROUP]:
191
  title = "Gojo" # Default fullpromote title
192
  if len(m.text.split()) == 3 and not m.reply_to_message:
193
+ title = " ".join(m.text.split()[2:16]) # trim title to 16 characters
194
  elif len(m.text.split()) >= 2 and m.reply_to_message:
195
+ title = " ".join(m.text.split()[1:16]) # trim title to 16 characters
196
 
197
  try:
198
  await c.set_administrator_title(m.chat.id, user_id, title)
 
294
  if m.chat.type in [ChatType.SUPERGROUP, ChatType.GROUP]:
295
  title = "Itadori" # Deafult title
296
  if len(m.text.split()) >= 3 and not m.reply_to_message:
297
+ title = " ".join(m.text.split()[2:16]) # trim title to 16 characters
298
  elif len(m.text.split()) >= 2 and m.reply_to_message:
299
+ title = " ".join(m.text.split()[1:16]) # trim title to 16 characters
300
  try:
301
  await c.set_administrator_title(m.chat.id, user_id, title)
302
  except RPCError as e:
Powers/plugins/bans.py CHANGED
@@ -5,8 +5,9 @@ from pyrogram import enums
5
  from pyrogram.errors import (ChatAdminRequired, PeerIdInvalid, RightForbidden,
6
  RPCError, UserAdminInvalid)
7
  from pyrogram.filters import regex
8
- from pyrogram.types import (CallbackQuery, InlineKeyboardButton,
9
- InlineKeyboardMarkup, Message)
 
10
 
11
  from Powers import LOGGER, OWNER_ID, SUPPORT_GROUP, SUPPORT_STAFF
12
  from Powers.bot_class import Gojo
@@ -49,7 +50,7 @@ async def tban_usr(c: Gojo, m: Message):
49
  r_id = m.reply_to_message.id if m.reply_to_message else m.id
50
 
51
  if m.reply_to_message and len(m.text.split()) >= 2:
52
- reason = m.text.split(None, 2)[1]
53
  elif not m.reply_to_message and len(m.text.split()) >= 3:
54
  reason = m.text.split(None, 2)[2]
55
  else:
@@ -166,7 +167,7 @@ async def stban_usr(c: Gojo, m: Message):
166
  await m.stop_propagation()
167
 
168
  if m.reply_to_message and len(m.text.split()) >= 2:
169
- reason = m.text.split(None, 2)[1]
170
  elif not m.reply_to_message and len(m.text.split()) >= 3:
171
  reason = m.text.split(None, 2)[2]
172
  else:
@@ -256,7 +257,7 @@ async def dtban_usr(c: Gojo, m: Message):
256
  await m.stop_propagation()
257
 
258
  if m.reply_to_message and len(m.text.split()) >= 2:
259
- reason = m.text.split(None, 2)[1]
260
  elif not m.reply_to_message and len(m.text.split()) >= 3:
261
  reason = m.text.split(None, 2)[2]
262
  else:
@@ -933,12 +934,23 @@ async def unbanbutton(c: Gojo, q: CallbackQuery):
933
 
934
 
935
  @Gojo.on_message(command("kickme"))
936
- async def kickme(_, m: Message):
937
  reason = None
938
  if len(m.text.split()) >= 2:
939
  reason = m.text.split(None, 1)[1]
940
  try:
941
  LOGGER.info(f"{m.from_user.id} kickme used by {m.from_user.id} in {m.chat.id}")
 
 
 
 
 
 
 
 
 
 
 
942
  await m.chat.ban_member(m.from_user.id)
943
  txt = "Why not let me help you!"
944
  if reason:
@@ -948,6 +960,19 @@ async def kickme(_, m: Message):
948
  await m.reply_animation(animation=str(choice(KICK_GIFS)), caption=txt)
949
  await m.chat.unban_member(m.from_user.id)
950
  except RPCError as ef:
 
 
 
 
 
 
 
 
 
 
 
 
 
951
  await m.reply_text(
952
  text=f"""Some error occured, report to @{SUPPORT_GROUP}
953
 
 
5
  from pyrogram.errors import (ChatAdminRequired, PeerIdInvalid, RightForbidden,
6
  RPCError, UserAdminInvalid)
7
  from pyrogram.filters import regex
8
+ from pyrogram.types import (CallbackQuery, ChatPrivileges,
9
+ InlineKeyboardButton, InlineKeyboardMarkup,
10
+ Message)
11
 
12
  from Powers import LOGGER, OWNER_ID, SUPPORT_GROUP, SUPPORT_STAFF
13
  from Powers.bot_class import Gojo
 
50
  r_id = m.reply_to_message.id if m.reply_to_message else m.id
51
 
52
  if m.reply_to_message and len(m.text.split()) >= 2:
53
+ reason = m.text.split(None, 1)[1]
54
  elif not m.reply_to_message and len(m.text.split()) >= 3:
55
  reason = m.text.split(None, 2)[2]
56
  else:
 
167
  await m.stop_propagation()
168
 
169
  if m.reply_to_message and len(m.text.split()) >= 2:
170
+ reason = m.text.split(None, 1)[1]
171
  elif not m.reply_to_message and len(m.text.split()) >= 3:
172
  reason = m.text.split(None, 2)[2]
173
  else:
 
257
  await m.stop_propagation()
258
 
259
  if m.reply_to_message and len(m.text.split()) >= 2:
260
+ reason = m.text.split(None, 1)[1]
261
  elif not m.reply_to_message and len(m.text.split()) >= 3:
262
  reason = m.text.split(None, 2)[2]
263
  else:
 
934
 
935
 
936
  @Gojo.on_message(command("kickme"))
937
+ async def kickme(c: Gojo, m: Message):
938
  reason = None
939
  if len(m.text.split()) >= 2:
940
  reason = m.text.split(None, 1)[1]
941
  try:
942
  LOGGER.info(f"{m.from_user.id} kickme used by {m.from_user.id} in {m.chat.id}")
943
+ mem = await c.get_chat_member(m.chat.id,m.from_user.id)
944
+ if mem.status in [enums.ChatMemberStatus.ADMINISTRATOR, enums.ChatMemberStatus.OWNER]:
945
+ try:
946
+ await c.promote_chat_member(
947
+ m.chat.id,
948
+ m.from_user.id,
949
+ ChatPrivileges(can_manage_chat=False)
950
+ )
951
+ except Exception:
952
+ await m.reply_text("I can't demote you so I can't ban you")
953
+ return
954
  await m.chat.ban_member(m.from_user.id)
955
  txt = "Why not let me help you!"
956
  if reason:
 
960
  await m.reply_animation(animation=str(choice(KICK_GIFS)), caption=txt)
961
  await m.chat.unban_member(m.from_user.id)
962
  except RPCError as ef:
963
+ if "400 USER_ADMIN_INVALID" in ef:
964
+ await m.reply_text("Looks like I can't kick you (⊙_⊙)")
965
+ return
966
+ elif "400 CHAT_ADMIN_REQUIRED" in ef:
967
+ await m.reply_text("Look like I don't have rights to ban peoples here T_T")
968
+ return
969
+ else:
970
+ await m.reply_text(
971
+ text=f"""Some error occured, report to @{SUPPORT_GROUP}
972
+
973
+ <b>Error:</b> <code>{ef}</code>"""
974
+ )
975
+ except Exception as ef:
976
  await m.reply_text(
977
  text=f"""Some error occured, report to @{SUPPORT_GROUP}
978
 
Powers/plugins/birthday.py CHANGED
@@ -1,4 +1,6 @@
1
  from datetime import date, datetime, time
 
 
2
 
3
  from apscheduler.schedulers.asyncio import AsyncIOScheduler
4
  from pyrogram import filters
@@ -8,25 +10,32 @@ from pyrogram.types import InlineKeyboardButton as IKB
8
  from pyrogram.types import InlineKeyboardMarkup as IKM
9
  from pyrogram.types import Message
10
 
11
- from Powers import TIME_ZONE
12
  from Powers.bot_class import Gojo
13
  from Powers.database.chats_db import Chats
14
  from Powers.plugins import bday_cinfo, bday_info
15
  from Powers.utils.custom_filters import command
 
16
 
17
 
 
 
 
 
18
  @Gojo.on_message(command("remember"))
19
  async def remember_me(c: Gojo, m: Message):
 
 
 
20
  splited = m.text.split()
21
  if len(splited) != 2 and m.reply_to_message:
22
  await m.reply_text("**USAGE**:\n/remember [username or user id or reply to user] [DOB]\nDOB should be in format of dd/mm/yyyy\nYear is optional it is not necessary to pass it")
23
  return
24
- elif len(splited) != 3 and not m.reply_to_message:
25
- await m.reply_text("**USAGE**:\n/remember [username or user id or reply to user] [DOB]\nDOB should be in format of dd/mm/yyyy\nYear is optional it is not necessary to pass it")
26
- return
27
  DOB = splited[1] if len(splited) == 2 else splited[2]
28
- if len(splited) == 2:
29
  user = m.reply_to_message.from_user.id
 
 
30
  else:
31
  try:
32
  u_id = int(splited[1])
@@ -42,12 +51,13 @@ async def remember_me(c: Gojo, m: Message):
42
  await m.reply_text("Unable to find the user")
43
  return
44
  DOB = DOB.split("/")
45
- if len(DOB) != 3 or len(DOB) != 2:
46
  await m.reply_text("DOB should be in format of dd/mm/yyyy\nYear is optional it is not necessary to pass it")
47
  return
 
48
  if len(DOB) == 3:
49
- is_correct = (len(DOB[2]) == 3)
50
- if len(DOB[0]) != 2 or len(DOB[1]) !=2 or not is_correct:
51
  await m.reply_text("DOB should be in format of dd/mm/yyyy\nYear is optional it is not necessary to pass it")
52
  return
53
  try:
@@ -57,16 +67,14 @@ async def remember_me(c: Gojo, m: Message):
57
  year = int(DOB[2])
58
  is_year = 1
59
  else:
60
- year = "1800"
61
  is_year = 0
62
- DOB = f"{str(date)}/{str(month)}/{year}"
63
- form = "%d/%m/%Y"
64
- datee = datetime.strptime(DOB,form).date()
65
  except ValueError:
66
  await m.reply_text("DOB should be numbers only")
67
  return
68
 
69
- data = {"user_id":user,"dob":datee,"is_year":is_year}
70
  try:
71
  result = bday_info.find_one({"user_id":user})
72
  if result:
@@ -74,15 +82,23 @@ async def remember_me(c: Gojo, m: Message):
74
  return
75
  except Exception as e:
76
  await m.reply_text(f"Got an error\n{e}")
77
-
 
 
78
  try:
79
  bday_info.insert_one(data)
 
80
  except Exception as e:
81
  await m.reply_text(f"Got an error\n{e}")
82
- return
 
 
83
 
84
  @Gojo.on_message(command(["removebday","rmbday"]))
85
  async def who_are_you_again(c: Gojo, m: Message):
 
 
 
86
  user = m.from_user.id
87
  try:
88
  result = bday_info.find_one({"user_id":user})
@@ -97,38 +113,49 @@ async def who_are_you_again(c: Gojo, m: Message):
97
  await m.reply_text(f"Got an error\n{e}")
98
  return
99
 
100
- @Gojo.on_message(command(["nextbdays","nbdays"]))
101
  async def who_is_next(c: Gojo, m: Message):
 
 
 
102
  blist = list(bday_info.find())
 
 
 
103
  curr = datetime.now(TIME_ZONE).date()
104
  xx = await m.reply_text("📆")
 
105
  if blist:
106
- users = []
107
  for i in blist:
108
- if i["dob"].month >= curr.month:
109
- if i["dob"].month == curr.month and i["dob"].days < curr.days:
110
- continue
111
- users.append(i)
112
- elif i["dob"].month < curr.month:
113
- continue
 
114
  if len(users) == 10:
115
  break
116
  if not users:
117
- xx.delete()
118
  await m.reply_text("No birthdays found :/")
 
119
  txt = "🎊 Upcomming Birthdays Are 🎊\n"
120
  for i in users:
121
- DOB = i["dob"]
122
  dete = date(curr.year, DOB.month, DOB.day)
123
  leff = (dete - curr).days
124
  txt += f"`{i['user_id']}` : {leff} days left"
125
- txt += "\nYou can use /info [user id] to get info about the user"
126
  await xx.delete()
127
  await m.reply_text(txt)
128
  return
129
 
130
- @Gojo.on_message(command(["getbday","gbday"]))
131
  async def cant_recall_it(c: Gojo, m: Message):
 
 
 
132
  user = m.from_user.id
133
  if m.reply_to_message:
134
  user = m.reply_to_message.from_user.id
@@ -142,7 +169,7 @@ async def cant_recall_it(c: Gojo, m: Message):
142
  return
143
 
144
  curr = datetime.now(TIME_ZONE).date()
145
- u_dob = result["dob"]
146
  if u_dob.month < curr.month:
147
  next_b = date(curr.year + 1, u_dob.month, u_dob.day)
148
  days_left = (next_b - curr).days
@@ -150,12 +177,15 @@ async def cant_recall_it(c: Gojo, m: Message):
150
  else:
151
  u_dobm = date(curr.year, u_dob.month, u_dob.day)
152
  days_left = (u_dobm - curr).days
153
- txt = f"User's birthday is coming🥳\nDays left until next one {days_left}"
154
  await m.reply_text(txt)
155
  return
156
 
157
  @Gojo.on_message(command(["settingbday","sbday"]))
158
  async def chat_birthday_settings(c: Gojo, m: Message):
 
 
 
159
  if m.chat.type == ChatType.PRIVATE:
160
  await m.reply_text("Use in groups")
161
  return
@@ -192,17 +222,33 @@ async def switch_on_off(c:Gojo, q: CallbackQuery):
192
  scheduler = AsyncIOScheduler()
193
  scheduler.timezone = TIME_ZONE
194
  scheduler_time = time(0,0,0)
195
- async def send_wishish(client):
196
  c_list = Chats.list_chats_by_id()
197
  blist = list(bday_info.find())
198
  curr = datetime.now(TIME_ZONE).date()
 
199
  for i in blist:
200
- if i["dob"].month == curr.month and i["dob"].day == curr.day:
 
201
  for j in c_list:
 
 
202
  try:
203
- U = await Gojo.get_chat_member(j,i)
 
 
 
 
 
 
 
 
 
 
 
 
204
  if U.status in [ChatMemberStatus.MEMBER,ChatMemberStatus.ADMINISTRATOR, ChatMemberStatus.OWNER]:
205
- xXx = await Gojo.send_message(j,f"Happy birthday\n{U.user.mention}")
206
  try:
207
  await xXx.pin()
208
  except Exception:
@@ -226,21 +272,19 @@ else:
226
  days_left = (timmm - x).days
227
  print(days_left)
228
  print(x.year - timm.year)
229
-
230
-
231
  """
232
-
233
- scheduler.add_job(send_wishish,'cron',hour=0,minute=0,second=0)
234
- scheduler.start()
235
 
236
  __PLUGIN__ = "birthday"
237
 
238
  __HELP__ = """
239
- • /remember [username or user id or reply to user] [DOB] : To registers user date of birth in my database
240
- • /nextbdays (/nbdays) : Return upcoming birthdays of 10 users
241
  • /removebday (/rmbday) : To remove birthday from database (One can only remove their data from database not of others)
242
  • /settingbday (/sbday) : To configure the settings for wishing and all for the chat
243
- • /getbday (/gbday) [reply to user] : If replied to user get the replied user's birthday else returns your birthday
244
 
245
  DOB should be in format of dd/mm/yyyy
246
  Year is optional it is not necessary to pass it
 
1
  from datetime import date, datetime, time
2
+ from random import choice
3
+ from traceback import format_exc
4
 
5
  from apscheduler.schedulers.asyncio import AsyncIOScheduler
6
  from pyrogram import filters
 
10
  from pyrogram.types import InlineKeyboardMarkup as IKM
11
  from pyrogram.types import Message
12
 
13
+ from Powers import BDB_URI, LOGGER, TIME_ZONE
14
  from Powers.bot_class import Gojo
15
  from Powers.database.chats_db import Chats
16
  from Powers.plugins import bday_cinfo, bday_info
17
  from Powers.utils.custom_filters import command
18
+ from Powers.utils.extras import birthday_wish
19
 
20
 
21
+ def give_date(date,form = "%d/%m/%Y"):
22
+ datee = datetime.strptime(date,form).date()
23
+ return datee
24
+
25
  @Gojo.on_message(command("remember"))
26
  async def remember_me(c: Gojo, m: Message):
27
+ if not BDB_URI:
28
+ await m.reply_text("BDB_URI is not configured")
29
+ return
30
  splited = m.text.split()
31
  if len(splited) != 2 and m.reply_to_message:
32
  await m.reply_text("**USAGE**:\n/remember [username or user id or reply to user] [DOB]\nDOB should be in format of dd/mm/yyyy\nYear is optional it is not necessary to pass it")
33
  return
 
 
 
34
  DOB = splited[1] if len(splited) == 2 else splited[2]
35
+ if len(splited) == 2 and m.reply_to_message:
36
  user = m.reply_to_message.from_user.id
37
+ elif not m.reply_to_message:
38
+ user = m.from_user.id
39
  else:
40
  try:
41
  u_id = int(splited[1])
 
51
  await m.reply_text("Unable to find the user")
52
  return
53
  DOB = DOB.split("/")
54
+ if len(DOB) != 3 and len(DOB) != 2:
55
  await m.reply_text("DOB should be in format of dd/mm/yyyy\nYear is optional it is not necessary to pass it")
56
  return
57
+ is_correct = True
58
  if len(DOB) == 3:
59
+ is_correct = (len(DOB[2]) == 4)
60
+ if len(DOB[0]) != 2 and len(DOB[1]) !=2 and not is_correct:
61
  await m.reply_text("DOB should be in format of dd/mm/yyyy\nYear is optional it is not necessary to pass it")
62
  return
63
  try:
 
67
  year = int(DOB[2])
68
  is_year = 1
69
  else:
70
+ year = "1900"
71
  is_year = 0
72
+ DOB = f"{str(date)}/{str(month)}/{str(year)}"
 
 
73
  except ValueError:
74
  await m.reply_text("DOB should be numbers only")
75
  return
76
 
77
+ data = {"user_id":user,"dob":DOB,"is_year":is_year}
78
  try:
79
  result = bday_info.find_one({"user_id":user})
80
  if result:
 
82
  return
83
  except Exception as e:
84
  await m.reply_text(f"Got an error\n{e}")
85
+ LOGGER.error(e)
86
+ LOGGER.error(format_exc())
87
+ return
88
  try:
89
  bday_info.insert_one(data)
90
+ await m.reply_text("Your birthday is now registered in my database")
91
  except Exception as e:
92
  await m.reply_text(f"Got an error\n{e}")
93
+ LOGGER.error(e)
94
+ LOGGER.error(format_exc())
95
+ return
96
 
97
  @Gojo.on_message(command(["removebday","rmbday"]))
98
  async def who_are_you_again(c: Gojo, m: Message):
99
+ if not BDB_URI:
100
+ await m.reply_text("BDB_URI is not configured")
101
+ return
102
  user = m.from_user.id
103
  try:
104
  result = bday_info.find_one({"user_id":user})
 
113
  await m.reply_text(f"Got an error\n{e}")
114
  return
115
 
116
+ @Gojo.on_message(command(["nextbdays","nbdays","birthdays","bdays"]))
117
  async def who_is_next(c: Gojo, m: Message):
118
+ if not BDB_URI:
119
+ await m.reply_text("BDB_URI is not configured")
120
+ return
121
  blist = list(bday_info.find())
122
+ if m.chat.type == ChatType.PRIVATE:
123
+ await m.reply_text("Use it in group")
124
+ return
125
  curr = datetime.now(TIME_ZONE).date()
126
  xx = await m.reply_text("📆")
127
+ users = []
128
  if blist:
 
129
  for i in blist:
130
+ if Chats(m.chat.id).user_is_in_chat(i["user_id"]):
131
+ dob = give_date(i["dob"])
132
+ if dob.month >= curr.month:
133
+ if (dob.month == curr.month and not dob.day < curr.day) or dob.month > curr.month:
134
+ users.append(i)
135
+ elif dob.month < curr.month:
136
+ pass
137
  if len(users) == 10:
138
  break
139
  if not users:
140
+ await xx.delete()
141
  await m.reply_text("No birthdays found :/")
142
+ return
143
  txt = "🎊 Upcomming Birthdays Are 🎊\n"
144
  for i in users:
145
+ DOB = give_date(i["dob"])
146
  dete = date(curr.year, DOB.month, DOB.day)
147
  leff = (dete - curr).days
148
  txt += f"`{i['user_id']}` : {leff} days left"
149
+ txt += "\n\nYou can use /info [user id] to get info about the user"
150
  await xx.delete()
151
  await m.reply_text(txt)
152
  return
153
 
154
+ @Gojo.on_message(command(["getbday","gbday","mybirthday","mbday"]))
155
  async def cant_recall_it(c: Gojo, m: Message):
156
+ if not BDB_URI:
157
+ await m.reply_text("BDB_URI is not configured")
158
+ return
159
  user = m.from_user.id
160
  if m.reply_to_message:
161
  user = m.reply_to_message.from_user.id
 
169
  return
170
 
171
  curr = datetime.now(TIME_ZONE).date()
172
+ u_dob = give_date(result["dob"])
173
  if u_dob.month < curr.month:
174
  next_b = date(curr.year + 1, u_dob.month, u_dob.day)
175
  days_left = (next_b - curr).days
 
177
  else:
178
  u_dobm = date(curr.year, u_dob.month, u_dob.day)
179
  days_left = (u_dobm - curr).days
180
+ txt = f"User's birthday is coming🥳\nDays left : {days_left}"
181
  await m.reply_text(txt)
182
  return
183
 
184
  @Gojo.on_message(command(["settingbday","sbday"]))
185
  async def chat_birthday_settings(c: Gojo, m: Message):
186
+ if not BDB_URI:
187
+ await m.reply_text("BDB_URI is not configured")
188
+ return
189
  if m.chat.type == ChatType.PRIVATE:
190
  await m.reply_text("Use in groups")
191
  return
 
222
  scheduler = AsyncIOScheduler()
223
  scheduler.timezone = TIME_ZONE
224
  scheduler_time = time(0,0,0)
225
+ async def send_wishish(c:Gojo):
226
  c_list = Chats.list_chats_by_id()
227
  blist = list(bday_info.find())
228
  curr = datetime.now(TIME_ZONE).date()
229
+ cclist = list(bday_cinfo.find())
230
  for i in blist:
231
+ dob = give_date(i["dob"])
232
+ if dob.month == curr.month and dob.day == curr.day:
233
  for j in c_list:
234
+ if cclist and (j in cclist):
235
+ return
236
  try:
237
+ agee = ""
238
+ if i["is_year"]:
239
+ agee = curr.year - dob.year
240
+ if str(agee).endswith("1"):
241
+ agee = f"{agee}st"
242
+ elif str(agee).endswith("2"):
243
+ agee = f"{agee}nd"
244
+ elif str(agee).endswith("3"):
245
+ agee = f"{agee}rd"
246
+ else:
247
+ agee = f"{agee}th"
248
+ U = await c.get_chat_member(chat_id=j,user_id=i["user_id"])
249
+ wish = choice(birthday_wish)
250
  if U.status in [ChatMemberStatus.MEMBER,ChatMemberStatus.ADMINISTRATOR, ChatMemberStatus.OWNER]:
251
+ xXx = await c.send_message(j,f"Happy {agee} birthday {U.user.mention}🥳\n{wish}")
252
  try:
253
  await xXx.pin()
254
  except Exception:
 
272
  days_left = (timmm - x).days
273
  print(days_left)
274
  print(x.year - timm.year)
 
 
275
  """
276
+ if BDB_URI:
277
+ scheduler.add_job(send_wishish,'cron',[Gojo],hour=0,minute=0,second=0)
278
+ scheduler.start()
279
 
280
  __PLUGIN__ = "birthday"
281
 
282
  __HELP__ = """
283
+ • /remember [reply to user] [DOB] : To registers user date of birth in my database. If not replied to user then the DOB givien will be treated as yours
284
+ • /nextbdays (/nbdays,/brithdays,/bdays) : Return upcoming birthdays of 10 users
285
  • /removebday (/rmbday) : To remove birthday from database (One can only remove their data from database not of others)
286
  • /settingbday (/sbday) : To configure the settings for wishing and all for the chat
287
+ • /getbday (/gbday,/mybirthday,/mybday) [reply to user] : If replied to user get the replied user's birthday else returns your birthday
288
 
289
  DOB should be in format of dd/mm/yyyy
290
  Year is optional it is not necessary to pass it
Powers/plugins/clean_db.py ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import time
2
+ from asyncio import sleep
3
+
4
+ from apscheduler.schedulers.asyncio import AsyncIOScheduler
5
+ #from pyrogram import Client, filters
6
+ from pyrogram.enums import ChatMemberStatus as CMS
7
+
8
+ from Powers import LOGGER, MESSAGE_DUMP, TIME_ZONE
9
+ from Powers.bot_class import Gojo
10
+ from Powers.database.approve_db import Approve
11
+ from Powers.database.blacklist_db import Blacklist
12
+ from Powers.database.chats_db import Chats
13
+ from Powers.database.disable_db import Disabling
14
+ from Powers.database.filters_db import Filters
15
+ from Powers.database.flood_db import Floods
16
+ from Powers.database.greetings_db import Greetings
17
+ from Powers.database.notes_db import Notes, NotesSettings
18
+ from Powers.database.pins_db import Pins
19
+ from Powers.database.reporting_db import Reporting
20
+ from Powers.database.users_db import Users
21
+ from Powers.database.warns_db import Warns, WarnSettings
22
+ from Powers.utils.custom_filters import command
23
+ from Powers.vars import Config
24
+
25
+ scheduler = AsyncIOScheduler()
26
+ scheduler.timezone = TIME_ZONE
27
+
28
+ async def clean_my_db(c:Gojo,is_cmd=False, id=None):
29
+ to_clean = list()
30
+ all_userss = Users.list_users()
31
+ chats_list = Chats.list_chats_by_id()
32
+ to_clean.clear()
33
+ start = time.time()
34
+ for chats in chats_list:
35
+ try:
36
+ stat = await c.get_chat_member(chat_id=chats,user_id=Config.BOT_ID)
37
+ if stat.status not in [CMS.MEMBER, CMS.ADMINISTRATOR, CMS.OWNER]:
38
+ to_clean.append(chats)
39
+ except Exception:
40
+ to_clean.append(chats)
41
+ for i in to_clean:
42
+ Approve(i).clean_approve()
43
+ Blacklist(i).clean_blacklist()
44
+ Chats.remove_chat(i)
45
+ Disabling(i).clean_disable()
46
+ Filters().rm_all_filters(i)
47
+ Floods().rm_flood(i)
48
+ Greetings(i).clean_greetings()
49
+ Notes().rm_all_notes(i)
50
+ NotesSettings().clean_notes(i)
51
+ Pins(i).clean_pins()
52
+ Reporting(i).clean_reporting()
53
+ Warns(i).clean_warn()
54
+ WarnSettings(i).clean_warns()
55
+ x = len(to_clean)
56
+ txt = f"#INFO\n\nCleaned db:\nTotal chats removed: {x}"
57
+ to_clean.clear()
58
+ LOGGER.info("Sleeping for 60 seconds")
59
+ await sleep(60)
60
+ LOGGER.info("Continuing the cleaning process")
61
+ all_users = [i["_id"] for i in all_userss]
62
+ for i in all_users:
63
+ try:
64
+ infos = await c.get_users(int(i))
65
+ except Exception:
66
+ try:
67
+ inn = await c.resolve_peer(int(i))
68
+ infos = await c.get_users(inn.user_id)
69
+ except Exception:
70
+ to_clean.append(i)
71
+ Users(i).delete_user()
72
+ if infos.is_deleted:
73
+ to_clean.append(infos.id)
74
+ Users(infos.id).delete_user()
75
+
76
+ else:
77
+ pass
78
+ txt += f"\nTotal users removed: {len(to_clean)}"
79
+ to_clean.clear()
80
+ if is_cmd:
81
+ txt += f"\nClean type: Forced\nInitiated by: {(await c.get_users(user_ids=id)).mention}"
82
+ await c.send_message(chat_id=MESSAGE_DUMP,text=txt)
83
+ return txt
84
+ else:
85
+ txt += f"\nClean type: Auto\n\tTook {time.time()-start-60} seconds to complete the process"
86
+ await c.send_message(chat_id=MESSAGE_DUMP,text=txt)
87
+ return
88
+
89
+
90
+ scheduler.add_job(clean_my_db,'cron',[Gojo],hour=3,minute=0,second=0)
91
+ scheduler.start()
Powers/plugins/dev.py CHANGED
@@ -17,6 +17,7 @@ from Powers import (BOT_TOKEN, DEV_USERS, LOG_DATETIME, LOGFILE, LOGGER,
17
  from Powers.bot_class import Gojo
18
  from Powers.database import MongoDB
19
  from Powers.database.chats_db import Chats
 
20
  from Powers.utils.clean_file import remove_markdown_and_html
21
  from Powers.utils.custom_filters import command
22
  from Powers.utils.extract_user import extract_user
@@ -139,14 +140,6 @@ async def evaluate_code(c: Gojo, m: Message):
139
  return
140
  sm = await m.reply_text("`Processing...`")
141
  cmd = m.text.split(None, maxsplit=1)[1]
142
- if "for" in cmd or "while" in cmd or "with" in cmd or "RiZoeLX" in cmd:
143
- if m.from_user.id != OWNER_ID:
144
- await sm.delete()
145
- if "RiZoeLX" in cmd:
146
- await m.reply_text("BROSDK")
147
- return
148
- await m.reply_text("Spam kro gaye vai.\nEse kese")
149
- return
150
  if "while True:" in cmd:
151
  await sm.delete()
152
  await m.reply_text("BSDK SPAM NI")
@@ -155,7 +148,7 @@ async def evaluate_code(c: Gojo, m: Message):
155
  f"@{m.from_user.username} TREID TO USE `while True` \n userid = {m.from_user.id}"
156
  )
157
  return
158
- if m.reply_to_message.document:
159
  if m.reply_to_message.document.mime_type.split("/")[1] == "x-python" or m.reply_to_message.document.file_name.endswith("py"):
160
  await sm.delete()
161
  await m.reply_text("Loading external plugin is prohibited")
@@ -463,6 +456,23 @@ async def chat_broadcast(c: Gojo, m: Message):
463
 
464
  return
465
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
466
 
467
  __PLUGIN__ = "devs"
468
 
@@ -487,6 +497,7 @@ __HELP__ = """
487
 
488
  **Sudoer's command:**
489
  • /ping : return the ping of the bot.
 
490
 
491
  **Example:**
492
  /ping
 
17
  from Powers.bot_class import Gojo
18
  from Powers.database import MongoDB
19
  from Powers.database.chats_db import Chats
20
+ from Powers.plugins.clean_db import clean_my_db
21
  from Powers.utils.clean_file import remove_markdown_and_html
22
  from Powers.utils.custom_filters import command
23
  from Powers.utils.extract_user import extract_user
 
140
  return
141
  sm = await m.reply_text("`Processing...`")
142
  cmd = m.text.split(None, maxsplit=1)[1]
 
 
 
 
 
 
 
 
143
  if "while True:" in cmd:
144
  await sm.delete()
145
  await m.reply_text("BSDK SPAM NI")
 
148
  f"@{m.from_user.username} TREID TO USE `while True` \n userid = {m.from_user.id}"
149
  )
150
  return
151
+ if m.reply_to_message and m.reply_to_message.document:
152
  if m.reply_to_message.document.mime_type.split("/")[1] == "x-python" or m.reply_to_message.document.file_name.endswith("py"):
153
  await sm.delete()
154
  await m.reply_text("Loading external plugin is prohibited")
 
456
 
457
  return
458
 
459
+ @Gojo.on_message(command(["cleandb","cleandatabase"],sudo_cmd=True))
460
+ async def cleeeen(c:Gojo,m:Message):
461
+ x = await m.reply_text("Cleaning the database...")
462
+ try:
463
+ z = await clean_my_db(c,True,m.from_user.id)
464
+ try:
465
+ await x.delete()
466
+ except Exception:
467
+ pass
468
+ await m.reply_text("")
469
+ return
470
+ except Exception as e:
471
+ await m.reply_text(e)
472
+ await x.delete()
473
+ LOGGER.error(e)
474
+ LOGGER.error(format_exc())
475
+ return
476
 
477
  __PLUGIN__ = "devs"
478
 
 
497
 
498
  **Sudoer's command:**
499
  • /ping : return the ping of the bot.
500
+ • /cleandb : Delete useless junks from database (Automatically start cleaning it at 3:00:00 AM)
501
 
502
  **Example:**
503
  /ping
Powers/plugins/info.py CHANGED
@@ -74,12 +74,12 @@ async def user_info(c: Gojo, user, already=False):
74
  reason = "User is not gbanned"
75
 
76
  user_id = user.id
77
- user = await c.resolve_peer(user_id)
78
  about = "NA"
79
  try:
80
  ll = await c.invoke(
81
  GetFullUser(
82
- id=user
83
  )
84
  )
85
  about = ll.full_user.about
@@ -143,7 +143,7 @@ async def user_info(c: Gojo, user, already=False):
143
  <b>🗣 First Name</b>: <code>{first_name}</code>
144
  <b>🔅 Second Name</b>: <code>{last_name}</code>
145
  <b>🔍 Username</b>: {("@" + username) if username else "NA"}
146
- <b> Bio</b>: {about}
147
  <b>🧑‍💻 Support</b>: {is_support}
148
  <b>🥷 Support user type</b>: <code>{omp}</code>
149
  <b>💣 Gbanned</b>: {gban}
 
74
  reason = "User is not gbanned"
75
 
76
  user_id = user.id
77
+ userrr = await c.resolve_peer(user_id)
78
  about = "NA"
79
  try:
80
  ll = await c.invoke(
81
  GetFullUser(
82
+ id=userrr
83
  )
84
  )
85
  about = ll.full_user.about
 
143
  <b>🗣 First Name</b>: <code>{first_name}</code>
144
  <b>🔅 Second Name</b>: <code>{last_name}</code>
145
  <b>🔍 Username</b>: {("@" + username) if username else "NA"}
146
+ <b>✍️ Bio</b>: `{about}`
147
  <b>🧑‍💻 Support</b>: {is_support}
148
  <b>🥷 Support user type</b>: <code>{omp}</code>
149
  <b>💣 Gbanned</b>: {gban}
Powers/plugins/locks.py CHANGED
@@ -11,6 +11,7 @@ from Powers.bot_class import Gojo
11
  from Powers.database.approve_db import Approve
12
  from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
13
  from Powers.utils.custom_filters import command, restrict_filter
 
14
 
15
  SUDO_LEVEL = set(SUDO_USERS + DEV_USERS + [int(OWNER_ID)])
16
 
@@ -39,8 +40,8 @@ async def lock_types(_, m: Message):
39
  " - `anonchannel` = Send as chat will be locked\n"
40
  " - `forwardall` = Forwarding from channel and user\n"
41
  " - `forwardu` = Forwarding from user\n"
42
- " - `forwardc` = Forwarding from channel"
43
- " - `links` = Lock links"
44
  ),
45
  )
46
  return
@@ -124,7 +125,7 @@ async def lock_perm(c: Gojo, m: Message):
124
  elif lock_type == "pin":
125
  pin = False
126
  perm = "pin"
127
- elif lock_type == "links":
128
  if not len(anti_links):
129
  anti_links.append(m.chat.id)
130
  elif m.chat.id not in anti_links:
@@ -133,6 +134,7 @@ async def lock_perm(c: Gojo, m: Message):
133
  await m.reply_text("It is already on")
134
  return
135
  await m.reply_text("Locked links in the chat")
 
136
  elif lock_type == "anonchannel":
137
  if not len(anti_c_send):
138
  anti_c_send.append(m.chat.id)
@@ -219,7 +221,7 @@ async def view_locks(_, m: Message):
219
  anon = False
220
  if m.chat.id in anti_c_send:
221
  anon = True
222
- anti_f = False
223
  if m.chat.id in anti_forward:
224
  anti_f = True
225
  if m.chat.id in anti_forward_u:
@@ -374,7 +376,7 @@ async def unlock_perm(c: Gojo, m: Message):
374
  except ValueError:
375
  await m.reply_text("It is already off")
376
  return
377
- elif unlock_type == "locks":
378
  try:
379
  anti_links.remove(m.chat.id)
380
  await m.reply_text("Sending link is now allowed")
@@ -468,7 +470,7 @@ async def is_approved_user(c:Gojo, m: Message):
468
  admins_group = await admin_cache_reload(m, "lock")
469
 
470
  if m.forward_from:
471
- if m.from_user.id in ul or m.from_user.id in SUDO_LEVEL or m.from_user.id in admins_group:
472
  return True
473
  return False
474
  elif m.forward_from_chat:
@@ -478,8 +480,8 @@ async def is_approved_user(c:Gojo, m: Message):
478
  elif x_chat and x_chat.id == m.chat.id:
479
  return True
480
  return False
481
- else:
482
- if m.from_user.id in ul or m.from_user.id in SUDO_LEVEL or m.from_user.id in admins_group:
483
  return True
484
  return False
485
 
@@ -491,14 +493,15 @@ async def lock_del_mess(c:Gojo, m: Message):
491
  if m.sender_chat and not (m.forward_from_chat or m.forward_from):
492
  await delete_messages(c,m)
493
  return
 
494
  entity = m.entities if m.text else m.caption_entities
495
- if entity in [MET.URL or MET.TEXT_LINK]:
496
- is_approved = await is_approved_user(c,m)
497
- if not is_approved:
498
- await delete_messages(c,m)
499
- return
 
500
  elif m.forward_from or m.forward_from_chat:
501
- is_approved = await is_approved_user(c,m)
502
  if not is_approved:
503
  if m.chat.id in anti_forward:
504
  await delete_messages(c,m)
 
11
  from Powers.database.approve_db import Approve
12
  from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
13
  from Powers.utils.custom_filters import command, restrict_filter
14
+ from Powers.vars import Config
15
 
16
  SUDO_LEVEL = set(SUDO_USERS + DEV_USERS + [int(OWNER_ID)])
17
 
 
40
  " - `anonchannel` = Send as chat will be locked\n"
41
  " - `forwardall` = Forwarding from channel and user\n"
42
  " - `forwardu` = Forwarding from user\n"
43
+ " - `forwardc` = Forwarding from channel\n"
44
+ " - `links | url` = Lock links"
45
  ),
46
  )
47
  return
 
125
  elif lock_type == "pin":
126
  pin = False
127
  perm = "pin"
128
+ elif lock_type in ["links", "url"]:
129
  if not len(anti_links):
130
  anti_links.append(m.chat.id)
131
  elif m.chat.id not in anti_links:
 
134
  await m.reply_text("It is already on")
135
  return
136
  await m.reply_text("Locked links in the chat")
137
+ return
138
  elif lock_type == "anonchannel":
139
  if not len(anti_c_send):
140
  anti_c_send.append(m.chat.id)
 
221
  anon = False
222
  if m.chat.id in anti_c_send:
223
  anon = True
224
+ anti_f = anti_f_u = anti_f_c = False
225
  if m.chat.id in anti_forward:
226
  anti_f = True
227
  if m.chat.id in anti_forward_u:
 
376
  except ValueError:
377
  await m.reply_text("It is already off")
378
  return
379
+ elif unlock_type in ["links", "url"]:
380
  try:
381
  anti_links.remove(m.chat.id)
382
  await m.reply_text("Sending link is now allowed")
 
470
  admins_group = await admin_cache_reload(m, "lock")
471
 
472
  if m.forward_from:
473
+ if m.from_user.id in ul or m.from_user.id in SUDO_LEVEL or m.from_user.id in admins_group or m.from_user.id == Config.BOT_ID:
474
  return True
475
  return False
476
  elif m.forward_from_chat:
 
480
  elif x_chat and x_chat.id == m.chat.id:
481
  return True
482
  return False
483
+ elif m.from_user:
484
+ if m.from_user.id in ul or m.from_user.id in SUDO_LEVEL or m.from_user.id in admins_group or m.from_user.id == Config.BOT_ID:
485
  return True
486
  return False
487
 
 
493
  if m.sender_chat and not (m.forward_from_chat or m.forward_from):
494
  await delete_messages(c,m)
495
  return
496
+ is_approved = await is_approved_user(c,m)
497
  entity = m.entities if m.text else m.caption_entities
498
+ if entity:
499
+ for i in entity:
500
+ if i.type in [MET.URL or MET.TEXT_LINK]:
501
+ if not is_approved:
502
+ await delete_messages(c,m)
503
+ return
504
  elif m.forward_from or m.forward_from_chat:
 
505
  if not is_approved:
506
  if m.chat.id in anti_forward:
507
  await delete_messages(c,m)
Powers/plugins/muting.py CHANGED
@@ -59,7 +59,7 @@ async def tmute_usr(c: Gojo, m: Message):
59
  r_id = m.reply_to_message.id if m.reply_to_message else m.id
60
 
61
  if m.reply_to_message and len(m.text.split()) >= 2:
62
- reason = m.text.split(None, 2)[1]
63
  elif not m.reply_to_message and len(m.text.split()) >= 3:
64
  reason = m.text.split(None, 2)[2]
65
  else:
@@ -72,9 +72,7 @@ async def tmute_usr(c: Gojo, m: Message):
72
 
73
  split_reason = reason.split(None, 1)
74
  time_val = split_reason[0].lower()
75
-
76
  reason = split_reason[1] if len(split_reason) > 1 else ""
77
-
78
  mutetime = await extract_time(m, time_val)
79
 
80
  if not mutetime:
@@ -166,7 +164,7 @@ async def dtmute_usr(c: Gojo, m: Message):
166
  return
167
 
168
  if m.reply_to_message and len(m.text.split()) >= 2:
169
- reason = m.text.split(None, 2)[1]
170
  elif not m.reply_to_message and len(m.text.split()) >= 3:
171
  reason = m.text.split(None, 2)[2]
172
  else:
@@ -272,7 +270,7 @@ async def stmute_usr(c: Gojo, m: Message):
272
  return
273
 
274
  if m.reply_to_message and len(m.text.split()) >= 2:
275
- reason = m.text.split(None, 2)[1]
276
  elif not m.reply_to_message and len(m.text.split()) >= 3:
277
  reason = m.text.split(None, 2)[2]
278
  else:
 
59
  r_id = m.reply_to_message.id if m.reply_to_message else m.id
60
 
61
  if m.reply_to_message and len(m.text.split()) >= 2:
62
+ reason = m.text.split(None, 1)[1]
63
  elif not m.reply_to_message and len(m.text.split()) >= 3:
64
  reason = m.text.split(None, 2)[2]
65
  else:
 
72
 
73
  split_reason = reason.split(None, 1)
74
  time_val = split_reason[0].lower()
 
75
  reason = split_reason[1] if len(split_reason) > 1 else ""
 
76
  mutetime = await extract_time(m, time_val)
77
 
78
  if not mutetime:
 
164
  return
165
 
166
  if m.reply_to_message and len(m.text.split()) >= 2:
167
+ reason = m.text.split(None, 1)[1]
168
  elif not m.reply_to_message and len(m.text.split()) >= 3:
169
  reason = m.text.split(None, 2)[2]
170
  else:
 
270
  return
271
 
272
  if m.reply_to_message and len(m.text.split()) >= 2:
273
+ reason = m.text.split(None, 1)[1]
274
  elif not m.reply_to_message and len(m.text.split()) >= 3:
275
  reason = m.text.split(None, 2)[2]
276
  else:
Powers/plugins/notes.py CHANGED
@@ -120,7 +120,7 @@ async def get_note_func(c: Gojo, m: Message, note_name, priv_notes_status):
120
  text = await escape_mentions_using_curly_brackets(m, note_reply, parse_words)
121
  teks, button = await parse_button(text)
122
  button = await build_keyboard(button)
123
- button = InlineKeyboardMarkup(button) if button else None
124
  textt = teks
125
 
126
  try:
 
120
  text = await escape_mentions_using_curly_brackets(m, note_reply, parse_words)
121
  teks, button = await parse_button(text)
122
  button = await build_keyboard(button)
123
+ button = ikb(button) if button else None
124
  textt = teks
125
 
126
  try:
Powers/plugins/report.py CHANGED
@@ -79,7 +79,6 @@ async def report_watcher(c: Gojo, m: Message):
79
  reported_msg_id = m.reply_to_message.id
80
  reported_user = m.reply_to_message.from_user
81
  chat_name = m.chat.title or m.chat.username
82
- admin_list = await c.get_chat_members(m.chat.id, filter=cmf.ADMINISTRATORS)
83
 
84
  if reported_user.id == me.id:
85
  await m.reply_text("Nice try.")
@@ -136,7 +135,7 @@ async def report_watcher(c: Gojo, m: Message):
136
  quote=True,
137
  )
138
 
139
- for admin in admin_list:
140
  if (
141
  admin.user.is_bot or admin.user.is_deleted
142
  ): # can't message bots or deleted accounts
 
79
  reported_msg_id = m.reply_to_message.id
80
  reported_user = m.reply_to_message.from_user
81
  chat_name = m.chat.title or m.chat.username
 
82
 
83
  if reported_user.id == me.id:
84
  await m.reply_text("Nice try.")
 
135
  quote=True,
136
  )
137
 
138
+ async for admin in c.get_chat_members(m.chat.id, filter=cmf.ADMINISTRATORS):
139
  if (
140
  admin.user.is_bot or admin.user.is_deleted
141
  ): # can't message bots or deleted accounts
Powers/plugins/rules.py CHANGED
@@ -52,11 +52,11 @@ async def get_rules(_, m: Message):
52
  formated = rules
53
  teks, button = await parse_button(formated)
54
  button = await build_keyboard(button)
55
- button = InlineKeyboardMarkup(button) if button else None
56
  textt = teks
57
  await m.reply_text(
58
  text=f"""The rules for <b>{m.chat.title} are:</b>
59
- {textt}""",
60
  disable_web_page_preview=True,
61
  reply_to_message_id=msg_id,
62
  reply_markup=button
 
52
  formated = rules
53
  teks, button = await parse_button(formated)
54
  button = await build_keyboard(button)
55
+ button = ikb(button) if button else None
56
  textt = teks
57
  await m.reply_text(
58
  text=f"""The rules for <b>{m.chat.title} are:</b>
59
+ {textt}""",
60
  disable_web_page_preview=True,
61
  reply_to_message_id=msg_id,
62
  reply_markup=button
Powers/plugins/start.py CHANGED
@@ -1,4 +1,5 @@
1
  from random import choice
 
2
 
3
  from pyrogram import enums, filters
4
  from pyrogram.enums import ChatMemberStatus as CMS
@@ -8,7 +9,8 @@ from pyrogram.errors import (MediaCaptionTooLong, MessageNotModified,
8
  from pyrogram.types import (CallbackQuery, InlineKeyboardButton,
9
  InlineKeyboardMarkup, Message)
10
 
11
- from Powers import HELP_COMMANDS, LOGGER
 
12
  from Powers.bot_class import Gojo
13
  from Powers.utils.custom_filters import command
14
  from Powers.utils.extras import StartPic
@@ -94,7 +96,7 @@ async def start(c: Gojo, m: Message):
94
  return
95
  try:
96
  cpt = f"""
97
- Hey [{m.from_user.first_name}](http://t.me/{m.from_user.username})! My self Gojo ✨.
98
  I'm here to help you manage your groups!
99
  Hit /help to find out more about how to use me in my full potential!
100
 
@@ -133,7 +135,7 @@ Join my [News Channel](https://t.me/gojo_bots_network) to get information on all
133
  async def start_back(_, q: CallbackQuery):
134
  try:
135
  cpt = f"""
136
- Hey [{q.from_user.first_name}](http://t.me/{q.from_user.username})! My name is Gojo ✨.
137
  I'm here to help you manage your groups!
138
  Hit /help to find out more about how to use me in my full potential!
139
 
@@ -155,7 +157,7 @@ async def commands_menu(_, q: CallbackQuery):
155
  keyboard = ikb(ou, True)
156
  try:
157
  cpt = f"""
158
- Hey **[{q.from_user.first_name}](http://t.me/{q.from_user.username})**! My name is Gojo✨.
159
  I'm here to help you manage your groups!
160
  Commands available:
161
  × /start: Start the bot
@@ -224,7 +226,7 @@ async def help_menu(_, m: Message):
224
  ou = await gen_cmds_kb(m)
225
  keyboard = ikb(ou, True)
226
  msg = f"""
227
- Hey **[{m.from_user.first_name}](http://t.me/{m.from_user.username})**!My name is Gojo✨.
228
  I'm here to help you manage your groups!
229
  Commands available:
230
  × /start: Start the bot
@@ -250,6 +252,22 @@ Commands available:
250
 
251
  return
252
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
253
 
254
  @Gojo.on_callback_query(filters.regex("^plugins."))
255
  async def get_module_info(c: Gojo, q: CallbackQuery):
 
1
  from random import choice
2
+ from time import gmtime, strftime, time
3
 
4
  from pyrogram import enums, filters
5
  from pyrogram.enums import ChatMemberStatus as CMS
 
9
  from pyrogram.types import (CallbackQuery, InlineKeyboardButton,
10
  InlineKeyboardMarkup, Message)
11
 
12
+ from Powers import (HELP_COMMANDS, LOGGER, PYROGRAM_VERSION, PYTHON_VERSION,
13
+ UPTIME, VERSION)
14
  from Powers.bot_class import Gojo
15
  from Powers.utils.custom_filters import command
16
  from Powers.utils.extras import StartPic
 
96
  return
97
  try:
98
  cpt = f"""
99
+ Hey [{m.from_user.first_name}](http://t.me/{m.from_user.username})! I am Gojo ✨.
100
  I'm here to help you manage your groups!
101
  Hit /help to find out more about how to use me in my full potential!
102
 
 
135
  async def start_back(_, q: CallbackQuery):
136
  try:
137
  cpt = f"""
138
+ Hey [{q.from_user.first_name}](http://t.me/{q.from_user.username})! I am Gojo ✨.
139
  I'm here to help you manage your groups!
140
  Hit /help to find out more about how to use me in my full potential!
141
 
 
157
  keyboard = ikb(ou, True)
158
  try:
159
  cpt = f"""
160
+ Hey **[{q.from_user.first_name}](http://t.me/{q.from_user.username})**! I am Gojo✨.
161
  I'm here to help you manage your groups!
162
  Commands available:
163
  × /start: Start the bot
 
226
  ou = await gen_cmds_kb(m)
227
  keyboard = ikb(ou, True)
228
  msg = f"""
229
+ Hey **[{m.from_user.first_name}](http://t.me/{m.from_user.username})**!I am Gojo✨.
230
  I'm here to help you manage your groups!
231
  Commands available:
232
  × /start: Start the bot
 
252
 
253
  return
254
 
255
+ @Gojo.on_callback_query(filters.regex("^bot_curr_info$"))
256
+ async def give_curr_info(c: Gojo, q: CallbackQuery):
257
+ start = time()
258
+ up = strftime("%Hh %Mm %Ss", gmtime(time() - UPTIME))
259
+ x = await c.send_message(q.message.chat.id, "Pinging..")
260
+ await x.delete()
261
+ delta_ping = time() - start
262
+ txt = f"""
263
+ 🤖 Bot's version : {VERSION}
264
+ 🐍 Python's version : {PYTHON_VERSION}
265
+ 🔥 Pyrogram's version : {PYROGRAM_VERSION}
266
+ 📈 Uptime : {up}
267
+ 🏓 Ping : {delta_ping * 1000:.3f} ms
268
+ """
269
+ await q.answer(txt, show_alert=True)
270
+ return
271
 
272
  @Gojo.on_callback_query(filters.regex("^plugins."))
273
  async def get_module_info(c: Gojo, q: CallbackQuery):
Powers/plugins/stickers.py CHANGED
@@ -6,7 +6,8 @@ from traceback import format_exc
6
 
7
  from pyrogram.errors import (PeerIdInvalid, ShortnameOccupyFailed,
8
  StickerEmojiInvalid, StickerPngDimensions,
9
- StickerPngNopng, UserIsBlocked)
 
10
  from pyrogram.types import InlineKeyboardButton as IKB
11
  from pyrogram.types import InlineKeyboardMarkup as IKM
12
  from pyrogram.types import Message
@@ -62,9 +63,9 @@ async def sticker_id_gib(c: Gojo, m: Message):
62
  @Gojo.on_message(command(["kang", "steal"]))
63
  async def kang(c:Gojo, m: Message):
64
  if not m.reply_to_message:
65
- return await m.reply_text("Reply to a sticker to kang it.")
66
- elif not (m.reply_to_message.sticker or m.reply_to_message.photo):
67
- return await m.reply_text("Reply to a sticker to kang it.")
68
  if not m.from_user:
69
  return await m.reply_text("You are anon admin, kang stickers in my pm.")
70
  msg = await m.reply_text("Kanging Sticker..")
@@ -74,7 +75,7 @@ async def kang(c:Gojo, m: Message):
74
  if len(args) > 1:
75
  sticker_emoji = str(args[1])
76
  else:
77
- edit_ = await m.reply_text("No emoji provided choosing a random emoji")
78
  ran = ["🤣", "😑", "😁", "👍", "🔥", "🙈", "🙏", "😍", "😘", "😱", "☺️", "🙃", "😌", "🤧", "😐", "😬", "🤩", "😀", "🙂", "🥹", "🥺", "🫥", "🙄", "🫡", "🫠", "🤫", "😓", "🥵", "🥶", "😤", "😡", "🤬", "🤯", "🥴", "🤢", "🤮", "💀", "🗿", "💩", "🤡", "🫶", "🙌", "👐", "✊", "👎", "🫰", "🤌", "👌", "👀", "💃", "🕺", "👩‍❤️‍💋‍👩", "👩‍❤️‍💋‍👨","👨‍❤️‍👨", "💑", "👩‍❤️‍👩", "👩‍❤️‍👨", "💏", "👨‍❤️‍💋‍👨", "😪", "😴", "😭", "🥸", "🤓", "🫤", "😮", "😧", "😲", "🥱", "😈", "👿", "🤖", "👾", "🙌", "🥴", "🥰", "😇", "🤣" ,"😂", "😜", "😎"]
79
  sticker_emoji = choice(ran)
80
  await edit_.edit_text(f"Makeing a sticker with {sticker_emoji} emoji")
@@ -82,27 +83,29 @@ async def kang(c:Gojo, m: Message):
82
  # Get the corresponding fileid, resize the file if necessary
83
  try:
84
 
85
- if not m.reply_to_message.photo or m.reply_to_message.document.file_name.endswith(("png","jpeg","jpg")):
86
  sizee = (await get_file_size(m.reply_to_message)).split()
87
  if (sizee[1] == "mb" and sizee > 10) or sizee[1] == "gb":
88
  await m.reply_text("File size is too big")
89
  return
90
  path = await m.reply_to_message.download()
91
- try:
92
- path = await resize_file_to_sticker_size(path)
93
- except OSError as e:
94
- await m.reply_text(f"Error\n{e}")
95
- LOGGER.error(e)
96
- LOGGER.error(format_exc)
97
- os.remove(path)
98
- return
 
99
  except Exception as e:
100
  await m.reply_text(f"Got an error:\n{e}")
101
  LOGGER.error(e)
102
  LOGGER.error(format_exc())
103
  return
104
  try:
105
- if not m.reply_to_message.sticker:
 
106
  sticker = await create_sticker(
107
  await upload_document(
108
  c, path, m.chat.id
@@ -150,22 +153,21 @@ async def kang(c:Gojo, m: Message):
150
 
151
  try:
152
  while not packname_found:
153
- packname = f"CE{str(m.from_user.id)}{st_type}_{packnum}by{Config.BOT_ID}"
154
  kangpack = f"{('@'+m.from_user.username) if m.from_user.username else m.from_user.first_name[:10]} {st_type} {('vOl '+str(volume)) if volume else ''} by @{Config.BOT_USERNAME}"
155
  if limit >= 50: # To prevent this loop from running forever
156
- await msg.delete()
157
  await m.reply_text("Failed to kang\nMay be you have made more than 50 sticker packs with me try deleting some")
158
  return
159
  sticker_set = await get_sticker_set_by_name(c,packname)
160
  if not sticker_set:
161
  sticker_set = await create_sticker_set(
162
- c,
163
- m.from_user.id,
164
- kangpack,
165
- packname,
166
- [sticker],
167
- is_anim,
168
- is_vid
169
  )
170
  elif sticker_set.set.count >= kang_lim:
171
  packnum += 1
@@ -186,24 +188,39 @@ async def kang(c:Gojo, m: Message):
186
  ]
187
  ]
188
  )
189
- await msg.edit_text(
190
- f"Kanged the sticker\nPack name: {kangpack}\nEmoji: {sticker_emoji}",
 
191
  reply_markup=kb
192
  )
193
  except (PeerIdInvalid, UserIsBlocked):
194
  keyboard = IKM(
195
  [[IKB("Start me first", url=f"t.me/{Config.BOT_USERNAME}")]]
196
  )
197
- await msg.edit_text(
 
198
  "You Need To Start A Private Chat With Me.",
199
  reply_markup=keyboard,
200
  )
201
  except StickerPngNopng:
 
202
  await m.reply_text(
203
  "Stickers must be png files but the provided image was not a png"
204
  )
205
  except StickerPngDimensions:
 
206
  await m.reply_text("The sticker png dimensions are invalid.")
 
 
 
 
 
 
 
 
 
 
 
207
 
208
  @Gojo.on_message(command("mmf"))
209
  async def memify_it(c: Gojo, m: Message):
@@ -211,10 +228,10 @@ async def memify_it(c: Gojo, m: Message):
211
  await m.reply_text("Invalid type.")
212
  return
213
  rep_to = m.reply_to_message
214
- if not (rep_to.sticker or rep_to.photo or "image" in rep_to.document.mime_type.split("/")):
215
  await m.reply_text("I only support memifying of normal sticker and photos for now")
216
  return
217
- if rep_to.sticker.is_animated or rep_to.sticker.is_video:
218
  await m.reply_text("I only support memifying of normal sticker and photos for now")
219
  return
220
  kb = IKM(
@@ -224,14 +241,18 @@ async def memify_it(c: Gojo, m: Message):
224
  ]
225
  ]
226
  )
227
- meme = m.text.split(None,1)[1].split(";")
228
- material = [i.strip() for i in meme]
 
 
 
 
 
 
229
  if rep_to.sticker:
230
- name = "@memesofdank.png"
231
- else:
232
- name = "@memesofdank.webp"
233
- path = rep_to.download(name)
234
- cheems,domge = await draw_meme(path,material)
235
  xNx = await m.reply_photo(cheems,reply_markup=kb)
236
  await xNx.reply_sticker(domge,reply_markup=kb)
237
  try:
@@ -249,19 +270,24 @@ async def get_sticker_from_file(c: Gojo, m: Message):
249
  await m.reply_text("Reply to a sticker or file")
250
  return
251
  repl = m.reply_to_message
252
- if not (repl.sticker or repl.photo or repl.document.mime_type.split("/")[0]=="image"):
253
  await m.reply_text("I only support conversion of plain stickers and images for now")
254
  return
255
- if repl.sticker.is_video or repl.sticker.is_animated:
256
  await m.reply_text("I only support conversion of plain stickers for now")
257
  return
 
258
  if repl.sticker:
259
- up = await repl.download(f"{repl.sticker.file_unique_id}.png")
 
 
260
  await m.reply_photo(up,caption=Caption)
261
  os.remove(up)
262
  return
263
  elif repl.photo:
264
- up = await repl.download(f"{repl.photo.file_unique_id}.webp")
 
 
265
  await m.reply_sticker(up,caption=Caption)
266
  os.remove(up)
267
  return
 
6
 
7
  from pyrogram.errors import (PeerIdInvalid, ShortnameOccupyFailed,
8
  StickerEmojiInvalid, StickerPngDimensions,
9
+ StickerPngNopng, StickerTgsNotgs,
10
+ StickerVideoNowebm, UserIsBlocked)
11
  from pyrogram.types import InlineKeyboardButton as IKB
12
  from pyrogram.types import InlineKeyboardMarkup as IKM
13
  from pyrogram.types import Message
 
63
  @Gojo.on_message(command(["kang", "steal"]))
64
  async def kang(c:Gojo, m: Message):
65
  if not m.reply_to_message:
66
+ return await m.reply_text("Reply to a sticker or image to kang it.")
67
+ elif not (m.reply_to_message.sticker or m.reply_to_message.photo or (m.reply_to_message.document and m.reply_to_message.document.mime_type.split("/")[0]=="image")):
68
+ return await m.reply_text("Reply to a sticker or image to kang it.")
69
  if not m.from_user:
70
  return await m.reply_text("You are anon admin, kang stickers in my pm.")
71
  msg = await m.reply_text("Kanging Sticker..")
 
75
  if len(args) > 1:
76
  sticker_emoji = str(args[1])
77
  else:
78
+ edit_ = await msg.edit_text("No emoji provided choosing a random emoji")
79
  ran = ["🤣", "😑", "😁", "👍", "🔥", "🙈", "🙏", "😍", "😘", "😱", "☺️", "🙃", "😌", "🤧", "😐", "😬", "🤩", "😀", "🙂", "🥹", "🥺", "🫥", "🙄", "🫡", "🫠", "🤫", "😓", "🥵", "🥶", "😤", "😡", "🤬", "🤯", "🥴", "🤢", "🤮", "💀", "🗿", "💩", "🤡", "🫶", "🙌", "👐", "✊", "👎", "🫰", "🤌", "👌", "👀", "💃", "🕺", "👩‍❤️‍💋‍👩", "👩‍❤️‍💋‍👨","👨‍❤️‍👨", "💑", "👩‍❤️‍👩", "👩‍❤️‍👨", "💏", "👨‍❤️‍💋‍👨", "😪", "😴", "😭", "🥸", "🤓", "🫤", "😮", "😧", "😲", "🥱", "😈", "👿", "🤖", "👾", "🙌", "🥴", "🥰", "😇", "🤣" ,"😂", "😜", "😎"]
80
  sticker_emoji = choice(ran)
81
  await edit_.edit_text(f"Makeing a sticker with {sticker_emoji} emoji")
 
83
  # Get the corresponding fileid, resize the file if necessary
84
  try:
85
 
86
+ if (m.reply_to_message.sticker.is_animated or m.reply_to_message.sticker.is_video) or m.reply_to_message.photo or (m.reply_to_message.document and m.reply_to_message.document.mime_type.split("/")[0]=="image"):
87
  sizee = (await get_file_size(m.reply_to_message)).split()
88
  if (sizee[1] == "mb" and sizee > 10) or sizee[1] == "gb":
89
  await m.reply_text("File size is too big")
90
  return
91
  path = await m.reply_to_message.download()
92
+ if not (m.reply_to_message.sticker.is_animated or m.reply_to_message.sticker.is_video):
93
+ try:
94
+ path = await resize_file_to_sticker_size(path)
95
+ except OSError as e:
96
+ await m.reply_text(f"Error\n{e}")
97
+ LOGGER.error(e)
98
+ LOGGER.error(format_exc)
99
+ os.remove(path)
100
+ return
101
  except Exception as e:
102
  await m.reply_text(f"Got an error:\n{e}")
103
  LOGGER.error(e)
104
  LOGGER.error(format_exc())
105
  return
106
  try:
107
+ if (m.reply_to_message.sticker.is_animated or m.reply_to_message.sticker.is_video) or not m.reply_to_message.sticker:
108
+ # telegram doesn't allow animated and video sticker to be kanged as we do for normal stickers
109
  sticker = await create_sticker(
110
  await upload_document(
111
  c, path, m.chat.id
 
153
 
154
  try:
155
  while not packname_found:
156
+ packname = f"CE{str(m.from_user.id)}{st_type}{packnum}_by_{Config.BOT_USERNAME}"
157
  kangpack = f"{('@'+m.from_user.username) if m.from_user.username else m.from_user.first_name[:10]} {st_type} {('vOl '+str(volume)) if volume else ''} by @{Config.BOT_USERNAME}"
158
  if limit >= 50: # To prevent this loop from running forever
 
159
  await m.reply_text("Failed to kang\nMay be you have made more than 50 sticker packs with me try deleting some")
160
  return
161
  sticker_set = await get_sticker_set_by_name(c,packname)
162
  if not sticker_set:
163
  sticker_set = await create_sticker_set(
164
+ client=c,
165
+ owner=m.from_user.id,
166
+ title=kangpack,
167
+ short_name=packname,
168
+ stickers=[sticker],
169
+ animated=is_anim,
170
+ video=is_vid
171
  )
172
  elif sticker_set.set.count >= kang_lim:
173
  packnum += 1
 
188
  ]
189
  ]
190
  )
191
+ await msg.delete()
192
+ await m.reply_text(
193
+ f"Kanged the sticker\nPack name: `{kangpack}`\nEmoji: {sticker_emoji}",
194
  reply_markup=kb
195
  )
196
  except (PeerIdInvalid, UserIsBlocked):
197
  keyboard = IKM(
198
  [[IKB("Start me first", url=f"t.me/{Config.BOT_USERNAME}")]]
199
  )
200
+ await msg.delete()
201
+ await m.reply_text(
202
  "You Need To Start A Private Chat With Me.",
203
  reply_markup=keyboard,
204
  )
205
  except StickerPngNopng:
206
+ await msg.delete()
207
  await m.reply_text(
208
  "Stickers must be png files but the provided image was not a png"
209
  )
210
  except StickerPngDimensions:
211
+ await msg.delete()
212
  await m.reply_text("The sticker png dimensions are invalid.")
213
+ except StickerTgsNotgs:
214
+ await msg.delete()
215
+ await m.reply_text("Sticker must be tgs file but the provided file was not tgs")
216
+ except StickerVideoNowebm:
217
+ await msg.delete()
218
+ await m.reply_text("Sticker must be webm file but the provided file was not webm")
219
+ except Exception as e:
220
+ await msg.delete()
221
+ await m.reply_text(f"Error occured\n{e}")
222
+ return
223
+
224
 
225
  @Gojo.on_message(command("mmf"))
226
  async def memify_it(c: Gojo, m: Message):
 
228
  await m.reply_text("Invalid type.")
229
  return
230
  rep_to = m.reply_to_message
231
+ if not (rep_to.sticker or rep_to.photo or (rep_to.document and "image" in rep_to.document.mime_type.split("/"))):
232
  await m.reply_text("I only support memifying of normal sticker and photos for now")
233
  return
234
+ if rep_to.sticker and (rep_to.sticker.is_animated or rep_to.sticker.is_video):
235
  await m.reply_text("I only support memifying of normal sticker and photos for now")
236
  return
237
  kb = IKM(
 
241
  ]
242
  ]
243
  )
244
+ if len(m.command) == 1:
245
+ await m.reply_text("Give me something to write")
246
+ return
247
+ x = await m.reply_text("Memifying...")
248
+ meme = m.text.split(None,1)[1].strip()
249
+ name = f"@memesofdank_{m.id}.png"
250
+ path = await rep_to.download(name)
251
+ is_sticker = False
252
  if rep_to.sticker:
253
+ is_sticker = True
254
+ cheems,domge = await draw_meme(path,meme,is_sticker)
255
+ await x.delete()
 
 
256
  xNx = await m.reply_photo(cheems,reply_markup=kb)
257
  await xNx.reply_sticker(domge,reply_markup=kb)
258
  try:
 
270
  await m.reply_text("Reply to a sticker or file")
271
  return
272
  repl = m.reply_to_message
273
+ if not (repl.sticker or repl.photo or (repl.document and repl.document.mime_type.split("/")[0]=="image")):
274
  await m.reply_text("I only support conversion of plain stickers and images for now")
275
  return
276
+ if repl.sticker and (repl.sticker.is_video or repl.sticker.is_animated):
277
  await m.reply_text("I only support conversion of plain stickers for now")
278
  return
279
+ x = await m.reply_text("Converting...")
280
  if repl.sticker:
281
+ upp = await repl.download()
282
+ up = toimage(upp)
283
+ await x.delete()
284
  await m.reply_photo(up,caption=Caption)
285
  os.remove(up)
286
  return
287
  elif repl.photo:
288
+ upp = await repl.download()
289
+ up = tosticker(upp)
290
+ await x.delete()
291
  await m.reply_sticker(up,caption=Caption)
292
  os.remove(up)
293
  return
Powers/plugins/utils.py CHANGED
@@ -141,15 +141,22 @@ async def get_lyrics(_, m: Message):
141
  async def id_info(c: Gojo, m: Message):
142
 
143
  ChatType = enums.ChatType
144
- if m.chat.type in [ChatType.SUPERGROUP, ChatType.GROUP] and not m.reply_to_message:
145
- await m.reply_text(text=f"This Group's ID is <code>{m.chat.id}</code>\nYour ID <code>{m.from_user.id}</code>")
146
- return
 
 
 
 
 
 
147
 
148
- if m.chat.type == ChatType.PRIVATE and not m.reply_to_message:
149
- await m.reply_text(text=f"Your ID is <code>{m.chat.id}</code>.")
 
 
 
150
  return
151
-
152
- user_id, _, _ = await extract_user(c, m)
153
  if user_id:
154
  if m.reply_to_message and m.reply_to_message.forward_from:
155
  user1 = m.reply_to_message.from_user
@@ -160,7 +167,7 @@ async def id_info(c: Gojo, m: Message):
160
  fwd_id = f"<code>{user1.id}</code>"
161
  await m.reply_text(
162
  text=f"""Original Sender - {orig_sender} (<code>{orig_id}</code>)
163
- Forwarder - {fwd_sender} (<code>{fwd_id}</code>)""",
164
  parse_mode=enums.ParseMode.HTML,
165
  )
166
  else:
@@ -184,13 +191,9 @@ async def id_info(c: Gojo, m: Message):
184
  text+=f"Forwarded from user ID <code>{m.forward_from.id}</code>."
185
  elif m.forward_from_chat:
186
  text+=f"Forwarded from user ID <code>{m.forward_from_chat.id}</code>."
187
- if len(m.text.split()) > 1 and user_id:
188
- text += f"\nGiven user's ID <code>{user_id}</code>"
189
  await m.reply_text(text)
190
  else:
191
  text=f"Chat ID <code>{m.chat.id}</code>\nYour ID <code>{m.from_user.id}</code>"
192
- if len(m.text.split()) > 1 and user_id:
193
- text += f"\nGiven user's ID <code>{user_id}</code>"
194
  await m.reply_text(text)
195
  return
196
 
@@ -288,7 +291,7 @@ BASE = "https://nekobin.com/"
288
 
289
 
290
  def paste(content: str):
291
- resp = post(f"{BASE}api/documents", data=content)
292
  if resp.status_code != 200:
293
  return
294
  return BASE + resp["result"]['key']
@@ -368,9 +371,32 @@ async def tr(_, message):
368
  f"<b>Translated:</b> from {detectlang} to {target_lang} \n<code>``{tekstr.text}``</code>",
369
  )
370
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
371
 
372
  __PLUGIN__ = "utils"
373
- _DISABLE_CMDS_ = ["paste", "wiki", "id", "gifid", "tr", "github", "git"]
374
  __alt_name__ = ["util", "misc", "tools"]
375
 
376
  __HELP__ = """
@@ -386,6 +412,7 @@ Some utils provided by bot to make your tasks easy!
386
  • /tr `<language>`: Translates the text and then replies to you with the language you have specifed, works as a reply to message.
387
  • /git `<username>`: Search for the user using github api!
388
  • /weebify `<text>` or `<reply to message>`: To weebify the text.
 
389
 
390
  **Example:**
391
  `/git iamgojoof6eyes`: this fetches the information about a user from the database."""
 
141
  async def id_info(c: Gojo, m: Message):
142
 
143
  ChatType = enums.ChatType
144
+ user_id, _, _ = await extract_user(c, m)
145
+ try:
146
+ if user_id and len(m.text.split()) == 2:
147
+ txt = f"Given user's id: <code>{user_id}</code>"
148
+ await m.reply_text(txt, parse_mode=enums.ParseMode.HTML)
149
+ return
150
+ elif m.chat.type in [ChatType.SUPERGROUP, ChatType.GROUP] and not m.reply_to_message:
151
+ await m.reply_text(text=f"This Group's ID is <code>{m.chat.id}</code>\nYour ID <code>{m.from_user.id}</code>")
152
+ return
153
 
154
+ elif m.chat.type == ChatType.PRIVATE and not m.reply_to_message:
155
+ await m.reply_text(text=f"Your ID is <code>{m.chat.id}</code>.")
156
+ return
157
+ except Exception as e:
158
+ await m.reply_text(e)
159
  return
 
 
160
  if user_id:
161
  if m.reply_to_message and m.reply_to_message.forward_from:
162
  user1 = m.reply_to_message.from_user
 
167
  fwd_id = f"<code>{user1.id}</code>"
168
  await m.reply_text(
169
  text=f"""Original Sender - {orig_sender} (<code>{orig_id}</code>)
170
+ Forwarder - {fwd_sender} (<code>{fwd_id}</code>)""",
171
  parse_mode=enums.ParseMode.HTML,
172
  )
173
  else:
 
191
  text+=f"Forwarded from user ID <code>{m.forward_from.id}</code>."
192
  elif m.forward_from_chat:
193
  text+=f"Forwarded from user ID <code>{m.forward_from_chat.id}</code>."
 
 
194
  await m.reply_text(text)
195
  else:
196
  text=f"Chat ID <code>{m.chat.id}</code>\nYour ID <code>{m.from_user.id}</code>"
 
 
197
  await m.reply_text(text)
198
  return
199
 
 
291
 
292
 
293
  def paste(content: str):
294
+ resp = resp_post(f"{BASE}api/documents", data=content)
295
  if resp.status_code != 200:
296
  return
297
  return BASE + resp["result"]['key']
 
371
  f"<b>Translated:</b> from {detectlang} to {target_lang} \n<code>``{tekstr.text}``</code>",
372
  )
373
 
374
+ @Gojo.on_message(command("bug"))
375
+ async def reporting_query(c: Gojo, m: Message):
376
+ repl = m.reply_to_message
377
+ if not repl:
378
+ await m.reply_text("Please reply to a message to report it as bug")
379
+ return
380
+ if not repl.text:
381
+ await m.reply_text("Please reply to a text message.")
382
+ return
383
+ txt = "#BUG\n"
384
+ txt += repl.text.html
385
+ txt += f"\nReported by: {m.from_user.id} ({m.from_user.mention})"
386
+ kb = InlineKeyboardMarkup([[InlineKeyboardButton("Update channel",url=f"https://t.me/{SUPPORT_GROUP}")],[InlineKeyboardButton("Report on github",url="https://github.com/Gojo-Bots/Gojo_Satoru/issues/new/choose")]])
387
+ try:
388
+ z = await c.send_message(MESSAGE_DUMP,txt,parse_mode=enums.ParseMode.HTML)
389
+ except Exception:
390
+ txt = repl.text.html
391
+ z = await c.send_message(MESSAGE_DUMP,txt,parse_mode=enums.ParseMode.HTML)
392
+ await z.reply_text(f"#BUG\nReported by: {m.from_user.id} ({m.from_user.mention})")
393
+ await m.reply_text("Successfully reported your bug",reply_markup=kb)
394
+ ppost = z.link
395
+ await c.send_message(OWNER_ID,f"New bug report\n{ppost}",disable_web_page_preview=True)
396
+ return
397
 
398
  __PLUGIN__ = "utils"
399
+ _DISABLE_CMDS_ = ["paste", "wiki", "id", "gifid", "tr", "github", "git", "bug"]
400
  __alt_name__ = ["util", "misc", "tools"]
401
 
402
  __HELP__ = """
 
412
  • /tr `<language>`: Translates the text and then replies to you with the language you have specifed, works as a reply to message.
413
  • /git `<username>`: Search for the user using github api!
414
  • /weebify `<text>` or `<reply to message>`: To weebify the text.
415
+ • /bug <reply to text message> : To report a bug
416
 
417
  **Example:**
418
  `/git iamgojoof6eyes`: this fetches the information about a user from the database."""
Powers/plugins/watchers.py CHANGED
@@ -5,7 +5,6 @@ from traceback import format_exc
5
  from pyrogram import filters
6
  from pyrogram.errors import ChatAdminRequired, RPCError, UserAdminInvalid
7
  from pyrogram.types import ChatPermissions, Message
8
- from RiZoeLX.functions import update_scanlist
9
 
10
  from Powers import LOGGER, MESSAGE_DUMP, SUPPORT_STAFF
11
  from Powers.bot_class import Gojo
@@ -167,8 +166,6 @@ async def bl_watcher(_, m: Message):
167
  return
168
 
169
 
170
- SCANLIST = []
171
-
172
 
173
  @Gojo.on_message(filters.user(list(ANTISPAM_BANNED)) & filters.group)
174
  async def gban_watcher(c: Gojo, m: Message):
@@ -210,20 +207,7 @@ async def gban_watcher(c: Gojo, m: Message):
210
  <b>Error:</b> <code>{ef}</code>""",
211
  )
212
 
213
- elif m.from_user.id in SCANLIST:
214
- msg = f"""
215
- ** Alert ⚠️**
216
- User {m.from_user.mention} is officially
217
- Scanned by TeamRed7 | Phoenix API ;)
218
- Appeal [Here](https://t.me/Red7WatchSupport)
219
- """
220
- try:
221
- await c.ban_chat_member(m.chat.id, m.from_user.id)
222
- await c.send_message(m.chat.id, msg, disable_web_page_preview=True)
223
- except Exception as a:
224
- LOGGER.error(a)
225
- LOGGER.error(format_exc())
226
- return
227
 
228
 
229
  @Gojo.on_message(filters.chat(BLACKLIST_CHATS))
 
5
  from pyrogram import filters
6
  from pyrogram.errors import ChatAdminRequired, RPCError, UserAdminInvalid
7
  from pyrogram.types import ChatPermissions, Message
 
8
 
9
  from Powers import LOGGER, MESSAGE_DUMP, SUPPORT_STAFF
10
  from Powers.bot_class import Gojo
 
166
  return
167
 
168
 
 
 
169
 
170
  @Gojo.on_message(filters.user(list(ANTISPAM_BANNED)) & filters.group)
171
  async def gban_watcher(c: Gojo, m: Message):
 
207
  <b>Error:</b> <code>{ef}</code>""",
208
  )
209
 
210
+
 
 
 
 
 
 
 
 
 
 
 
 
 
211
 
212
 
213
  @Gojo.on_message(filters.chat(BLACKLIST_CHATS))
Powers/plugins/web_con.py CHANGED
@@ -1,4 +1,6 @@
 
1
  import os
 
2
 
3
  from pyrogram import filters
4
  from pyrogram.types import CallbackQuery
@@ -10,7 +12,8 @@ from Powers import (LOGGER, RMBG, Audd, genius_lyrics, is_audd,
10
  is_genius_lyrics, is_rmbg)
11
  from Powers.bot_class import Gojo
12
  from Powers.utils.custom_filters import command
13
- from Powers.utils.http_helper import post
 
14
  from Powers.utils.web_helpers import *
15
 
16
 
@@ -19,6 +22,7 @@ async def telegraph_upload(c:Gojo,m:Message):
19
  if not m.reply_to_message:
20
  await m.reply_text("Reply to media/text to upload it to telegraph")
21
  return
 
22
  file = m.reply_to_message
23
  if file.text:
24
  if len(m.command) == 1:
@@ -26,24 +30,27 @@ async def telegraph_upload(c:Gojo,m:Message):
26
  elif len(m.command) > 1:
27
  name = " ".join(m.command[1:5])
28
  try:
29
- upload = telegraph_up(file,name)
30
  except Exception as e:
31
  await m.reply_text(f"Got an error\n{e}")
32
  return
33
  if upload:
34
- kb = IKM([[IKB("Here is link to file",url=upload)]])
35
- await m.reply_text("Here is your uploaded file",disable_web_page_preview=True,reply_markup=kb)
 
36
  return
37
  elif not upload:
38
  await m.reply_text("Failed to upload the text to telegraph")
39
- return
40
- size = await get_file_size(m.reply_to_message)
41
- form = size.split(None,1)
42
- if (form[-1] == "mb" and int(form[0]) > 5) or form[-1] == "gb":
43
- await m.reply_text("File size too big to upload\nLimit: 5mbs")
44
- return
 
 
45
  try:
46
- upload = telegraph_up(file)
47
  except Exception as e:
48
  await m.reply_text(f"Got an error\n{e}")
49
  return
@@ -55,84 +62,107 @@ async def telegraph_upload(c:Gojo,m:Message):
55
  await m.reply_text("Failed to upload the file to telegraph")
56
  return
57
 
58
- @Gojo.on_command(command["songname","insong","songinfo","whichsong","rsong","reversesong"])
59
- async def get_song_info(c: Gojo, m: Message):
60
- if not is_audd:
61
- await m.reply_text("Audd api is missing add it to use this command")
62
- return
63
- reply = m.reply_to_message
64
- if not reply:
65
- await m.reply_text("Reply to a video or audio file")
66
- return
67
- elif not (reply.video or reply.audio or reply.video_note or (reply.document.mime_type.split("/")[0] in ["video","audio"])):
68
- await m.reply_text("Reply to a video or audio file")
69
- return
70
- URL = "https://api.audd.io/"
71
- sizee = (await get_file_size(reply)).split()
72
- if (int(sizee[0]) <= 15 and sizee[1] == "mb") or sizee[1] == "kb":
73
- fpath = await reply.download()
74
- files = {
75
- "file" : open(fpath,"rb")
76
- }
77
- BASE_AUDD = {
78
- "api_token":Audd,
79
- "return": "spotify"
80
- }
81
- result = post(URL,data=BASE_AUDD, files=files)
82
- elif int(sizee[0]) > 15 or int(sizee[0]) <= 30 and sizee[1] == "mb":
83
- BASE_AUDD = {
84
- "api_token":Audd,
85
- "url": f'{reply.link}',
86
- "return": "spotify"
87
- }
88
- result = post(URL,data=BASE_AUDD)
89
- else:
90
- await m.reply_text("File size too big\nI can only fetch file of size upto 30 mbs for now")
91
- return
92
- os.remove(fpath)
93
- if result.status_code != 200:
94
- await m.reply_text(f"{result.status_code}:{result.text}")
95
- return
96
- data = result["result"]
97
- Artist = data["artist"]
98
- Title = data["title"]
99
- Release_date = data["release_date"]
100
- web_slink = data["song_link"]
101
- SPOTIFY = data["spotify"]
102
- spotify_url = SPOTIFY["external_urls"]
103
- album_url = SPOTIFY["album"]["external_urls"]
104
- Album = SPOTIFY["album"]["name"]
105
- photo = SPOTIFY["images"][0]["url"]
106
- artist_url = SPOTIFY["artists"]["external_urls"]
107
- cap = f"""
108
- Song name: {Title}
109
- Artist: {Artist}
110
- Album: {Album}
111
- Release data: {Release_date}
112
- """
113
- kb = [
114
- [
115
- IKB("🗂 Album", url=album_url),
116
- IKB("🎨 Artist",url=artist_url)
117
- ],
118
- [
119
- IKB("🎵 Spotify song link",url=spotify_url),
120
- IKB("♾ More links", url=web_slink)
121
- ]
122
- ]
123
- if is_genius_lyrics:
124
- g_k = [IKB("📝 Lyrics",f"lyrics_{Artist}:{Title}")]
125
- kb.append(g_k)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
 
127
- await m.reply_photo(photo,caption=cap,reply_markup=IKM(kb))
128
-
129
 
130
  @Gojo.on_callback_query(filters.regex("^lyrics_"))
131
  async def lyrics_for_song(c: Gojo, q: CallbackQuery):
132
  data = q.data.split("_")[1].split(":")
133
- song = data[1]
134
- artist = data[0]
135
- song = genius_lyrics.search_song(song,artist)
 
 
 
 
 
 
136
  if not song.lyrics:
137
  await q.answer("‼️ No lyrics found ‼️",True)
138
  return
@@ -162,7 +192,7 @@ async def lyrics_for_song(c: Gojo, q: CallbackQuery):
162
  await q.message.delete()
163
  return
164
 
165
- @Gojo.on_message(command["removebackground","removebg","rmbg"])
166
  async def remove_background(c: Gojo, m: Message):
167
  if not is_rmbg:
168
  await m.reply_text("Add rmbg api to use this command")
@@ -170,27 +200,51 @@ async def remove_background(c: Gojo, m: Message):
170
 
171
  reply = m.reply_to_message
172
  if not reply:
173
- await m.reply_text("Reply to image to remove it's background")
 
 
 
174
  return
175
- elif not (reply.photo or reply.document.mime_type.split("/")[0] == "image" or reply.sticker and (reply.sticker.is_animated or reply.sticker.is_video)):
176
- await m.reply_text("Reply to image to remove it's background")
177
  return
 
178
  URL = "https://api.remove.bg/v1.0/removebg"
179
- file = await reply.download("Gojo_Satoru.png")
180
- to_path = file.replace("\\","/").rsplit("/",1)[0]
 
 
 
181
  finfo = {'image_file':open(file,'rb')}
182
  Data = {'size':'auto'}
183
  Headers = {'X-Api-Key':RMBG}
184
- result = post(URL,files=finfo,data=Data,headers=Headers)
185
- os.remove(file)
 
186
  if result.status_code != 200:
187
  await m.reply_text(f"{result.status_code}:{result.text}")
 
188
  return
189
- to_path = f'{to_path}/no-bg.png'
 
 
 
 
 
 
 
 
190
  with open(to_path,'wb') as out:
191
  out.write(result.content)
192
- await m.reply_photo(to_path)
193
- os.remove(to_path)
 
 
 
 
 
 
 
194
  return
195
 
196
  @Gojo.on_message(command(["song","yta"]))
@@ -202,11 +256,15 @@ async def song_down_up(c: Gojo, m: Message):
202
  else:
203
  is_direct = False
204
  query = splited
 
205
  try:
206
  await youtube_downloader(c,m,query,is_direct,"a")
 
207
  return
208
  except Exception as e:
209
- await m.reply_text(f"Got an error\n{e}")
 
 
210
  return
211
 
212
  @Gojo.on_message(command(["vsong","ytv"]))
@@ -218,11 +276,15 @@ async def video_down_up(c: Gojo, m: Message):
218
  else:
219
  is_direct = False
220
  query = splited
 
221
  try:
222
  await youtube_downloader(c,m,query,is_direct,"v")
 
223
  return
224
  except Exception as e:
225
- await m.reply_text(f"Got an error\n{e}")
 
 
226
  return
227
 
228
  __PLUGIN__ = "web support"
@@ -231,9 +293,8 @@ __HELP__ = """
231
  **Available commands**
232
  • /telegraph (/tgh, /tgm) <page name> : Reply to media which you want to upload to telegraph.
233
  • /rmbg (/removebg, /removebackground) : Reply to image file or sticker of which you want to remove background
234
- • /whichsong (/songname, /songinfo, /insong, /rsong, /reversesong) : Reply to file to get the song playing in it.
235
  • /song (/yta) <songname or youtube link>
236
  • /vsong (/ytv) <songname or youtube link>
237
 
238
- **Bot will not download any song or video having duration greater than 5 minutes (to reduce the load on bot's server)**
239
  """
 
1
+ import asyncio
2
  import os
3
+ from traceback import format_exc
4
 
5
  from pyrogram import filters
6
  from pyrogram.types import CallbackQuery
 
12
  is_genius_lyrics, is_rmbg)
13
  from Powers.bot_class import Gojo
14
  from Powers.utils.custom_filters import command
15
+ from Powers.utils.http_helper import *
16
+ from Powers.utils.sticker_help import toimage
17
  from Powers.utils.web_helpers import *
18
 
19
 
 
22
  if not m.reply_to_message:
23
  await m.reply_text("Reply to media/text to upload it to telegraph")
24
  return
25
+ XnX = await m.reply_text("⏳")
26
  file = m.reply_to_message
27
  if file.text:
28
  if len(m.command) == 1:
 
30
  elif len(m.command) > 1:
31
  name = " ".join(m.command[1:5])
32
  try:
33
+ upload = await telegraph_up(file,name)
34
  except Exception as e:
35
  await m.reply_text(f"Got an error\n{e}")
36
  return
37
  if upload:
38
+ await XnX.delete()
39
+ kb = IKM([[IKB("Here is link to the uploaded text",url=upload)]])
40
+ await m.reply_text("Here is your uploaded text",disable_web_page_preview=True,reply_markup=kb)
41
  return
42
  elif not upload:
43
  await m.reply_text("Failed to upload the text to telegraph")
44
+ return
45
+ if m.reply_to_message.photo or m.reply_to_message.document or m.reply_to_message.audio or m.reply_to_message.video:
46
+ size = await get_file_size(m.reply_to_message)
47
+ form = size.split(None,1)
48
+ if (form[-1] == "mb" and int(form[0]) > 5) or form[-1] == "gb":
49
+ await XnX.edit_text("File size too big to upload\nLimit: 5mbs")
50
+ return
51
+ await XnX.delete()
52
  try:
53
+ upload = await telegraph_up(file)
54
  except Exception as e:
55
  await m.reply_text(f"Got an error\n{e}")
56
  return
 
62
  await m.reply_text("Failed to upload the file to telegraph")
63
  return
64
 
65
+ # @Gojo.on_message(command(["songname","insong","songinfo","whichsong","rsong","reversesong"]))
66
+ # /whichsong (/songname, /songinfo, /insong, /rsong, /reversesong) : Reply to file to get the song playing in it.
67
+ # async def get_song_info(c: Gojo, m: Message):
68
+ # if not is_audd:
69
+ # await m.reply_text("Audd api is missing add it to use this command")
70
+ # return
71
+ # reply = m.reply_to_message
72
+ # if not reply:
73
+ # await m.reply_text("Reply to a video or audio file")
74
+ # return
75
+ # elif reply.text:
76
+ # await m.reply_text("Reply to a video or audio file")
77
+ # return
78
+ # elif not (reply.video or reply.audio or reply.video_note or reply.document and (reply.document.mime_type.split("/")[0] in ["video","audio"])):
79
+ # await m.reply_text("Reply to a video or audio file")
80
+ # return
81
+ # try:
82
+ # XnX = await m.reply_text("")
83
+ # URL = "https://api.audd.io/"
84
+ # sizee = (await get_file_size(reply)).split()
85
+ # if (int(sizee[0]) <= 30 and sizee[1] == "mb") or sizee[1] == "kb":
86
+ # fpath = await reply.download()
87
+ # files = {
88
+ # "file" : open(fpath,"rb")
89
+ # }
90
+ # BASE_AUDD = {
91
+ # "api_token":Audd,
92
+ # "return": "spotify"
93
+ # }
94
+ # result = resp_post(URL,data=BASE_AUDD, files=files)
95
+ # # elif int(sizee[0]) > 15 or int(sizee[0]) <= 30 and sizee[1] == "mb":
96
+ # # BASE_AUDD = {
97
+ # # "api_token":Audd,
98
+ # # "url": f'{reply.link}',
99
+ # # "return": "spotify"
100
+ # # }
101
+ # # result = resp_post(URL,data=BASE_AUDD)
102
+ # else:
103
+ # await XnX.edit_text("File size too big\nI can only fetch file of size upto 30 mbs for now")
104
+ # return
105
+ # if result.status_code != 200:
106
+ # await XnX.edit_text(f"{result.status_code}:{result.text}")
107
+ # return
108
+ # result = result.json()
109
+ # data = result["result"]
110
+ # Artist = data["artist"]
111
+ # Title = data["title"]
112
+ # Release_date = data["release_date"]
113
+ # web_slink = data["song_link"]
114
+ # SPOTIFY = data["spotify"]
115
+ # spotify_url = SPOTIFY["external_urls"]
116
+ # album_url = SPOTIFY["album"]["external_urls"]
117
+ # Album = SPOTIFY["album"]["name"]
118
+ # photo = SPOTIFY["images"][0]["url"]
119
+ # artist_url = SPOTIFY["artists"]["external_urls"]
120
+ # cap = f"""
121
+ # Song name: {Title}
122
+ # Artist: {Artist}
123
+ # Album: {Album}
124
+ # Release data: {Release_date}
125
+ # """
126
+ # youtube_link = (await song_search(Title))[1]["link"]
127
+ # kb = [
128
+ # [
129
+ # IKB("🗂 Album", url=album_url),
130
+ # IKB("🎨 Artist",url=artist_url)
131
+ # ],
132
+ # [
133
+ # IKB("🎵 Spotify song link",url=spotify_url),
134
+ # IKB("▶️ Youtube",url=youtube_link)
135
+ # ],
136
+ # [IKB("♾ More links", url=web_slink)]
137
+ # ]
138
+ # if is_genius_lyrics:
139
+ # g_k = [IKB("📝 Lyrics",f"lyrics_{Title}:{Artist}")]
140
+ # kb.append(g_k)
141
+ # await XnX.delete()
142
+ # os.remove(fpath)
143
+ # await m.reply_photo(photo,caption=cap,reply_markup=IKM(kb))
144
+ # except Exception as e:
145
+ # await XnX.delete()
146
+ # await m.reply_text(f"Error\n{e}")
147
+ # try:
148
+ # os.remove(fpath)
149
+ # except Exception:
150
+ # pass
151
+ # return
152
 
 
 
153
 
154
  @Gojo.on_callback_query(filters.regex("^lyrics_"))
155
  async def lyrics_for_song(c: Gojo, q: CallbackQuery):
156
  data = q.data.split("_")[1].split(":")
157
+ song = data[0]
158
+ try:
159
+ artist = data[1]
160
+ except IndexError:
161
+ artist = None
162
+ if artist:
163
+ song = genius_lyrics.search_song(song,artist)
164
+ elif not artist:
165
+ song = genius_lyrics.search_song(song)
166
  if not song.lyrics:
167
  await q.answer("‼️ No lyrics found ‼️",True)
168
  return
 
192
  await q.message.delete()
193
  return
194
 
195
+ @Gojo.on_message(command(["removebackground","removebg","rmbg"]))
196
  async def remove_background(c: Gojo, m: Message):
197
  if not is_rmbg:
198
  await m.reply_text("Add rmbg api to use this command")
 
200
 
201
  reply = m.reply_to_message
202
  if not reply:
203
+ await m.reply_text("Reply to image/sticker to remove it's background")
204
+ return
205
+ elif not (reply.photo or (reply.document and reply.document.mime_type.split("/")[0] == "image") or reply.sticker):
206
+ await m.reply_text("Reply to image/sticker to remove it's background")
207
  return
208
+ elif reply.sticker and (reply.sticker.is_video or reply.sticker.is_animated):
209
+ await m.reply_text("Reply to normal sticker to remove it's background")
210
  return
211
+ XnX = await m.reply_text("⏳")
212
  URL = "https://api.remove.bg/v1.0/removebg"
213
+ if reply.sticker:
214
+ filee = await reply.download()
215
+ file = toimage(filee)
216
+ else:
217
+ file = await reply.download()
218
  finfo = {'image_file':open(file,'rb')}
219
  Data = {'size':'auto'}
220
  Headers = {'X-Api-Key':RMBG}
221
+ result = resp_post(URL,files=finfo,data=Data,headers=Headers)
222
+ await XnX.delete()
223
+ contentType = result.headers.get("content-type")
224
  if result.status_code != 200:
225
  await m.reply_text(f"{result.status_code}:{result.text}")
226
+ os.remove(file)
227
  return
228
+ elif "image" not in contentType:
229
+ await m.reply_text(f"Error\n{result.content.decode('UTF-8')}")
230
+ os.remove(file)
231
+ return
232
+ to_path = "./downloads"
233
+ if reply.sticker:
234
+ to_path = f'{to_path}/no-bg.webp'
235
+ else:
236
+ to_path = f'{to_path}/no-bg.png'
237
  with open(to_path,'wb') as out:
238
  out.write(result.content)
239
+ if reply.sticker:
240
+ await m.reply_sticker(to_path)
241
+ else:
242
+ await m.reply_photo(to_path)
243
+ try:
244
+ os.remove(file)
245
+ os.remove(to_path)
246
+ except PermissionError:
247
+ await asyncio.sleep(5)
248
  return
249
 
250
  @Gojo.on_message(command(["song","yta"]))
 
256
  else:
257
  is_direct = False
258
  query = splited
259
+ XnX = await m.reply_text("⏳")
260
  try:
261
  await youtube_downloader(c,m,query,is_direct,"a")
262
+ await XnX.delete()
263
  return
264
  except Exception as e:
265
+ await XnX.edit_text(f"Got an error\n{e}")
266
+ LOGGER.error(e)
267
+ LOGGER.error(format_exc())
268
  return
269
 
270
  @Gojo.on_message(command(["vsong","ytv"]))
 
276
  else:
277
  is_direct = False
278
  query = splited
279
+ XnX = await m.reply_text("⏳")
280
  try:
281
  await youtube_downloader(c,m,query,is_direct,"v")
282
+ await XnX.delete()
283
  return
284
  except Exception as e:
285
+ await XnX.edit_text(f"Got an error\n{e}")
286
+ LOGGER.error(e)
287
+ LOGGER.error(format_exc())
288
  return
289
 
290
  __PLUGIN__ = "web support"
 
293
  **Available commands**
294
  • /telegraph (/tgh, /tgm) <page name> : Reply to media which you want to upload to telegraph.
295
  • /rmbg (/removebg, /removebackground) : Reply to image file or sticker of which you want to remove background
 
296
  • /song (/yta) <songname or youtube link>
297
  • /vsong (/ytv) <songname or youtube link>
298
 
299
+ **Bot will not download any song or video having duration greater than 10 minutes (to reduce the load on bot's server)**
300
  """
Powers/utils/custom_filters.py CHANGED
@@ -156,6 +156,8 @@ async def admin_check_func(_, __, m: Message or CallbackQuery):
156
  if m.sender_chat:
157
  return True
158
 
 
 
159
 
160
  try:
161
  admin_group = {i[0] for i in ADMIN_CACHE[m.chat.id]}
@@ -183,6 +185,9 @@ async def owner_check_func(_, __, m: Message or CallbackQuery):
183
 
184
  if m.chat.type not in [ChatType.SUPERGROUP, ChatType.GROUP]:
185
  return False
 
 
 
186
 
187
  user = await m.chat.get_member(m.from_user.id)
188
 
@@ -209,10 +214,12 @@ async def restrict_check_func(_, __, m: Message or CallbackQuery):
209
  ):
210
  return False
211
 
 
 
212
 
213
  user = await m.chat.get_member(m.from_user.id)
214
 
215
- if user.privileges.can_restrict_members or user.status == CMS.OWNER:
216
  status = True
217
  else:
218
  status = False
@@ -229,10 +236,12 @@ async def promote_check_func(_, __, m):
229
  if m.chat.type not in [ChatType.SUPERGROUP, ChatType.GROUP]:
230
  return False
231
 
 
 
232
 
233
  user = await m.chat.get_member(m.from_user.id)
234
 
235
- if user.privileges.can_promote_members or user.status == CMS.OWNER:
236
  status = True
237
  else:
238
  status = False
@@ -257,7 +266,7 @@ async def changeinfo_check_func(_, __, m):
257
 
258
  user = await m.chat.get_member(m.from_user.id)
259
 
260
- if user.privileges.can_change_info or user.status == CMS.OWNER:
261
  status = True
262
  else:
263
  status = False
@@ -285,7 +294,7 @@ async def can_pin_message_func(_, __, m):
285
 
286
  user = await m.chat.get_member(m.from_user.id)
287
 
288
- if user.privileges.can_pin_messages or user.status == CMS.OWNER:
289
  status = True
290
  else:
291
  status = False
 
156
  if m.sender_chat:
157
  return True
158
 
159
+ if not m.from_user:
160
+ return False
161
 
162
  try:
163
  admin_group = {i[0] for i in ADMIN_CACHE[m.chat.id]}
 
185
 
186
  if m.chat.type not in [ChatType.SUPERGROUP, ChatType.GROUP]:
187
  return False
188
+
189
+ if not m.from_user:
190
+ return False
191
 
192
  user = await m.chat.get_member(m.from_user.id)
193
 
 
214
  ):
215
  return False
216
 
217
+ if not m.from_user:
218
+ return False
219
 
220
  user = await m.chat.get_member(m.from_user.id)
221
 
222
+ if user.status in [CMS.ADMINISTRATOR, CMS.OWNER] and user.privileges.can_restrict_members:
223
  status = True
224
  else:
225
  status = False
 
236
  if m.chat.type not in [ChatType.SUPERGROUP, ChatType.GROUP]:
237
  return False
238
 
239
+ if not m.from_user:
240
+ return False
241
 
242
  user = await m.chat.get_member(m.from_user.id)
243
 
244
+ if user.status in [CMS.ADMINISTRATOR, CMS.OWNER] and user.privileges.can_promote_members:
245
  status = True
246
  else:
247
  status = False
 
266
 
267
  user = await m.chat.get_member(m.from_user.id)
268
 
269
+ if user.status in [CMS.ADMINISTRATOR, CMS.OWNER] and user.privileges.can_change_info:
270
  status = True
271
  else:
272
  status = False
 
294
 
295
  user = await m.chat.get_member(m.from_user.id)
296
 
297
+ if user.status in [CMS.ADMINISTRATOR, CMS.OWNER] and user.privileges.can_pin_messages:
298
  status = True
299
  else:
300
  status = False
Powers/utils/extras.py CHANGED
@@ -690,3 +690,82 @@ StartPic = [
690
  "https://te.legra.ph/file/52d92a67f0c6ce0a9f89f.jpg",
691
  "https://te.legra.ph/file/d91e7353b3803a8148bfc.jpg",
692
  ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
690
  "https://te.legra.ph/file/52d92a67f0c6ce0a9f89f.jpg",
691
  "https://te.legra.ph/file/d91e7353b3803a8148bfc.jpg",
692
  ]
693
+
694
+
695
+ birthday_wish = [
696
+ "Wishing you a happy birthday filled with love and joy.",
697
+ "Hope your birthday is as wonderful as you are.",
698
+ "Happy birthday to someone who deserves a truly special day.",
699
+ "May your birthday be full of surprises and delight.",
700
+ "Wishing you a year filled with new adventures and accomplishments.",
701
+ "May your birthday be as sweet as cake and as joyful as the celebration.",
702
+ "Here's to a fabulous birthday and a year filled with blessings.",
703
+ "Sending you lots of love and warm wishes on your special day.",
704
+ "May your birthday be a time for reflection, relaxation, and joy.",
705
+ "Cheers to another year of making unforgettable memories!",
706
+ "May your birthday be filled with laughter, love, and good times.",
707
+ "Wishing you a birthday that's just as amazing as you are.",
708
+ "Here's to a year filled with love, happiness, and success.",
709
+ "May your birthday be filled with all the love and blessings you deserve.",
710
+ "Sending you warm wishes for a joyful and memorable birthday.",
711
+ "Wishing you a birthday that's as wonderful as you are.",
712
+ "May your birthday be a time to celebrate all the amazing things you've accomplished.",
713
+ "Here's to another year of blessings, love, and adventure.",
714
+ "Sending you lots of love, hugs, and birthday wishes.",
715
+ "May your birthday be full of sunshine, laughter, and good times.",
716
+ "Wishing you a year filled with happiness, success, and love.",
717
+ "Here's to a fantastic birthday and an even better year ahead!",
718
+ "May your birthday be a day filled with joy, love, and celebration.",
719
+ "Sending you lots of love and warm wishes on your special day.",
720
+ "Wishing you a birthday that's as bright and beautiful as you are.",
721
+ "May your birthday be full of love, laughter, and happiness.",
722
+ "Here's to a year filled with exciting adventures and new opportunities.",
723
+ "Wishing you a birthday that's just as amazing as you are.",
724
+ "May your birthday be a time to reflect on all the wonderful things in your life.",
725
+ "Sending you lots of love, hugs, and birthday wishes from afar.",
726
+ "Wishing you a year filled with love, laughter, and all your heart desires.",
727
+ "May your birthday be a time to relax, unwind, and enjoy the company of loved ones.",
728
+ "Here's to another year of blessings, love, and adventure.",
729
+ "Sending you warm wishes for a wonderful and unforgettable birthday.",
730
+ "Wishing you a birthday that's as special and unique as you are.",
731
+ "May your birthday be a time to cherish all the special moments and memories you've created.",
732
+ "Here's to a year filled with joy, laughter, and happiness.",
733
+ "Wishing you a birthday that's just as amazing as you are.",
734
+ "May your birthday be a time to celebrate your wonderful achievements and accomplishments.",
735
+ "Sending you lots of love, hugs, and birthday wishes to make your day extra special.",
736
+ "Wishing you a year filled with love, happiness, and all your heart's desires.",
737
+ "May your birthday be a time to create new memories and cherish old ones.",
738
+ "Here's to another year of blessings, love, and adventure.",
739
+ "Sending you warm wishes for a fabulous and unforgettable birthday.",
740
+ "Wishing you a birthday that's full of love, laughter, and happiness.",
741
+ "May your birthday be a time to appreciate all the wonderful people in your life.",
742
+ "Wishing you a birthday as amazing as you are, filled with joy and memories to last a lifetime.",
743
+ "May your birthday be full of laughter and love, and your year be full of happiness and success.",
744
+ "Happy birthday to someone who makes the world a better place, may all your wishes come true.",
745
+ "Sending you warm birthday wishes and virtual hugs, can't wait to celebrate in person!",
746
+ "May your birthday be as special as you are, surrounded by all the people who love you the most.",
747
+ "Wishing you a day filled with laughter, and a year filled with new adventures and opportunities.",
748
+ "Happy birthday to someone who's always there to brighten up my day, may your day be as bright as you are.",
749
+ "Here's to a birthday that's just as awesome as you are, and a year filled with love and happiness.",
750
+ "May your birthday be a time to reflect on all the wonderful memories you've made, and look forward to new ones.",
751
+ "Wishing you a birthday that's full of surprises and excitement, and a year filled with new beginnings.",
752
+ "Happy birthday to my favorite person in the world, may your day be as special as you are to me.",
753
+ "Sending you the biggest birthday hugs and all my love, may your day be filled with joy and celebration.",
754
+ "May your birthday be a time to celebrate all your accomplishments and be proud of all you've achieved.",
755
+ "Wishing you a birthday that's as bright and beautiful as you are, filled with love and laughter.",
756
+ "Happy birthday to a true gem, may your day be filled with joy, laughter, and all the things you love.",
757
+ "Here's to a birthday that's full of happiness, excitement, and all the people who make your life special.",
758
+ "May your birthday be a time to let loose and have fun, and your year be filled with growth and success.",
759
+ "Wishing you a birthday that's full of all the things you love, and a year that's even better than the last.",
760
+ "Happy birthday to someone who makes my life brighter, may your day be as amazing as you are.",
761
+ "Sending you lots of love and virtual hugs on your special day, may your year be filled with blessings.",
762
+ "May your birthday be a time to cherish all the people who make your life special, and celebrate the person you've become.",
763
+ "Wishing you a birthday that's as unique and wonderful as you are, filled with love and laughter.",
764
+ "Happy birthday to someone who's always been there for me, may your day be filled with joy and celebration.",
765
+ "Here's to a birthday that's full of love, happiness, and all the things that bring you the most joy.",
766
+ "May your birthday be a time to reflect on all the amazing things you've accomplished, and look forward to all that's to come.",
767
+ "Wishing you a birthday that's full of surprises, happiness, and all the things that make you feel alive.",
768
+ "Happy birthday to someone who brings a smile to my face every day, may your day be as wonderful as you are.",
769
+ "Sending you all my love and warmest wishes on your special day, may your year be filled with love and happiness.",
770
+ "May your birthday be a time to appreciate all the people who make your life special, and cherish all the memories you've created.",
771
+ "Wishing you a birthday that's as beautiful as you are, filled with joy and celebration.",]
Powers/utils/start_utils.py CHANGED
@@ -49,7 +49,15 @@ async def gen_start_kb(q: Message or CallbackQuery):
49
  "url",
50
  ),
51
  ],
52
- [("📚 Commands & Help", "commands")],
 
 
 
 
 
 
 
 
53
  [
54
  (
55
  "🗃️ Source Code",
@@ -58,8 +66,8 @@ async def gen_start_kb(q: Message or CallbackQuery):
58
  ),
59
  (
60
  "Owner ❤️",
61
- f"https://t.me/{Config.owner_username}",
62
- "url",
63
  ),
64
  ],
65
  [
@@ -260,7 +268,7 @@ async def get_help_msg(m: Message or CallbackQuery, help_option: str):
260
  )
261
  else:
262
  help_msg = """
263
- Hey There! My name is Gojo.
264
  I'm here to help you manage your groups!
265
  Commands available:
266
  × /start: Start the bot
 
49
  "url",
50
  ),
51
  ],
52
+ [
53
+ (
54
+ "📚 Commands & Help", "commands"
55
+ ),
56
+ (
57
+ "👾 Bot info",
58
+ "bot_curr_info"
59
+ )
60
+ ],
61
  [
62
  (
63
  "🗃️ Source Code",
 
66
  ),
67
  (
68
  "Owner ❤️",
69
+ Config.OWNER_ID,
70
+ "user_id",
71
  ),
72
  ],
73
  [
 
268
  )
269
  else:
270
  help_msg = """
271
+ Hey There! I am Gojo.
272
  I'm here to help you manage your groups!
273
  Commands available:
274
  × /start: Start the bot
Powers/utils/sticker_help.py CHANGED
@@ -6,12 +6,14 @@ import textwrap
6
  from typing import List, Tuple
7
 
8
  from PIL import Image, ImageDraw, ImageFont
9
- from pyrogram import Client, errors, raw
10
  from pyrogram.file_id import FileId
11
 
 
 
12
 
13
  async def get_sticker_set_by_name(
14
- client: Client, name: str
15
  ) -> raw.base.messages.StickerSet:
16
  try:
17
  return await client.invoke(
@@ -26,7 +28,7 @@ async def get_sticker_set_by_name(
26
 
27
 
28
  async def create_sticker_set(
29
- client: Client,
30
  owner: int,
31
  title: str,
32
  short_name: str,
@@ -47,7 +49,7 @@ async def create_sticker_set(
47
 
48
 
49
  async def add_sticker_to_set(
50
- client: Client,
51
  stickerset: raw.base.messages.StickerSet,
52
  sticker: raw.base.InputStickerSetItem,
53
  ) -> raw.base.messages.StickerSet:
@@ -73,7 +75,6 @@ STICKER_DIMENSIONS = (512, 512)
73
 
74
  async def resize_file_to_sticker_size(file_path: str,length:int=512,width:int=512) -> str:
75
  im = Image.open(file_path)
76
- file_path = file_path.replace("\\","/").rsplit("/",1)[0]
77
  if (im.width, im.height) < STICKER_DIMENSIONS:
78
  size1 = im.width
79
  size2 = im.height
@@ -91,16 +92,16 @@ async def resize_file_to_sticker_size(file_path: str,length:int=512,width:int=51
91
  im = im.resize(sizenew)
92
  else:
93
  im.thumbnail(STICKER_DIMENSIONS)
94
- try:
95
- os.remove(file_path)
96
- file_path = f"{file_path}/resized.png"
97
- return file_path
98
- finally:
99
- im.save(file_path)
100
 
101
 
102
  async def upload_document(
103
- client: Client, file_path: str, chat_id: int
104
  ) -> raw.base.InputDocument:
105
  media = await client.invoke(
106
  raw.functions.messages.UploadMedia(
@@ -113,6 +114,7 @@ async def upload_document(
113
  file_name=os.path.basename(file_path)
114
  )
115
  ],
 
116
  ),
117
  )
118
  )
@@ -133,11 +135,9 @@ async def get_document_from_file_id(
133
  file_reference=decoded.file_reference,
134
  )
135
 
136
- async def draw_meme(image_path, text):
137
  """Hellbot se churaya hai hue hue hue..."""
138
  img = Image.open(image_path)
139
- UwU = image_path.rsplit("/")[0]
140
- os.remove(image_path)
141
  i_width, i_height = img.size
142
  m_font = ImageFont.truetype(
143
  "./extras/comic.ttf", int((70 / 640) * i_width)
@@ -150,7 +150,7 @@ async def draw_meme(image_path, text):
150
  draw = ImageDraw.Draw(img)
151
  current_h, pad = 10, 5
152
  if upper_text:
153
- for u_text in textwrap.wrap(upper_text, width=15):
154
  u_width, u_height = draw.textsize(u_text, font=m_font)
155
  draw.text(
156
  xy=(((i_width - u_width) / 2) - 1, int((current_h / 640) * i_width)),
@@ -184,7 +184,7 @@ async def draw_meme(image_path, text):
184
  )
185
  current_h += u_height + pad
186
  if lower_text:
187
- for l_text in textwrap.wrap(lower_text, width=15):
188
  u_width, u_height = draw.textsize(l_text, font=m_font)
189
  draw.text(
190
  xy=(
@@ -232,11 +232,32 @@ async def draw_meme(image_path, text):
232
  fill=(255, 255, 255),
233
  )
234
  current_h += u_height + pad
235
-
236
- hue = f"{UwU}/@memesofdank_memer_hu_vai.png"
237
- stick_path = await resize_file_to_sticker_size(hue)
238
- mee = hue = f"{stick_path.rsplit('/',1)[0]}/@memesofdank_memer_hu_vai.webp"
239
- os.remove(stick_path)
 
 
240
  img.save(hue)
241
  img.save(mee)
242
  return hue, mee
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  from typing import List, Tuple
7
 
8
  from PIL import Image, ImageDraw, ImageFont
9
+ from pyrogram import errors, raw
10
  from pyrogram.file_id import FileId
11
 
12
+ from Powers.bot_class import Gojo
13
+
14
 
15
  async def get_sticker_set_by_name(
16
+ client: Gojo, name: str
17
  ) -> raw.base.messages.StickerSet:
18
  try:
19
  return await client.invoke(
 
28
 
29
 
30
  async def create_sticker_set(
31
+ client: Gojo,
32
  owner: int,
33
  title: str,
34
  short_name: str,
 
49
 
50
 
51
  async def add_sticker_to_set(
52
+ client: Gojo,
53
  stickerset: raw.base.messages.StickerSet,
54
  sticker: raw.base.InputStickerSetItem,
55
  ) -> raw.base.messages.StickerSet:
 
75
 
76
  async def resize_file_to_sticker_size(file_path: str,length:int=512,width:int=512) -> str:
77
  im = Image.open(file_path)
 
78
  if (im.width, im.height) < STICKER_DIMENSIONS:
79
  size1 = im.width
80
  size2 = im.height
 
92
  im = im.resize(sizenew)
93
  else:
94
  im.thumbnail(STICKER_DIMENSIONS)
95
+
96
+ file_pathh = "./downloads/resized.png"
97
+ im.save(file_pathh)
98
+ os.remove(file_path)
99
+ return file_pathh
100
+
101
 
102
 
103
  async def upload_document(
104
+ client: Gojo, file_path: str, chat_id: int
105
  ) -> raw.base.InputDocument:
106
  media = await client.invoke(
107
  raw.functions.messages.UploadMedia(
 
114
  file_name=os.path.basename(file_path)
115
  )
116
  ],
117
+ force_file=True,
118
  ),
119
  )
120
  )
 
135
  file_reference=decoded.file_reference,
136
  )
137
 
138
+ async def draw_meme(image_path, text:str,stick):
139
  """Hellbot se churaya hai hue hue hue..."""
140
  img = Image.open(image_path)
 
 
141
  i_width, i_height = img.size
142
  m_font = ImageFont.truetype(
143
  "./extras/comic.ttf", int((70 / 640) * i_width)
 
150
  draw = ImageDraw.Draw(img)
151
  current_h, pad = 10, 5
152
  if upper_text:
153
+ for u_text in textwrap.wrap(upper_text,width=15,subsequent_indent=" "):
154
  u_width, u_height = draw.textsize(u_text, font=m_font)
155
  draw.text(
156
  xy=(((i_width - u_width) / 2) - 1, int((current_h / 640) * i_width)),
 
184
  )
185
  current_h += u_height + pad
186
  if lower_text:
187
+ for l_text in textwrap.wrap(upper_text,width=15,subsequent_indent=" "):
188
  u_width, u_height = draw.textsize(l_text, font=m_font)
189
  draw.text(
190
  xy=(
 
232
  fill=(255, 255, 255),
233
  )
234
  current_h += u_height + pad
235
+
236
+ hue = image_path
237
+ if stick:
238
+ stick_path = image_path
239
+ else:
240
+ stick_path = await resize_file_to_sticker_size(hue)
241
+ mee = tosticker(stick_path,"@memesofdank_memer_hu_vai.webp")
242
  img.save(hue)
243
  img.save(mee)
244
  return hue, mee
245
+
246
+ def toimage(image, filename=None):
247
+ filename = filename if filename else "gojo.jpg"
248
+ img = Image.open(image)
249
+ if img.mode != "RGB":
250
+ img = img.convert("RGB")
251
+ img.save(filename, "jpeg")
252
+ os.remove(image)
253
+ return filename
254
+
255
+
256
+ def tosticker(response, filename=None):
257
+ filename = filename if filename else "gojo.webp"
258
+ image = Image.open(response)
259
+ if image.mode != "RGB":
260
+ image.convert("RGB")
261
+ image.save(filename, "webp")
262
+ os.remove(response)
263
+ return filename
Powers/utils/web_helpers.py CHANGED
@@ -20,16 +20,20 @@ async def get_file_size(file: Message):
20
  size = file.document.file_size/1024
21
  elif file.video:
22
  size = file.video.file_size/1024
23
-
 
 
 
 
24
  if size <= 1024:
25
- return f"{round(size,3)} kb"
26
  elif size > 1024:
27
  size = size/1024
28
  if size <= 1024:
29
- return f"{round(size,3)} mb"
30
  elif size > 1024:
31
  size = size/1024
32
- return f"{round(size,3)} gb"
33
 
34
  async def telegraph_up(file:Message=None,name=None,content=None):
35
  if not name:
@@ -70,9 +74,9 @@ class GOJO_YTS:
70
  encoded_search = parse.quote_plus(self.search_terms)
71
  BASE_URL = "https://youtube.com"
72
  url = f"{BASE_URL}/results?search_query={encoded_search}"
73
- response = get(url).text
74
  while "ytInitialData" not in response:
75
- response = get(url).text
76
  results = self._parse_html(response)
77
  if self.max_results is not None and len(results) > self.max_results:
78
  return results[: self.max_results]
@@ -145,9 +149,18 @@ async def song_search(query, max_results=1):
145
  except KeyError:
146
  return
147
  yt_dict = {}
148
- if not (i['duration'] > 300):
149
- nums = 1
150
- for i in results["videos"]:
 
 
 
 
 
 
 
 
 
151
  dict_form = {
152
  "link": f"https://www.youtube.com{i['url_suffix']}",
153
  "title": i['title'],
@@ -155,11 +168,11 @@ async def song_search(query, max_results=1):
155
  "channel": i['channel'],
156
  "duration": i['duration'],
157
  "thumbnail": i['thumbnails'][0]
158
- }
159
  yt_dict.update({nums: dict_form})
160
  nums += 1
161
- else:
162
- pass
163
  return yt_dict
164
 
165
  song_opts = {
@@ -219,19 +232,23 @@ async def youtube_downloader(c:Gojo,m:Message,query:str,is_direct:bool,type_:str
219
  dicti = await song_search(query, 1)
220
  if not dicti:
221
  await m.reply_text("File with duration less than or equals to 5 minutes is allowed only")
222
- return
223
- query = dicti['link']
224
- FILE = ydl.extract_info(query,download=False)
225
- if FILE['duration'] > 300:
226
  await m.reply_text("File with duration less than or equals to 5 minutes is allowed only")
227
  return
228
  f_name = FILE['title']
229
  uploader = FILE['uploader']
230
  up_url = FILE['uploader_url']
231
  views = FILE['view_count']
232
- url = f"https://www.youtube.com/watch?v={FILE['id']}"
233
- f_path = ydl.prepare_filename(FILE)
234
- ydl.download([query])
 
 
 
 
 
235
  cap = f"""
236
  ✘ Name: `{f_name}`
237
  ✘ Views: `{views}`
@@ -245,12 +262,13 @@ async def youtube_downloader(c:Gojo,m:Message,query:str,is_direct:bool,type_:str
245
  ]
246
  )
247
  if video:
248
- m.reply_video(f_path,caption=cap,reply_markup=kb)
249
  os.remove(f_path)
250
  return
251
  elif song:
252
- m.reply_audio(f_path,caption=cap,reply_markup=kb)
253
  os.remove(f_path)
 
254
  return
255
 
256
 
 
20
  size = file.document.file_size/1024
21
  elif file.video:
22
  size = file.video.file_size/1024
23
+ elif file.audio:
24
+ size = file.audio.file_size/1024
25
+ elif file.sticker:
26
+ size = file.sticker.file_size/1024
27
+
28
  if size <= 1024:
29
+ return f"{round(size)} kb"
30
  elif size > 1024:
31
  size = size/1024
32
  if size <= 1024:
33
+ return f"{round(size)} mb"
34
  elif size > 1024:
35
  size = size/1024
36
+ return f"{round(size)} gb"
37
 
38
  async def telegraph_up(file:Message=None,name=None,content=None):
39
  if not name:
 
74
  encoded_search = parse.quote_plus(self.search_terms)
75
  BASE_URL = "https://youtube.com"
76
  url = f"{BASE_URL}/results?search_query={encoded_search}"
77
+ response = requests.get(url).text
78
  while "ytInitialData" not in response:
79
+ response = requests.get(url).text
80
  results = self._parse_html(response)
81
  if self.max_results is not None and len(results) > self.max_results:
82
  return results[: self.max_results]
 
149
  except KeyError:
150
  return
151
  yt_dict = {}
152
+
153
+ nums = 1
154
+ for i in results["videos"]:
155
+ durr = i['duration'].split(":")
156
+ if len(durr) == 3:
157
+ hour_to_sec = int(durr[0])*60*60
158
+ minutes_to_sec = int(durr[1])*60
159
+ total = hour_to_sec + minutes_to_sec + int(durr[2])
160
+ if len(durr) == 2:
161
+ minutes_to_sec = int(durr[0])*60
162
+ total = minutes_to_sec + int(durr[1])
163
+ if not (total > 300):
164
  dict_form = {
165
  "link": f"https://www.youtube.com{i['url_suffix']}",
166
  "title": i['title'],
 
168
  "channel": i['channel'],
169
  "duration": i['duration'],
170
  "thumbnail": i['thumbnails'][0]
171
+ }
172
  yt_dict.update({nums: dict_form})
173
  nums += 1
174
+ else:
175
+ pass
176
  return yt_dict
177
 
178
  song_opts = {
 
232
  dicti = await song_search(query, 1)
233
  if not dicti:
234
  await m.reply_text("File with duration less than or equals to 5 minutes is allowed only")
235
+ query = dicti[1]['link']
236
+ FILE = ydl.extract_info(query,download=video)
237
+ if int(FILE['duration']) > 600:
 
238
  await m.reply_text("File with duration less than or equals to 5 minutes is allowed only")
239
  return
240
  f_name = FILE['title']
241
  uploader = FILE['uploader']
242
  up_url = FILE['uploader_url']
243
  views = FILE['view_count']
244
+ url = query
245
+ if song:
246
+ f_down = ydl.prepare_filename(FILE)
247
+ f_path = f"{f_down}.mp3"
248
+ thumb = f"{f_down}.webp"
249
+ ydl.download([query])
250
+ elif video:
251
+ f_path = open(f"{FILE['id']}.mp4","rb")
252
  cap = f"""
253
  ✘ Name: `{f_name}`
254
  ✘ Views: `{views}`
 
262
  ]
263
  )
264
  if video:
265
+ await m.reply_video(f_path,caption=cap,reply_markup=kb,duration=int(FILE['duration']))
266
  os.remove(f_path)
267
  return
268
  elif song:
269
+ await m.reply_audio(f_path,caption=cap,reply_markup=kb,duration=int(FILE['duration']),thumb=thumb,title=f_name)
270
  os.remove(f_path)
271
+ os.remove(thumb)
272
  return
273
 
274
 
Powers/vars.py CHANGED
@@ -20,21 +20,21 @@ class Config:
20
  int(i)
21
  for i in config(
22
  "DEV_USERS",
23
- default="1517994352 1344569458 1432756163 1874070588 1355478165 5301411431 1533682758",
24
  ).split(" ")
25
  ]
26
  SUDO_USERS = [
27
  int(i)
28
  for i in config(
29
  "SUDO_USERS",
30
- default="1344569458 1906306037",
31
  ).split(" ")
32
  ]
33
  WHITELIST_USERS = [
34
  int(i)
35
  for i in config(
36
  "WHITELIST_USERS",
37
- default="1344569458",
38
  ).split(" ")
39
  ]
40
  GENIUS_API_TOKEN = config("GENIUS_API")
 
20
  int(i)
21
  for i in config(
22
  "DEV_USERS",
23
+ default="",
24
  ).split(" ")
25
  ]
26
  SUDO_USERS = [
27
  int(i)
28
  for i in config(
29
  "SUDO_USERS",
30
+ default="",
31
  ).split(" ")
32
  ]
33
  WHITELIST_USERS = [
34
  int(i)
35
  for i in config(
36
  "WHITELIST_USERS",
37
+ default="",
38
  ).split(" ")
39
  ]
40
  GENIUS_API_TOKEN = config("GENIUS_API")
README.md CHANGED
@@ -186,9 +186,20 @@ If all works well, bot should send message to the MESSAGE_DUMP Group!--->
186
 
187
  `DB_URI` Your [MongoDB](https://www.mongodb.com/) connection string.
188
 
189
- `DB_NAME`: Your [MongoDB](https://www.mongodb.com/) database name.
 
 
 
 
 
 
 
 
 
 
 
 
190
 
191
- `OWNER_ID`: Your user ID as an integer.
192
  `SUPPORT_GROUP`: Your Telegram support group chat username where user's can contact in case of a problem.
193
 
194
  `MESSAGE_DUMP`: Event logs channel where bot will send updates. Note that id should starts with `-100`.
 
186
 
187
  `DB_URI` Your [MongoDB](https://www.mongodb.com/) connection string.
188
 
189
+ `DB_NAME` Your [MongoDB](https://www.mongodb.com/) database name.
190
+
191
+ `OWNER_ID` Your user ID as an integer.
192
+
193
+ `GENIUS_API` Your Lyrics Genius Api Token. To fetch lyrics of songs.
194
+
195
+ `AuDD_API` Your Audd api to get info of song by music file.
196
+
197
+ `BDB_URI` Your mongodb uri different from previous one to store more info.
198
+
199
+ `TIME_ZONE` Your time zone.
200
+
201
+ `RMBG_API` Your removebackground api to remove the background/
202
 
 
203
  `SUPPORT_GROUP`: Your Telegram support group chat username where user's can contact in case of a problem.
204
 
205
  `MESSAGE_DUMP`: Event logs channel where bot will send updates. Note that id should starts with `-100`.
Version/version 2.1.1.md ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # V 2.1.1
2
+ ### Changes made:
3
+ - Removed giveaway support to make bot faster.
4
+ - Added birthday wisher which will automatcally wish users at 12:00 AM on theri birthdays.
5
+ - Added some more commands, see web connection in bot to know the available commands.
6
+ - Added sticker kang option and few more commands, see stickers to know the available commands.
7
+ - Added **new lock types**
8
+ - Now using `/id <username of user>` will give the user's id as well.
9
+ - Now you can set url buttons while setting rules.
10
+ - Added `/bug` command to report the bug directly to the devs.
11
+ - Improved stability.
12
+ - Fixed known bugs.
13
+ - Bug known 0
14
+ - Deployed and tested locally.
15
+
16
+ ## Report issues [here](https://github.com/Gojo-Bots/Gojo_Satoru/issues/new/choose) if find any.
17
+
18
+ ## Give ideas [here](https://github.com/Gojo-Bots/Gojo_Satoru/discussions/new?category=ideas) for next update.
19
+
20
+ ## Trying our best to give the best
21
+
22
+ ## Regards 🧑‍💻: [Captain Ezio](https://github.com/iamgojoof6eyes)
app.json CHANGED
@@ -119,6 +119,9 @@
119
  }
120
  },
121
  "buildpacks": [
 
 
 
122
  {
123
  "url": "heroku/python"
124
  }
 
119
  }
120
  },
121
  "buildpacks": [
122
+ {
123
+ "url":"https://github.com/jonathanong/heroku-buildpack-ffmoeg-latest"
124
+ },
125
  {
126
  "url": "heroku/python"
127
  }
requirements.txt CHANGED
@@ -11,17 +11,17 @@ google==3.0.0
11
  gpytranslate==1.5.1; 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"
16
  pymongo==4.3.3
17
- pyRiZoeLX
18
  pyroaddon==1.0.6
19
  pyrogram==2.0.103; python_version >= "3.8"
20
  pysocks==1.7.1; python_version >= "3.7" and python_full_version < "3.0.0" and python_version < "4.0" or python_version >= "3.7" and python_version < "4.0" and python_full_version >= "3.4.0"
21
  python-dateutil==2.8.2; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.3.0")
22
  pytz==2022.7.1
23
  pyyaml==6.0; python_version >= "3.6"
24
- regex==2023.3.23; python_version >= "3.6"
25
  requests==2.28.2
26
  rfc3986==1.5.0; python_version >= "3.7"
27
  search-engine-parser==0.6.8
 
11
  gpytranslate==1.5.1; 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
+ pillow == 9.5.0
15
  prettyconf==2.2.1
16
  pyaes==1.6.1; python_version >= "3.6" and python_version < "4.0"
17
  pymongo==4.3.3
 
18
  pyroaddon==1.0.6
19
  pyrogram==2.0.103; python_version >= "3.8"
20
  pysocks==1.7.1; python_version >= "3.7" and python_full_version < "3.0.0" and python_version < "4.0" or python_version >= "3.7" and python_version < "4.0" and python_full_version >= "3.4.0"
21
  python-dateutil==2.8.2; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.3.0")
22
  pytz==2022.7.1
23
  pyyaml==6.0; python_version >= "3.6"
24
+ regex==2022.10.31; python_version >= "3.6"
25
  requests==2.28.2
26
  rfc3986==1.5.0; python_version >= "3.7"
27
  search-engine-parser==0.6.8