Captain Ezio commited on
Commit
fc19cc9
·
1 Parent(s): 5864280

Finally done

Browse files
Powers/__init__.py CHANGED
@@ -14,8 +14,6 @@ import lyricsgenius
14
  import pyrogram
15
  import pytz
16
 
17
- from Powers.database.support_db import SUPPORTS
18
-
19
  LOG_DATETIME = datetime.now().strftime("%d_%m_%Y-%H_%M_%S")
20
  LOGDIR = f"{__name__}/logs"
21
 
@@ -79,7 +77,6 @@ LOGGER.info(f"Owner: {str(Config.OWNER_ID)}")
79
  LOGGER.info(f"Time zone set to {Config.TIME_ZONE}")
80
  LOGGER.info("Source Code: https://github.com/Gojo-Bots/Gojo_Satoru\n")
81
  LOGGER.info("Checking lyrics genius api...")
82
- LOGGER.info("Initialising telegraph client")
83
 
84
  # API based clients
85
  if Config.GENIUS_API_TOKEN:
@@ -135,39 +132,6 @@ Defult_dev = set(defult_dev)
135
  DEVS = DEVS_USER | Defult_dev
136
  DEV_USERS = list(DEVS)
137
 
138
- async def load_support_users():
139
- support = SUPPORTS()
140
- for i in DEV_USERS:
141
- support.insert_support_user(int(i),"dev")
142
- for i in SUDO_USERS:
143
- support.insert_support_user(int(i),"sudo")
144
- for i in WHITELIST_USERS:
145
- support.insert_support_user(int(i),"whitelist")
146
- return
147
-
148
- def get_support_staff(want = "all"):
149
- """
150
- dev, sudo, whitelist, dev_level, sudo_level, all
151
- """
152
- support = SUPPORTS()
153
- devs = support.get_particular_support("dev")
154
- sudo = support.get_particular_support("sudo")
155
- whitelist = support.get_particular_support("whitelist")
156
-
157
- if want == "dev":
158
- return devs
159
- elif want == "sudo":
160
- return sudo
161
- elif want == "whitelist":
162
- return whitelist
163
- elif want == "dev_level":
164
- return devs
165
- elif want == "sudo_level":
166
- return sudo + devs
167
- else:
168
- return list(set([int(OWNER_ID)] + devs + sudo + whitelist))
169
-
170
-
171
  # Plugins, DB and Workers
172
  DB_URI = Config.DB_URI
173
  DB_NAME = Config.DB_NAME
@@ -176,10 +140,14 @@ WORKERS = Config.WORKERS
176
  BDB_URI = Config.BDB_URI
177
 
178
  # Prefixes
 
179
 
180
  HELP_COMMANDS = {} # For help menu
181
  UPTIME = time() # Check bot uptime
182
 
 
 
 
183
 
184
  async def load_cmds(all_plugins):
185
  """Loads all the plugins in bot."""
 
14
  import pyrogram
15
  import pytz
16
 
 
 
17
  LOG_DATETIME = datetime.now().strftime("%d_%m_%Y-%H_%M_%S")
18
  LOGDIR = f"{__name__}/logs"
19
 
 
77
  LOGGER.info(f"Time zone set to {Config.TIME_ZONE}")
78
  LOGGER.info("Source Code: https://github.com/Gojo-Bots/Gojo_Satoru\n")
79
  LOGGER.info("Checking lyrics genius api...")
 
80
 
81
  # API based clients
82
  if Config.GENIUS_API_TOKEN:
 
132
  DEVS = DEVS_USER | Defult_dev
133
  DEV_USERS = list(DEVS)
134
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  # Plugins, DB and Workers
136
  DB_URI = Config.DB_URI
137
  DB_NAME = Config.DB_NAME
 
140
  BDB_URI = Config.BDB_URI
141
 
142
  # Prefixes
143
+ PREFIX_HANDLER = Config.PREFIX_HANDLER
144
 
145
  HELP_COMMANDS = {} # For help menu
146
  UPTIME = time() # Check bot uptime
147
 
148
+ from apscheduler.schedulers.asyncio import AsyncIOScheduler
149
+
150
+ scheduler = AsyncIOScheduler(timezone=TIME_ZONE)
151
 
152
  async def load_cmds(all_plugins):
153
  """Loads all the plugins in bot."""
Powers/__main__.py CHANGED
@@ -5,3 +5,4 @@ if __name__ == "__main__":
5
  # uvloop.install() # Comment it out if using on windows
6
  Gojo().run()
7
 
 
 
5
  # uvloop.install() # Comment it out if using on windows
6
  Gojo().run()
7
 
8
+
Powers/bot_class.py CHANGED
@@ -2,22 +2,19 @@ from platform import python_version
2
  from threading import RLock
3
  from time import gmtime, strftime, time
4
 
5
- from apscheduler.schedulers.asyncio import AsyncIOScheduler
6
  from pyrogram import Client, __version__
7
  from pyrogram.raw.all import layer
8
  from pyrogram.types import BotCommand
9
 
10
  from Powers import (API_HASH, API_ID, BDB_URI, BOT_TOKEN, LOG_DATETIME,
11
- LOGFILE, LOGGER, MESSAGE_DUMP, NO_LOAD, OWNER_ID,
12
- TIME_ZONE, UPTIME, WORKERS, load_cmds, load_support_users)
13
  from Powers.database import MongoDB
14
  from Powers.plugins import all_plugins
15
- from Powers.plugins.birthday import send_wishish
16
- from Powers.plugins.clean_db import clean_my_db
17
  from Powers.vars import Config
18
 
19
- scheduler = AsyncIOScheduler(timezone=TIME_ZONE)
20
-
21
  INITIAL_LOCK = RLock()
22
 
23
  # Check if MESSAGE_DUMP is correct
@@ -59,10 +56,6 @@ class Gojo(Client):
59
  Config.BOT_ID = meh.id
60
  Config.BOT_NAME = meh.first_name
61
  Config.BOT_USERNAME = meh.username
62
- scheduler.add_job(clean_my_db,'cron',[self],hour=3,minute=0,second=0)
63
- if BDB_URI:
64
- scheduler.add_job(send_wishish,'cron',[self],hour=0,minute=0,second=0)
65
- scheduler.start()
66
  startmsg = await self.send_message(MESSAGE_DUMP, "<i>Starting Bot...</i>")
67
 
68
  # Show in Log that bot has started
@@ -75,7 +68,10 @@ class Gojo(Client):
75
  cmd_list = await load_cmds(await all_plugins())
76
  await load_support_users()
77
  LOGGER.info(f"Plugins Loaded: {cmd_list}")
78
-
 
 
 
79
  # Send a message to MESSAGE_DUMP telling that the
80
  # bot has started and has loaded all plugins!
81
  await startmsg.edit_text(
 
2
  from threading import RLock
3
  from time import gmtime, strftime, time
4
 
 
5
  from pyrogram import Client, __version__
6
  from pyrogram.raw.all import layer
7
  from pyrogram.types import BotCommand
8
 
9
  from Powers import (API_HASH, API_ID, BDB_URI, BOT_TOKEN, LOG_DATETIME,
10
+ LOGFILE, LOGGER, MESSAGE_DUMP, NO_LOAD, OWNER_ID, UPTIME,
11
+ WORKERS, load_cmds, scheduler)
12
  from Powers.database import MongoDB
13
  from Powers.plugins import all_plugins
14
+ from Powers.plugins.scheduled_jobs import *
15
+ from Powers.supports import *
16
  from Powers.vars import Config
17
 
 
 
18
  INITIAL_LOCK = RLock()
19
 
20
  # Check if MESSAGE_DUMP is correct
 
56
  Config.BOT_ID = meh.id
57
  Config.BOT_NAME = meh.first_name
58
  Config.BOT_USERNAME = meh.username
 
 
 
 
59
  startmsg = await self.send_message(MESSAGE_DUMP, "<i>Starting Bot...</i>")
60
 
61
  # Show in Log that bot has started
 
68
  cmd_list = await load_cmds(await all_plugins())
69
  await load_support_users()
70
  LOGGER.info(f"Plugins Loaded: {cmd_list}")
71
+ scheduler.add_job(clean_my_db,'cron',[self],hour=3,minute=0,second=0)
72
+ if BDB_URI:
73
+ scheduler.add_job(send_wishish,'cron',[self],hour=0,minute=0,second=0)
74
+ scheduler.start()
75
  # Send a message to MESSAGE_DUMP telling that the
76
  # bot has started and has loaded all plugins!
77
  await startmsg.edit_text(
Powers/database/afk_db.py CHANGED
@@ -13,16 +13,15 @@ class AFK(MongoDB):
13
  def __init__(self) -> None:
14
  super().__init__(self.db_name)
15
 
16
- def insert_afk(self, chat_id, user_id, time, reason, media_type,media=0):
17
  with INSERTION_LOCK:
18
  curr = self.check_afk(chat_id=chat_id, user_id=user_id)
19
  if curr:
20
  if reason:
21
- self.update({"chat_id":chat_id,"user_id":user_id},{"reason":reason})
22
- self.update({"chat_id":chat_id,"user_id":user_id},{"time":time})
23
  if media:
24
- self.update({"chat_id":chat_id,"user_id":user_id},{'media':media,'media_type':media_type})
25
- return
26
  else:
27
  self.insert_one(
28
  {
@@ -34,7 +33,7 @@ class AFK(MongoDB):
34
  "media_type":media_type
35
  }
36
  )
37
- return
38
 
39
  def check_afk(self, chat_id, user_id):
40
  curr = self.find_one({"chat_id":chat_id,"user_id":user_id})
 
13
  def __init__(self) -> None:
14
  super().__init__(self.db_name)
15
 
16
+ def insert_afk(self, chat_id, user_id, time, reason, media_type,media=None):
17
  with INSERTION_LOCK:
18
  curr = self.check_afk(chat_id=chat_id, user_id=user_id)
19
  if curr:
20
  if reason:
21
+ self.update({"chat_id":chat_id,"user_id":user_id},{"reason":reason,"time":time})
 
22
  if media:
23
+ self.update({"chat_id":chat_id,"user_id":user_id},{'media':media,'media_type':media_type,"time":time})
24
+ return True
25
  else:
26
  self.insert_one(
27
  {
 
33
  "media_type":media_type
34
  }
35
  )
36
+ return True
37
 
38
  def check_afk(self, chat_id, user_id):
39
  curr = self.find_one({"chat_id":chat_id,"user_id":user_id})
Powers/database/autojoin_db.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from threading import RLock
2
+ from time import time
3
+
4
+ from Powers import LOGGER
5
+ from Powers.database import MongoDB
6
+
7
+ INSERTION_LOCK = RLock()
8
+
9
+
10
+ class AUTOJOIN(MongoDB):
11
+ """class to store auto join requests"""
12
+
13
+ db_name = "autojoin"
14
+
15
+ def __init__(self) -> None:
16
+ super().__init__(self.db_name)
17
+
18
+ def load_autojoin(self, chat,mode="auto"):
19
+ """
20
+ type = auto or notify
21
+ auto to auto accept join requests
22
+ notify to notify the admins about the join requests
23
+ """
24
+ curr = self.find_one({"chat_id":chat,})
25
+ if not curr:
26
+ with INSERTION_LOCK:
27
+ self.insert_one({"chat_id":chat,"type":mode})
28
+ return True
29
+ return False
30
+
31
+ def get_autojoin(self,chat):
32
+ curr = self.find_one({"chat_id":chat})
33
+ if not curr:
34
+ return False
35
+ else:
36
+ return curr["type"]
37
+
38
+ def update_join_type(self,chat,mode):
39
+ curr = self.find_one({"chat_id":chat})
40
+ if curr:
41
+ self.update({"chat_id":chat},{"type":mode})
42
+ return
43
+ else:
44
+ return
45
+
46
+ def remove_autojoin(self,chat):
47
+ curr = self.find_one({"chat_id":chat})
48
+ if curr:
49
+ self.delete_one({"chat_id":chat})
50
+ return
Powers/database/locks_db.py CHANGED
@@ -11,4 +11,74 @@ class LOCKS(MongoDB):
11
  db_name = "locks"
12
 
13
  def __init__(self) -> None:
14
- super().__init__(self.db_name)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  db_name = "locks"
12
 
13
  def __init__(self) -> None:
14
+ super().__init__(self.db_name)
15
+
16
+ def insert_lock_channel(self, chat: int, locktype: str):
17
+ """
18
+ locktypes: anti_c_send, anti_fwd, anti_fwd_u, anti_fwd_c, anti_links
19
+ """
20
+ curr = self.find_one({"chat_id":chat,"locktype":locktype})
21
+ if curr:
22
+ return False
23
+ else:
24
+ with INSERTION_LOCK:
25
+ hmm = self.merge_u_and_c(chat,locktype)
26
+ if not hmm:
27
+ self.insert_one({"chat_id":chat,"locktype":locktype})
28
+ return True
29
+
30
+ def remove_lock_channel(self, chat: int, locktype: str):
31
+ """
32
+ locktypes: anti_c_send, anti_fwd, anti_fwd_u, anti_fwd_c, anti_links
33
+ """
34
+ curr = self.find_one({"chat_id":chat,"locktype":locktype})
35
+ if curr:
36
+ with INSERTION_LOCK:
37
+ self.delete_one({"chat_id":chat,"locktype":locktype})
38
+ return True
39
+ else:
40
+ return False
41
+
42
+ def get_lock_channel(self, locktype: str="all"):
43
+ """
44
+ locktypes: anti_c_send, anti_fwd, anti_fwd_u, anti_fwd_c, anti_links
45
+ """
46
+ if locktype not in ["anti_c_send","anti_fwd","anti_fwd_u","anti_fwd_c","anti_links", "all"]:
47
+ return False
48
+ else:
49
+ if locktype == "all":
50
+ find = {}
51
+ else:
52
+ find = {"locktype":locktype}
53
+ curr = self.find_all(find)
54
+ if not curr:
55
+ list_ = []
56
+ else:
57
+ list_ = [i["chat_id"] for i in curr]
58
+ return list_
59
+
60
+ def merge_u_and_c(self, chat: int, locktype: str):
61
+ if locktype == "anti_fwd_u":
62
+ curr = self.find_one({"chat_id":chat,"locktype":"anti_fwd_c"})
63
+ elif locktype == "anti_fwd_c":
64
+ curr = self.find_one({"chat_id":chat,"locktype":"anti_fwd_u"})
65
+ else:
66
+ return False
67
+
68
+ if curr:
69
+ self.delete_one({"chat_id":chat,"locktype":locktype})
70
+ self.insert_one({"chat_id":chat,"locktype":"anti_fwd"})
71
+ return True
72
+ else:
73
+ return False
74
+
75
+ def is_particular_lock(self, chat: int, locktype: str):
76
+ """
77
+ locktypes: anti_c_send, anti_fwd, anti_fwd_u, anti_fwd_c, anti_links
78
+ """
79
+ curr = self.find_one({"chat_id":chat,"locktype":locktype})
80
+ if curr:
81
+ return True
82
+ else:
83
+ return False
84
+
Powers/database/support_db.py CHANGED
@@ -59,7 +59,7 @@ class SUPPORTS(MongoDB):
59
  def get_particular_support(self,support_type):
60
  curr = self.find_all({"support_type":support_type})
61
  if curr:
62
- return curr
63
  else:
64
  return []
65
 
 
59
  def get_particular_support(self,support_type):
60
  curr = self.find_all({"support_type":support_type})
61
  if curr:
62
+ return [i['user_id'] for i in curr]
63
  else:
64
  return []
65
 
Powers/plugins/admin.py CHANGED
@@ -11,10 +11,11 @@ from pyrogram.errors import (ChatAdminInviteRequired, ChatAdminRequired,
11
  UserAdminInvalid)
12
  from pyrogram.types import ChatPrivileges, Message
13
 
14
- from Powers import LOGGER, OWNER_ID, get_support_staff
15
  from Powers.bot_class import Gojo
16
  from Powers.database.approve_db import Approve
17
  from Powers.database.reporting_db import Reporting
 
18
  from Powers.utils.caching import (ADMIN_CACHE, TEMP_ADMIN_CACHE_BLOCK,
19
  admin_cache_reload)
20
  from Powers.utils.custom_filters import (admin_filter, command, owner_filter,
 
11
  UserAdminInvalid)
12
  from pyrogram.types import ChatPrivileges, Message
13
 
14
+ from Powers import LOGGER, OWNER_ID
15
  from Powers.bot_class import Gojo
16
  from Powers.database.approve_db import Approve
17
  from Powers.database.reporting_db import Reporting
18
+ from Powers.supports import get_support_staff
19
  from Powers.utils.caching import (ADMIN_CACHE, TEMP_ADMIN_CACHE_BLOCK,
20
  admin_cache_reload)
21
  from Powers.utils.custom_filters import (admin_filter, command, owner_filter,
Powers/plugins/afk.py CHANGED
@@ -5,21 +5,17 @@ from pyrogram import filters
5
  from pyrogram.enums import ParseMode as PM
6
  from pyrogram.types import Message
7
 
8
- # from Powers import LOGGER
9
  from Powers.bot_class import Gojo
10
  from Powers.database.afk_db import AFK
11
  from Powers.plugins import till_date
12
  from Powers.utils.cmd_senders import send_cmd
13
  from Powers.utils.custom_filters import command
14
- from Powers.utils.msg_types import Types, get_wlcm_type
15
  from Powers.vars import Config
16
 
17
  # from traceback import format_exc
18
 
19
-
20
-
21
- cmds = Config.PREFIX_HANDLER
22
-
23
  res = [
24
  "{first} is resting for a while...",
25
  "{first} living his real life, go and live yours.",
@@ -42,36 +38,39 @@ async def going_afk(c: Gojo, m: Message):
42
  user = m.from_user.id
43
  chat = m.chat.id
44
  afk = AFK()
45
- text, data_type, content = await get_wlcm_type(m)
46
-
47
  time = str(datetime.now()).rsplit(".",1)[0]
48
 
49
- if not text and not data_type:
50
  text = choice(res)
51
- data_type = Types.TEXT
52
 
53
- elif data_type and not text:
54
- text = choice(res)
 
 
 
55
 
56
  afk.insert_afk(chat,user,str(time),text,data_type,content)
57
 
58
  await m.reply_text(f"{m.from_user.mention} is now AFK")
 
59
  return
60
 
61
  async def get_hours(hour:str):
62
  tim = hour.strip().split(":")
63
-
64
  if int(tim[0]):
65
- hour = tim[0] + "hours"
66
  if int(tim[1]):
67
- minute = tim[1] + " minutes"
68
- if int(tim[2]):
69
- second = tim[2] + " seconds"
70
 
71
- return hour + minute + second
72
 
73
 
74
- @Gojo.on_message(filters.group,group=18)
75
  async def afk_checker(c: Gojo, m: Message):
76
  if not m.from_user:
77
  return
@@ -88,29 +87,35 @@ async def afk_checker(c: Gojo, m: Message):
88
  rep_user = False
89
 
90
  is_afk = afk.check_afk(chat,user)
91
-
92
  if rep_user:
93
  is_rep_afk = afk.check_afk(chat,rep_user)
94
 
95
- if is_rep_afk:
96
  con = afk.get_afk(chat,rep_user)
97
- reason = con["reason"].format(repl.from_user.first_name)
98
  time = till_date(con["time"])
99
  media = con["media"]
100
  media_type = con["media_type"]
101
  tim_ = datetime.now() - time
102
  tim_ = str(tim_).split(",")
103
  tim = await get_hours(tim_[-1])
104
-
105
- tims = tim_[0] + " " + tim
106
- txt = reason + f"\nAfk since: {tims}"
 
 
 
 
 
 
 
107
 
108
  if media_type == Types.TEXT:
109
  await (await send_cmd(c,media_type))(
110
  chat,
111
  txt,
112
  parse_mode=PM.MARKDOWN,
113
- reply_to_message_id=repl.id,
114
  )
115
  else:
116
  await (await send_cmd(c,media_type))(
@@ -122,12 +127,13 @@ async def afk_checker(c: Gojo, m: Message):
122
  )
123
 
124
  if is_afk:
125
- txt = m.text
 
 
 
 
126
 
127
- for cmd in cmds:
128
- txt = txt.strip(cmd)
129
-
130
- if txt in ["afk","brb"]:
131
  return
132
  else:
133
  con = afk.get_afk(chat,user)
@@ -135,8 +141,12 @@ async def afk_checker(c: Gojo, m: Message):
135
  tim_ = datetime.now() - time
136
  tim_ = str(tim_).split(",")
137
  tim = await get_hours(tim_[-1])
138
- tims = tim_[0] + " " + tim
139
- txt = back_.fromat(m.from_user.mention) + f"\nAfk for: {tims}"
 
 
 
 
140
  afk.delete_afk(chat,user)
141
  return
142
 
 
5
  from pyrogram.enums import ParseMode as PM
6
  from pyrogram.types import Message
7
 
8
+ from Powers import LOGGER, PREFIX_HANDLER
9
  from Powers.bot_class import Gojo
10
  from Powers.database.afk_db import AFK
11
  from Powers.plugins import till_date
12
  from Powers.utils.cmd_senders import send_cmd
13
  from Powers.utils.custom_filters import command
14
+ from Powers.utils.msg_types import Types, get_afk_type
15
  from Powers.vars import Config
16
 
17
  # from traceback import format_exc
18
 
 
 
 
 
19
  res = [
20
  "{first} is resting for a while...",
21
  "{first} living his real life, go and live yours.",
 
38
  user = m.from_user.id
39
  chat = m.chat.id
40
  afk = AFK()
41
+ text, data_type, content = await get_afk_type(m)
42
+
43
  time = str(datetime.now()).rsplit(".",1)[0]
44
 
45
+ if len(m.command) == 1:
46
  text = choice(res)
 
47
 
48
+ elif len(m.command) > 1:
49
+ text = m.text.markdown.split(None,1)[1]
50
+
51
+ if not data_type:
52
+ data_type = Types.TEXT
53
 
54
  afk.insert_afk(chat,user,str(time),text,data_type,content)
55
 
56
  await m.reply_text(f"{m.from_user.mention} is now AFK")
57
+
58
  return
59
 
60
  async def get_hours(hour:str):
61
  tim = hour.strip().split(":")
62
+ txt = ""
63
  if int(tim[0]):
64
+ txt += tim[0] + " hours "
65
  if int(tim[1]):
66
+ txt += tim[1] + " minutes "
67
+ if int(round(float(tim[2]))):
68
+ txt += str(round(float(tim[2]))) + " seconds"
69
 
70
+ return txt
71
 
72
 
73
+ @Gojo.on_message(filters.group,group=-18)
74
  async def afk_checker(c: Gojo, m: Message):
75
  if not m.from_user:
76
  return
 
87
  rep_user = False
88
 
89
  is_afk = afk.check_afk(chat,user)
90
+ is_rep_afk = False
91
  if rep_user:
92
  is_rep_afk = afk.check_afk(chat,rep_user)
93
 
94
+ if is_rep_afk and rep_user != user:
95
  con = afk.get_afk(chat,rep_user)
 
96
  time = till_date(con["time"])
97
  media = con["media"]
98
  media_type = con["media_type"]
99
  tim_ = datetime.now() - time
100
  tim_ = str(tim_).split(",")
101
  tim = await get_hours(tim_[-1])
102
+ if len(tim_) == 1:
103
+ tims = tim
104
+ elif len(tim_) == 2:
105
+ tims = tim_[0] + " " + tim
106
+ reason = f"{repl.from_user.first_name} is afk since {tims}\n"
107
+ if con['reason'] not in res:
108
+ reason += f"\nDue to: {con['reason'].format(first=repl.from_user.first_name)}"
109
+ else:
110
+ reason += f"\n{con['reason'].format(first=repl.from_user.first_name)}"
111
+ txt = reason
112
 
113
  if media_type == Types.TEXT:
114
  await (await send_cmd(c,media_type))(
115
  chat,
116
  txt,
117
  parse_mode=PM.MARKDOWN,
118
+ reply_to_message_id=m.id,
119
  )
120
  else:
121
  await (await send_cmd(c,media_type))(
 
127
  )
128
 
129
  if is_afk:
130
+ txt = False
131
+ try:
132
+ txt = m.command[0]
133
+ except Exception:
134
+ pass
135
 
136
+ if txt and txt in ["afk","brb"]:
 
 
 
137
  return
138
  else:
139
  con = afk.get_afk(chat,user)
 
141
  tim_ = datetime.now() - time
142
  tim_ = str(tim_).split(",")
143
  tim = await get_hours(tim_[-1])
144
+ if len(tim_) == 1:
145
+ tims = tim
146
+ elif len(tim_) == 2:
147
+ tims = tim_[0] + " " + tim
148
+ txt = back_.format(first=m.from_user.mention) + f"\n\nAfk for: {tims}"
149
+ await m.reply_text(txt)
150
  afk.delete_afk(chat,user)
151
  return
152
 
Powers/plugins/antispam.py CHANGED
@@ -5,11 +5,11 @@ from traceback import format_exc
5
  from pyrogram.errors import MessageTooLong, PeerIdInvalid, UserIsBlocked
6
  from pyrogram.types import Message
7
 
8
- from Powers import (LOGGER, MESSAGE_DUMP, SUPPORT_GROUP, TIME_ZONE,
9
- get_support_staff)
10
  from Powers.bot_class import Gojo
11
  from Powers.database.antispam_db import GBan
12
  from Powers.database.users_db import Users
 
13
  from Powers.utils.clean_file import remove_markdown_and_html
14
  from Powers.utils.custom_filters import command
15
  from Powers.utils.extract_user import extract_user
 
5
  from pyrogram.errors import MessageTooLong, PeerIdInvalid, UserIsBlocked
6
  from pyrogram.types import Message
7
 
8
+ from Powers import LOGGER, MESSAGE_DUMP, SUPPORT_GROUP, TIME_ZONE
 
9
  from Powers.bot_class import Gojo
10
  from Powers.database.antispam_db import GBan
11
  from Powers.database.users_db import Users
12
+ from Powers.supports import get_support_staff
13
  from Powers.utils.clean_file import remove_markdown_and_html
14
  from Powers.utils.custom_filters import command
15
  from Powers.utils.extract_user import extract_user
Powers/plugins/approve.py CHANGED
@@ -210,12 +210,7 @@ async def unapproveall_callback(_, q: CallbackQuery):
210
  show_alert=True,
211
  )
212
  return
213
- if user_status != "creator":
214
- await q.answer(
215
- "You're just an admin, not owner\nStay in your limits!",
216
- show_alert=True,
217
- )
218
- return
219
  db.unapprove_all()
220
  for i in approved_people:
221
  await q.message.chat.restrict_member(
 
210
  show_alert=True,
211
  )
212
  return
213
+
 
 
 
 
 
214
  db.unapprove_all()
215
  for i in approved_people:
216
  await q.message.chat.restrict_member(
Powers/plugins/auto_join.py ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pyrogram import filters
2
+ from pyrogram.enums import ChatMemberStatus as CMS
3
+ from pyrogram.types import CallbackQuery, ChatJoinRequest
4
+ from pyrogram.types import InlineKeyboardButton as ikb
5
+ from pyrogram.types import InlineKeyboardMarkup as ikm
6
+ from pyrogram.types import Message
7
+
8
+ from Powers.bot_class import Gojo
9
+ from Powers.database.autojoin_db import AUTOJOIN
10
+ from Powers.supports import get_support_staff
11
+ from Powers.utils.custom_filters import admin_filter, command
12
+
13
+ SUPPORT_STAFF = get_support_staff()
14
+
15
+ @Gojo.on_message(command(["joinreq"]) & admin_filter)
16
+ async def accept_join_requests(c: Gojo, m: Message):
17
+ if m.chat.id == m.from_user.id:
18
+ await m.reply_text("Use it in groups")
19
+ return
20
+
21
+ split = m.command
22
+ a_j = AUTOJOIN()
23
+
24
+ if len(split) == 1:
25
+ txt = "**USAGE**\n/joinreq [on | off]"
26
+ await m.reply_text(txt)
27
+ return
28
+ else:
29
+ yes_no = split[1].lower()
30
+ if yes_no not in ["on","off"]:
31
+ txt = "**USAGE**\n/joinreq [on | off]"
32
+ await m.reply_text(txt)
33
+ return
34
+
35
+ else:
36
+ if yes_no == "on":
37
+ is_al = a_j.load_autojoin(m.chat.id)
38
+
39
+ if is_al:
40
+ txt = "Now I will approve all the join request of the chat\nIf you want that I will just notify admins about the join request use command\n//joinreqmode [manual | auto]"
41
+ await m.reply_text(txt)
42
+ return
43
+ else:
44
+ txt = "Auto approve join request is already on for this chat\nIf you want that I will just notify admins about the join request use command\n/joinreqmode [manual | auto]"
45
+ await m.reply_text(txt)
46
+ return
47
+
48
+ elif yes_no == "off":
49
+ a_j.remove_autojoin(m.chat.id)
50
+ txt = "Now I will neither auto approve join request nor notify any admins about it"
51
+ await m.reply_text(txt)
52
+ return
53
+
54
+ @Gojo.on_message(command("joinreqmode") & admin_filter)
55
+ async def join_request_mode(c: Gojo, m: Message):
56
+ if m.chat.id == m.from_user.id:
57
+ await m.reply_text("Use it in groups")
58
+ return
59
+ u_text = "**USAGE**\n/joinreqmode [auto | manual]\nauto: auto approve joins\nmanual: will notify admin about the join request"
60
+
61
+ split = m.command
62
+ a_j = AUTOJOIN()
63
+
64
+ if len(split) == 1:
65
+ await m.reply_text(u_text)
66
+ return
67
+
68
+ else:
69
+ auto_manual = split[1]
70
+ if auto_manual not in ["auto","manual"]:
71
+ await m.reply_text(u_text)
72
+ return
73
+ else:
74
+ a_j.update_join_type(m.chat.id,auto_manual)
75
+ txt = "Changed join request type"
76
+ await m.reply_text(txt)
77
+ return
78
+
79
+
80
+ @Gojo.on_chat_join_request(filters.group)
81
+ async def join_request_handler(c: Gojo, j: ChatJoinRequest):
82
+ chat = j.chat.id
83
+ aj = AUTOJOIN()
84
+ join_type = aj.get_autojoin(chat)
85
+
86
+ if not join_type:
87
+ return
88
+
89
+ user = j.from_user.id
90
+ userr = j.from_user
91
+ if join_type == "auto" or user in SUPPORT_STAFF:
92
+ await c.approve_chat_join_request(chat,user)
93
+
94
+ elif join_type == "manual":
95
+ txt = "New join request is available\n**USER's INFO**\n"
96
+ txt += f"Name: {userr.first_name} {userr.last_name if userr.last_name else ''}"
97
+ txt += f"Mention: {userr.mention}"
98
+ txt += f"Id: {user}"
99
+ txt += f"Scam: {'True' if userr.is_scam else 'False'}"
100
+ if userr.username:
101
+ txt+= f"Username: @{userr.username}"
102
+ kb = [
103
+ [
104
+ ikb("Accept",f"accept_joinreq_uest_{user}"),
105
+ ikb("Decline",f"decline_joinreq_uest_{user}")
106
+ ]
107
+ ]
108
+ await c.send_message(chat,txt,reply_markup=ikm(kb))
109
+ return
110
+
111
+ @Gojo.on_callback_query(filters.regex("^accept_joinreq_uest_") | filters.regex("^decline_joinreq_uest_"))
112
+ async def accept_decline_request(c:Gojo, q: CallbackQuery):
113
+ user_id = q.from_user.id
114
+ user_status = (await q.message.chat.get_member(user_id)).status
115
+ if user_status not in {CMS.OWNER, CMS.ADMINISTRATOR}:
116
+ await q.answer(
117
+ "You're not even an admin, don't try this explosive shit!",
118
+ show_alert=True,
119
+ )
120
+ return
121
+
122
+ split = q.data.split("_")
123
+ chat = q.message.chat.id
124
+ user = int(split[-1])
125
+ data = split[0]
126
+
127
+ if data == "accept":
128
+ await c.approve_chat_join_request(chat,user)
129
+ await q.answer(f"APPROVED: {user}",True)
130
+ elif data == "decline":
131
+ await c.decline_chat_join_request(chat,user)
132
+ await q.answer(f"DECLINED: {user}")
133
+
134
+ return
135
+
136
+ __PLUGIN__ = "auto join"
137
+
138
+ __alt_name__ = ["join_request"]
139
+
140
+
141
+ __HELP__ = """
142
+ **Auto join request**
143
+
144
+ **Admin commands:**
145
+ • /joinreq [on | off]: To switch on auto accept join request
146
+ • /joinreqmode [auto | manual]: `auto` to accept join request automatically and `manual` to get notified when new join request is available
147
+ """
Powers/plugins/bans.py CHANGED
@@ -9,8 +9,9 @@ from pyrogram.types import (CallbackQuery, ChatPrivileges,
9
  InlineKeyboardButton, InlineKeyboardMarkup,
10
  Message)
11
 
12
- from Powers import LOGGER, MESSAGE_DUMP, OWNER_ID, get_support_staff
13
  from Powers.bot_class import Gojo
 
14
  from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
15
  from Powers.utils.custom_filters import command, restrict_filter
16
  from Powers.utils.extract_user import extract_user
@@ -648,7 +649,7 @@ async def unban_usr(c: Gojo, m: Message):
648
  await m.chat.unban_member(user_id)
649
  admin = m.from_user.mention
650
  unbanned = await mention_html(user_first_name, user_id)
651
- chat_title = (m.chat.title,)
652
  txt = f"{admin} unbanned {unbanned} in chat <b>{chat_title}</b>!"
653
  if reason:
654
  txt += f"\n<b>Reason</b>: {reason}"
 
9
  InlineKeyboardButton, InlineKeyboardMarkup,
10
  Message)
11
 
12
+ from Powers import LOGGER, MESSAGE_DUMP, OWNER_ID
13
  from Powers.bot_class import Gojo
14
+ from Powers.supports import get_support_staff
15
  from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
16
  from Powers.utils.custom_filters import command, restrict_filter
17
  from Powers.utils.extract_user import extract_user
 
649
  await m.chat.unban_member(user_id)
650
  admin = m.from_user.mention
651
  unbanned = await mention_html(user_first_name, user_id)
652
+ chat_title = m.chat.title
653
  txt = f"{admin} unbanned {unbanned} in chat <b>{chat_title}</b>!"
654
  if reason:
655
  txt += f"\n<b>Reason</b>: {reason}"
Powers/plugins/birthday.py CHANGED
@@ -1,8 +1,6 @@
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
7
  from pyrogram.enums import ChatMemberStatus, ChatType
8
  from pyrogram.types import CallbackQuery
@@ -18,7 +16,6 @@ if BDB_URI:
18
  from Powers.plugins import bday_cinfo, bday_info
19
 
20
  from Powers.utils.custom_filters import command
21
- from Powers.utils.extras import birthday_wish
22
 
23
 
24
  def give_date(date,form = "%d/%m/%Y"):
@@ -144,7 +141,7 @@ async def who_is_next(c: Gojo, m: Message):
144
  break
145
  if not users:
146
  await xx.delete()
147
- await m.reply_text("No birthdays found :/")
148
  return
149
  txt = "🎊 Upcomming Birthdays Are 🎊\n"
150
  for i in users:
@@ -186,6 +183,7 @@ async def cant_recall_it(c: Gojo, m: Message):
186
  u_dobm = date(curr.year, u_dob.month, u_dob.day)
187
  days_left = (u_dobm - curr).days
188
  txt = f"User's birthday is coming🥳\nDays left : {days_left}"
 
189
  await m.reply_text(txt)
190
  return
191
 
@@ -227,60 +225,7 @@ async def switch_on_off(c:Gojo, q: CallbackQuery):
227
  await q.edit_message_text(f"Done! I will {'wish' if data == 'yes' else 'not wish'}",reply_markup=IKM([[IKB("Close", "f_close")]]))
228
  return
229
 
230
- scheduler = AsyncIOScheduler()
231
- scheduler.timezone = TIME_ZONE
232
- scheduler_time = time(0,0,0)
233
- async def send_wishish(JJK: Gojo):
234
- c_list = Chats.list_chats_by_id()
235
- blist = list(bday_info.find())
236
- curr = datetime.now(TIME_ZONE).date()
237
- cclist = list(bday_cinfo.find())
238
- for i in blist:
239
- dob = give_date(i["dob"])
240
- if dob.month == curr.month and dob.day == curr.day:
241
- for j in c_list:
242
- if cclist and (j in cclist):
243
- return
244
- try:
245
- agee = ""
246
- if i["is_year"]:
247
- agee = curr.year - dob.year
248
- if str(agee).endswith("1"):
249
- agee = f"{agee}st"
250
- elif str(agee).endswith("2"):
251
- agee = f"{agee}nd"
252
- elif str(agee).endswith("3"):
253
- agee = f"{agee}rd"
254
- else:
255
- agee = f"{agee}th"
256
- U = await JJK.get_chat_member(chat_id=j,user_id=i["user_id"])
257
- wish = choice(birthday_wish)
258
- if U.status in [ChatMemberStatus.MEMBER,ChatMemberStatus.ADMINISTRATOR, ChatMemberStatus.OWNER]:
259
- xXx = await JJK.send_message(j,f"Happy {agee} birthday {U.user.mention}🥳\n{wish}")
260
- try:
261
- await xXx.pin()
262
- except Exception:
263
- pass
264
- except Exception:
265
- pass
266
 
267
- """"
268
- from datetime import date, datetime
269
-
270
- #form =
271
- num = "18/05/2005"
272
- st = "18 May 2005"
273
- timm = datetime.strptime(num,"%d/%m/%Y").date()
274
- x = datetime.now().date()
275
- if timm.month < x.month:
276
- next_b = date(x.year + 1, timm.month, timm.day)
277
- days_left = (next_b - x).days
278
- else:
279
- timmm = date(x.year, timm.month, timm.day)
280
- days_left = (timmm - x).days
281
- print(days_left)
282
- print(x.year - timm.year)
283
- """
284
 
285
  __PLUGIN__ = "birthday"
286
 
 
1
+ from datetime import date, datetime
 
2
  from traceback import format_exc
3
 
 
4
  from pyrogram import filters
5
  from pyrogram.enums import ChatMemberStatus, ChatType
6
  from pyrogram.types import CallbackQuery
 
16
  from Powers.plugins import bday_cinfo, bday_info
17
 
18
  from Powers.utils.custom_filters import command
 
19
 
20
 
21
  def give_date(date,form = "%d/%m/%Y"):
 
141
  break
142
  if not users:
143
  await xx.delete()
144
+ await m.reply_text("There are no upcoming birthdays of any user in this chat:/\nEither all the birthdays are passed or no user from this chat have registered their birthday")
145
  return
146
  txt = "🎊 Upcomming Birthdays Are 🎊\n"
147
  for i in users:
 
183
  u_dobm = date(curr.year, u_dob.month, u_dob.day)
184
  days_left = (u_dobm - curr).days
185
  txt = f"User's birthday is coming🥳\nDays left : {days_left}"
186
+ txt += f"\n\nBirthday on: {result['dob']}"
187
  await m.reply_text(txt)
188
  return
189
 
 
225
  await q.edit_message_text(f"Done! I will {'wish' if data == 'yes' else 'not wish'}",reply_markup=IKM([[IKB("Close", "f_close")]]))
226
  return
227
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
228
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
229
 
230
  __PLUGIN__ = "birthday"
231
 
Powers/plugins/botstaff.py CHANGED
@@ -1,8 +1,9 @@
1
  from pyrogram.errors import RPCError
2
  from pyrogram.types import Message
3
 
4
- from Powers import LOGGER, OWNER_ID, WHITELIST_USERS, get_support_staff
5
  from Powers.bot_class import Gojo
 
6
  from Powers.utils.custom_filters import command
7
  from Powers.utils.parser import mention_html
8
 
 
1
  from pyrogram.errors import RPCError
2
  from pyrogram.types import Message
3
 
4
+ from Powers import LOGGER, OWNER_ID, WHITELIST_USERS
5
  from Powers.bot_class import Gojo
6
+ from Powers.supports import get_support_staff
7
  from Powers.utils.custom_filters import command
8
  from Powers.utils.parser import mention_html
9
 
Powers/plugins/captcha.py CHANGED
@@ -1,16 +1,18 @@
1
- import os
2
  from random import shuffle
3
  from traceback import format_exc
4
 
 
5
  from pyrogram import filters
 
6
  from pyrogram.types import CallbackQuery, ChatMemberUpdated, ChatPermissions
7
  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 LOGGER, get_support_staff
12
  from Powers.bot_class import Gojo
13
  from Powers.database.captcha_db import CAPTCHA, CAPTCHA_DATA
 
14
  from Powers.utils.captcha_helper import (genrator, get_image_captcha,
15
  get_qr_captcha)
16
  from Powers.utils.custom_filters import admin_filter, command
@@ -30,7 +32,7 @@ async def start_captcha(c: Gojo, m: Message):
30
  await m.reply_text(txt)
31
  return
32
  else:
33
- on_off = split[1]
34
  if on_off in ["on","yes","enable"]:
35
  captcha.insert_captcha(m.chat.id)
36
  await m.reply_text("Captcha verification is now **on** for this chat")
@@ -70,20 +72,47 @@ async def set_captcha_mode(c: Gojo, m: Message):
70
  await m.reply_text("**USAGE**\n/captchamode [qr | image]")
71
  return
72
 
73
- @Gojo.on_chat_member_updated(filters.group & filters.service,18)
74
- async def joinss(c: Gojo, u: ChatMemberUpdated, m: Message):
75
  chat = u.chat.id
76
- user = u.from_user.id
77
 
78
- is_qr = CAPTCHA().is_captcha()
 
 
 
 
 
 
 
 
 
 
79
  if not is_qr:
80
  return
81
-
82
  captcha = CAPTCHA()
83
  cap_data = CAPTCHA_DATA()
84
 
85
  if user in SUPPORT_STAFF:
86
  return
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  try:
88
  await c.restrict_chat_member(chat,user,ChatPermissions())
89
  except Exception as e:
@@ -91,48 +120,16 @@ async def joinss(c: Gojo, u: ChatMemberUpdated, m: Message):
91
  LOGGER.error(format_exc())
92
  return
93
 
94
- captcha_type = captcha.get_captcha(chat)
95
-
96
- if captcha_type == "qr":
97
- is_already = cap_data.is_already_data(chat, user)
98
-
99
- try:
100
- if is_already:
101
- mess = await c.get_messages(chat,int(is_already))
102
- except Exception:
103
- cap_data.del_message_id(chat,is_already)
104
- is_already = False
105
-
106
- if not is_already:
107
- pic = get_qr_captcha(chat, user)
108
- cap = f"Please {u.from_user.mention} scan this qr code with your phone to verify that you are human"
109
- ms = await m.reply_photo(pic,caption=cap)
110
  cap_data.store_message_id(chat,user,ms.id)
111
  return
112
- else:
113
- kb = ikm(
114
- [
115
- [
116
- ikb("Click here to verify",url=mess.link)
117
- ]
118
- ]
119
- )
120
- await m.reply_text("You verification is already pending",reply_markup=kb)
121
- return
122
-
123
- elif captcha_type == "image":
124
- is_already = cap_data.is_already_data(chat, user)
125
-
126
- try:
127
- if is_already:
128
- mess = await c.get_messages(chat,int(is_already))
129
- except Exception:
130
- cap_data.del_message_id(chat,is_already)
131
- is_already = False
132
-
133
- if not is_already:
134
- img, code = get_image_captcha(chat, user)
135
- cap = f"Please {u.from_user.mention} please choose the correct code from the one given bellow\nYou have three tries if you get all three wrong u will be kicked from the chat.\nTries left: 3"
136
  cap_data.load_cap_data(chat, user, code)
137
  rand = [code]
138
  while len(rand) != 5:
@@ -143,35 +140,40 @@ async def joinss(c: Gojo, u: ChatMemberUpdated, m: Message):
143
 
144
  ini = f"captcha_{chat}_{user}_"
145
 
146
- kb = ikm(
147
- [
148
- ikb(rand[0],ini+rand[0])
149
- ],
150
- [
151
- ikb(rand[1],ini+rand[1])
152
- ],
153
- [
154
- ikb(rand[2],ini+rand[2])
155
- ],
156
- [
157
- ikb(rand[3],ini+rand[3])
158
- ],
159
- [
160
- ikb(rand[4],ini+rand[4])
161
- ]
162
- )
163
- await m.reply_photo(img,caption=cap,reply_markup=kb)
164
- return
165
- else:
166
  kb = ikm(
167
  [
168
  [
169
- ikb("Click here to verify",url=mess.link)
 
 
 
 
 
 
 
 
 
 
 
 
170
  ]
171
  ]
172
  )
173
- await m.reply_text("You verification is already pending",reply_markup=kb)
174
  return
 
 
 
 
 
 
 
 
 
 
 
 
 
175
 
176
  @Gojo.on_callback_query(filters.regex("^captcha_"))
177
  async def captcha_codes_check(c: Gojo, q: CallbackQuery):
@@ -191,23 +193,23 @@ async def captcha_codes_check(c: Gojo, q: CallbackQuery):
191
  if code_ == code:
192
  cap = "You guessed the captcha right...Now you can talk in the chat with no restrictions"
193
  c_data.remove_cap_data(chat,user)
194
- await q.answer(cap)
195
  try:
196
  await q.message.chat.unban_member(user)
197
  except Exception as e:
198
  await q.message.reply_text(f"Unable to unmute {q.from_user.mention} this user")
199
  await q.message.reply_text(e)
200
  return
201
- await c.send_message(f"{q.from_user.mention} now you are free to talk")
202
  await q.message.delete()
203
  return
204
  else:
205
- await q.answer("Wrong")
206
  caps = q.message.caption.split(":")
207
  tries = int(caps[1].strip()) - 1
208
  caps.pop(-1)
209
  caps.append(f" {tries}")
210
  new_cap = ":".join(caps)
 
211
  if not tries:
212
  new_cap = f"You have zero tries left now. I am going to kick you know coz you failed to solve captcha...see yaa {q.from_user.mention}"
213
  try:
@@ -220,5 +222,13 @@ async def captcha_codes_check(c: Gojo, q: CallbackQuery):
220
  await c.unban_chat_member(chat,user)
221
 
222
  else:
223
- await q.edit_message_caption(new_cap)
224
  return
 
 
 
 
 
 
 
 
 
 
1
  from random import shuffle
2
  from traceback import format_exc
3
 
4
+ import pyrogram # don't remove
5
  from pyrogram import filters
6
+ from pyrogram.enums import ChatMemberStatus as CMS
7
  from pyrogram.types import CallbackQuery, ChatMemberUpdated, ChatPermissions
8
  from pyrogram.types import InlineKeyboardButton as ikb
9
  from pyrogram.types import InlineKeyboardMarkup as ikm
10
  from pyrogram.types import Message
11
 
12
+ from Powers import LOGGER
13
  from Powers.bot_class import Gojo
14
  from Powers.database.captcha_db import CAPTCHA, CAPTCHA_DATA
15
+ from Powers.supports import get_support_staff
16
  from Powers.utils.captcha_helper import (genrator, get_image_captcha,
17
  get_qr_captcha)
18
  from Powers.utils.custom_filters import admin_filter, command
 
32
  await m.reply_text(txt)
33
  return
34
  else:
35
+ on_off = split[1].lower()
36
  if on_off in ["on","yes","enable"]:
37
  captcha.insert_captcha(m.chat.id)
38
  await m.reply_text("Captcha verification is now **on** for this chat")
 
72
  await m.reply_text("**USAGE**\n/captchamode [qr | image]")
73
  return
74
 
75
+ @Gojo.on_chat_member_updated(filters.group,18)
76
+ async def joinss(c: Gojo, u: ChatMemberUpdated):
77
  chat = u.chat.id
 
78
 
79
+ if (
80
+ u.new_chat_member
81
+ ):
82
+ pass
83
+ else:
84
+ return
85
+
86
+ user = u.new_chat_member.user.id
87
+ userr = u.new_chat_member.user
88
+
89
+ is_qr = CAPTCHA().is_captcha(chat)
90
  if not is_qr:
91
  return
92
+
93
  captcha = CAPTCHA()
94
  cap_data = CAPTCHA_DATA()
95
 
96
  if user in SUPPORT_STAFF:
97
  return
98
+
99
+ captcha_type = captcha.get_captcha(chat)
100
+
101
+ is_already = cap_data.is_already_data(chat, user)
102
+
103
+ mess = False
104
+ try:
105
+ if is_already:
106
+ mess = await c.get_messages(chat,int(is_already))
107
+ except Exception:
108
+ cap_data.del_message_id(chat,is_already)
109
+ mess = False
110
+ is_already = False
111
+
112
+ if is_already and not mess:
113
+ cap_data.del_message_id(chat,is_already)
114
+ return
115
+
116
  try:
117
  await c.restrict_chat_member(chat,user,ChatPermissions())
118
  except Exception as e:
 
120
  LOGGER.error(format_exc())
121
  return
122
 
123
+ if not is_already:
124
+ if captcha_type == "qr":
125
+ pic = await get_qr_captcha(chat, user)
126
+ cap = f"Please {userr.mention} scan this qr code with your phone to verify that you are human"
127
+ ms = await c.send_photo(chat,pic,caption=cap)
 
 
 
 
 
 
 
 
 
 
 
128
  cap_data.store_message_id(chat,user,ms.id)
129
  return
130
+ elif captcha_type == "image":
131
+ img, code = await get_image_captcha(chat, user)
132
+ cap = f"Please {userr.mention} please choose the correct code from the one given bellow\nYou have three tries if you get all three wrong u will be kicked from the chat.\nTries left: 3"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
  cap_data.load_cap_data(chat, user, code)
134
  rand = [code]
135
  while len(rand) != 5:
 
140
 
141
  ini = f"captcha_{chat}_{user}_"
142
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143
  kb = ikm(
144
  [
145
  [
146
+ ikb(rand[0],ini+rand[0])
147
+ ],
148
+ [
149
+ ikb(rand[1],ini+rand[1])
150
+ ],
151
+ [
152
+ ikb(rand[2],ini+rand[2])
153
+ ],
154
+ [
155
+ ikb(rand[3],ini+rand[3])
156
+ ],
157
+ [
158
+ ikb(rand[4],ini+rand[4])
159
  ]
160
  ]
161
  )
162
+ await c.send_photo(chat,img,caption=cap,reply_markup=kb)
163
  return
164
+ elif is_already and mess:
165
+ kb = ikm(
166
+ [
167
+ [
168
+ ikb("Click here to verify",url=mess.link)
169
+ ]
170
+ ]
171
+ )
172
+ await c.send_message(f"{userr.mention} your verification is already pending",reply_markup=kb)
173
+ return
174
+ else:
175
+ await c.unban_chat_member(chat,user)
176
+ return
177
 
178
  @Gojo.on_callback_query(filters.regex("^captcha_"))
179
  async def captcha_codes_check(c: Gojo, q: CallbackQuery):
 
193
  if code_ == code:
194
  cap = "You guessed the captcha right...Now you can talk in the chat with no restrictions"
195
  c_data.remove_cap_data(chat,user)
196
+ await q.answer(cap,True)
197
  try:
198
  await q.message.chat.unban_member(user)
199
  except Exception as e:
200
  await q.message.reply_text(f"Unable to unmute {q.from_user.mention} this user")
201
  await q.message.reply_text(e)
202
  return
203
+ await c.send_message(chat,f"{q.from_user.mention} now you are free to talk")
204
  await q.message.delete()
205
  return
206
  else:
 
207
  caps = q.message.caption.split(":")
208
  tries = int(caps[1].strip()) - 1
209
  caps.pop(-1)
210
  caps.append(f" {tries}")
211
  new_cap = ":".join(caps)
212
+ await q.answer(f"Wrong\nTries left: {tries}", True)
213
  if not tries:
214
  new_cap = f"You have zero tries left now. I am going to kick you know coz you failed to solve captcha...see yaa {q.from_user.mention}"
215
  try:
 
222
  await c.unban_chat_member(chat,user)
223
 
224
  else:
225
+ await q.edit_message_caption(new_cap,reply_markup=q.message.reply_markup)
226
  return
227
+
228
+
229
+ __PLUGIN__ = "captcha"
230
+
231
+ __HELP__ = """
232
+ • /captcha [on|yes|enable|off|no|disable] : To enable or disable captcha verification
233
+ • /captchamode [qr|image] : To change captcha mode
234
+ """
Powers/plugins/dev.py CHANGED
@@ -16,13 +16,14 @@ from pyrogram.types import InlineKeyboardMarkup as IKM
16
  from pyrogram.types import Message
17
 
18
  from Powers import (BOT_TOKEN, LOG_DATETIME, LOGFILE, LOGGER, MESSAGE_DUMP,
19
- OWNER_ID, UPTIME, get_support_staff)
20
  from Powers.bot_class import Gojo
21
  from Powers.database import MongoDB
22
  from Powers.database.chats_db import Chats
23
  from Powers.database.support_db import SUPPORTS
24
  from Powers.database.users_db import Users
25
- from Powers.plugins.clean_db import clean_my_db
 
26
  from Powers.utils.clean_file import remove_markdown_and_html
27
  from Powers.utils.custom_filters import command
28
  from Powers.utils.extract_user import extract_user
@@ -179,7 +180,7 @@ async def rm_support(c: Gojo, m: Message):
179
  await m.reply_text("Reply to an user")
180
  return
181
  support.delete_support_user(curr)
182
- await m.reply_text("Done")
183
  elif len(split) >= 2:
184
  try:
185
  user,_,_ = extract_user(split[1])
@@ -187,7 +188,7 @@ async def rm_support(c: Gojo, m: Message):
187
  await m.reply_text("Dunno who u r talking abt")
188
  return
189
  support.delete_support_user(user)
190
- await m.reply_text("Done")
191
  else:
192
  await m.reply_text("**USAGE**\n/rmsupport [reply to user | user id | username]")
193
  return
@@ -613,7 +614,7 @@ async def chat_broadcast(c: Gojo, m: Message):
613
 
614
  return
615
 
616
- @Gojo.on_message(command(["forward","fwd"]),dev_cmd=True)
617
  async def forward_type_broadcast(c: Gojo, m: Message):
618
  repl = m.reply_to_message
619
  if not repl:
@@ -694,7 +695,7 @@ __HELP__ = """
694
  • /update : To update the bot with the main stream repo
695
 
696
  **Dev's commands:**
697
- • /adddev : Reply to message or give me user id or username
698
  • /logs : Return the logs of bot.
699
  • /neofetch : Fetch neo.
700
  • /eval : Evaluate the given python code.
 
16
  from pyrogram.types import Message
17
 
18
  from Powers import (BOT_TOKEN, LOG_DATETIME, LOGFILE, LOGGER, MESSAGE_DUMP,
19
+ OWNER_ID, UPTIME)
20
  from Powers.bot_class import Gojo
21
  from Powers.database import MongoDB
22
  from Powers.database.chats_db import Chats
23
  from Powers.database.support_db import SUPPORTS
24
  from Powers.database.users_db import Users
25
+ from Powers.plugins.scheduled_jobs import clean_my_db
26
+ from Powers.supports import get_support_staff
27
  from Powers.utils.clean_file import remove_markdown_and_html
28
  from Powers.utils.custom_filters import command
29
  from Powers.utils.extract_user import extract_user
 
180
  await m.reply_text("Reply to an user")
181
  return
182
  support.delete_support_user(curr)
183
+ await m.reply_text("Done! User now no longer belongs to the support staff")
184
  elif len(split) >= 2:
185
  try:
186
  user,_,_ = extract_user(split[1])
 
188
  await m.reply_text("Dunno who u r talking abt")
189
  return
190
  support.delete_support_user(user)
191
+ await m.reply_text("Done! User now no longer belongs to the support staff")
192
  else:
193
  await m.reply_text("**USAGE**\n/rmsupport [reply to user | user id | username]")
194
  return
 
614
 
615
  return
616
 
617
+ @Gojo.on_message(command(["forward","fwd"],dev_cmd=True))
618
  async def forward_type_broadcast(c: Gojo, m: Message):
619
  repl = m.reply_to_message
620
  if not repl:
 
695
  • /update : To update the bot with the main stream repo
696
 
697
  **Dev's commands:**
698
+ • /addsupport [dev | sudo | whitelist] : Reply to message or give me user id or username
699
  • /logs : Return the logs of bot.
700
  • /neofetch : Fetch neo.
701
  • /eval : Evaluate the given python code.
Powers/plugins/filters.py CHANGED
@@ -212,7 +212,7 @@ async def send_filter_reply(c: Gojo, m: Message, trigger: str):
212
  text = await escape_mentions_using_curly_brackets(m, filter_reply, parse_words)
213
  teks, button = await parse_button(text)
214
  button = await build_keyboard(button)
215
- button = InlineKeyboardMarkup(button) if button else None
216
  textt = teks
217
  try:
218
  if msgtype == Types.TEXT:
 
212
  text = await escape_mentions_using_curly_brackets(m, filter_reply, parse_words)
213
  teks, button = await parse_button(text)
214
  button = await build_keyboard(button)
215
+ button = ikb(button) if button else None
216
  textt = teks
217
  try:
218
  if msgtype == Types.TEXT:
Powers/plugins/flood.py CHANGED
@@ -10,10 +10,11 @@ from pyrogram.types import (CallbackQuery, ChatPermissions,
10
  InlineKeyboardButton, InlineKeyboardMarkup,
11
  Message)
12
 
13
- from Powers import LOGGER, SUPPORT_GROUP, get_support_staff
14
  from Powers.bot_class import Gojo
15
  from Powers.database.approve_db import Approve
16
  from Powers.database.flood_db import Floods
 
17
  from Powers.utils.custom_filters import admin_filter, command
18
  from Powers.utils.extras import BAN_GIFS, KICK_GIFS, MUTE_GIFS
19
  from Powers.utils.kbhelpers import ikb
 
10
  InlineKeyboardButton, InlineKeyboardMarkup,
11
  Message)
12
 
13
+ from Powers import LOGGER, SUPPORT_GROUP
14
  from Powers.bot_class import Gojo
15
  from Powers.database.approve_db import Approve
16
  from Powers.database.flood_db import Floods
17
+ from Powers.supports import get_support_staff
18
  from Powers.utils.custom_filters import admin_filter, command
19
  from Powers.utils.extras import BAN_GIFS, KICK_GIFS, MUTE_GIFS
20
  from Powers.utils.kbhelpers import ikb
Powers/plugins/fun.py CHANGED
@@ -5,8 +5,9 @@ from pyrogram import enums
5
  from pyrogram.errors import MessageTooLong
6
  from pyrogram.types import Message
7
 
8
- from Powers import LOGGER, get_support_staff
9
  from Powers.bot_class import Gojo
 
10
  from Powers.utils import extras
11
  from Powers.utils.custom_filters import command
12
  from Powers.utils.extras import NOWYES as NO
 
5
  from pyrogram.errors import MessageTooLong
6
  from pyrogram.types import Message
7
 
8
+ from Powers import LOGGER
9
  from Powers.bot_class import Gojo
10
+ from Powers.supports import get_support_staff
11
  from Powers.utils import extras
12
  from Powers.utils.custom_filters import command
13
  from Powers.utils.extras import NOWYES as NO
Powers/plugins/greetings.py CHANGED
@@ -1,17 +1,20 @@
1
  from html import escape
2
  from secrets import choice
 
3
 
4
  from pyrogram import enums, filters
5
  from pyrogram.enums import ChatMemberStatus as CMS
6
  from pyrogram.errors import ChatAdminRequired, RPCError
7
- from pyrogram.types import ChatMemberUpdated, InlineKeyboardMarkup, Message
8
 
9
- from Powers import get_support_staff
10
  from Powers.bot_class import Gojo
11
  from Powers.database.antispam_db import GBan
12
  from Powers.database.greetings_db import Greetings
 
13
  from Powers.utils.cmd_senders import send_cmd
14
  from Powers.utils.custom_filters import admin_filter, bot_admin_filter, command
 
15
  from Powers.utils.msg_types import Types, get_wlcm_type
16
  from Powers.utils.parser import escape_markdown, mention_html
17
  from Powers.utils.string import (build_keyboard, escape_invalid_curly_brackets,
@@ -161,7 +164,7 @@ async def save_wlcm(_, m: Message):
161
  await m.reply_text("Please provide some data for this to reply with!")
162
  return
163
 
164
- db.set_welcome_text(text,file)
165
  await m.reply_text("Saved welcome!")
166
  return
167
 
@@ -199,7 +202,7 @@ async def save_gdbye(_, m: Message):
199
  await m.reply_text("Please provide some data for this to reply with!")
200
  return
201
 
202
- db.set_goodbye_text(text,file)
203
  await m.reply_text("Saved goodbye!")
204
  return
205
 
@@ -291,7 +294,7 @@ async def member_has_joined(c: Gojo, member: ChatMemberUpdated):
291
  if status:
292
  tek, button = await parse_button(hmm)
293
  button = await build_keyboard(button)
294
- button = InlineKeyboardMarkup(button) if button else None
295
 
296
  if "%%%" in tek:
297
  filter_reply = tek.split("%%%")
@@ -324,7 +327,8 @@ async def member_has_joined(c: Gojo, member: ChatMemberUpdated):
324
  if jj:
325
  db.set_cleanwlcm_id(int(jj.id))
326
  except RPCError as e:
327
- print(e)
 
328
  return
329
  else:
330
  return
@@ -362,7 +366,7 @@ async def member_has_left(c: Gojo, member: ChatMemberUpdated):
362
  if status:
363
  tek, button = await parse_button(hmm)
364
  button = await build_keyboard(button)
365
- button = InlineKeyboardMarkup(button) if button else None
366
 
367
  if "%%%" in tek:
368
  filter_reply = tek.split("%%%")
@@ -402,7 +406,8 @@ async def member_has_left(c: Gojo, member: ChatMemberUpdated):
402
  db.set_cleangoodbye_id(int(ooo.id))
403
  return
404
  except RPCError as e:
405
- print(e)
 
406
  return
407
  else:
408
  return
@@ -434,11 +439,11 @@ async def welcome(c: Gojo, m: Message):
434
  return
435
  if args[1].lower() == "on":
436
  db.set_current_welcome_settings(True)
437
- await m.reply_text("Turned on!")
438
  return
439
  if args[1].lower() == "off":
440
  db.set_current_welcome_settings(False)
441
- await m.reply_text("Turned off!")
442
  return
443
  await m.reply_text("what are you trying to do ??")
444
  return
@@ -450,10 +455,25 @@ async def welcome(c: Gojo, m: Message):
450
  Welcome text:
451
  """,
452
  )
 
 
453
  tek, button = await parse_button(oo)
454
  button = await build_keyboard(button)
455
- button = InlineKeyboardMarkup(button) if button else None
456
- await c.send_message(m.chat.id, text=tek, reply_markup=button)
 
 
 
 
 
 
 
 
 
 
 
 
 
457
  return
458
 
459
 
@@ -481,11 +501,11 @@ async def goodbye(c: Gojo, m: Message):
481
  return
482
  if args[1].lower() == "on":
483
  db.set_current_goodbye_settings(True)
484
- await m.reply_text("Turned on!")
485
  return
486
  if args[1].lower() == "off":
487
  db.set_current_goodbye_settings(False)
488
- await m.reply_text("Turned off!")
489
  return
490
  await m.reply_text("what are you trying to do ??")
491
  return
@@ -497,10 +517,26 @@ async def goodbye(c: Gojo, m: Message):
497
  Goodbye text:
498
  """,
499
  )
 
 
500
  tek, button = await parse_button(oo)
501
  button = await build_keyboard(button)
502
- button = InlineKeyboardMarkup(button) if button else None
503
- await c.send_message(m.chat.id, text=tek, reply_markup=button)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
504
  return
505
 
506
 
 
1
  from html import escape
2
  from secrets import choice
3
+ from traceback import format_exc
4
 
5
  from pyrogram import enums, filters
6
  from pyrogram.enums import ChatMemberStatus as CMS
7
  from pyrogram.errors import ChatAdminRequired, RPCError
8
+ from pyrogram.types import ChatMemberUpdated, Message
9
 
10
+ from Powers import LOGGER
11
  from Powers.bot_class import Gojo
12
  from Powers.database.antispam_db import GBan
13
  from Powers.database.greetings_db import Greetings
14
+ from Powers.supports import get_support_staff
15
  from Powers.utils.cmd_senders import send_cmd
16
  from Powers.utils.custom_filters import admin_filter, bot_admin_filter, command
17
+ from Powers.utils.kbhelpers import ikb
18
  from Powers.utils.msg_types import Types, get_wlcm_type
19
  from Powers.utils.parser import escape_markdown, mention_html
20
  from Powers.utils.string import (build_keyboard, escape_invalid_curly_brackets,
 
164
  await m.reply_text("Please provide some data for this to reply with!")
165
  return
166
 
167
+ db.set_welcome_text(text,msgtype,file)
168
  await m.reply_text("Saved welcome!")
169
  return
170
 
 
202
  await m.reply_text("Please provide some data for this to reply with!")
203
  return
204
 
205
+ db.set_goodbye_text(text,msgtype,file)
206
  await m.reply_text("Saved goodbye!")
207
  return
208
 
 
294
  if status:
295
  tek, button = await parse_button(hmm)
296
  button = await build_keyboard(button)
297
+ button = ikb(button) if button else None
298
 
299
  if "%%%" in tek:
300
  filter_reply = tek.split("%%%")
 
327
  if jj:
328
  db.set_cleanwlcm_id(int(jj.id))
329
  except RPCError as e:
330
+ LOGGER.error(e)
331
+ LOGGER.error(format_exc(e))
332
  return
333
  else:
334
  return
 
366
  if status:
367
  tek, button = await parse_button(hmm)
368
  button = await build_keyboard(button)
369
+ button = ikb(button) if button else None
370
 
371
  if "%%%" in tek:
372
  filter_reply = tek.split("%%%")
 
406
  db.set_cleangoodbye_id(int(ooo.id))
407
  return
408
  except RPCError as e:
409
+ LOGGER.error(e)
410
+ LOGGER.error(format_exc(e))
411
  return
412
  else:
413
  return
 
439
  return
440
  if args[1].lower() == "on":
441
  db.set_current_welcome_settings(True)
442
+ await m.reply_text("I will greet newly joined member from now on.")
443
  return
444
  if args[1].lower() == "off":
445
  db.set_current_welcome_settings(False)
446
+ await m.reply_text("I will stay quiet when someone joins.")
447
  return
448
  await m.reply_text("what are you trying to do ??")
449
  return
 
455
  Welcome text:
456
  """,
457
  )
458
+ UwU = db.get_welcome_media()
459
+ mtype = db.get_welcome_msgtype()
460
  tek, button = await parse_button(oo)
461
  button = await build_keyboard(button)
462
+ button = ikb(button) if button else None
463
+ if not UwU:
464
+ await c.send_message(
465
+ m.chat.id,
466
+ text=tek,
467
+ reply_markup=button,
468
+ disable_web_page_preview=True,
469
+ )
470
+ elif UwU:
471
+ await (await send_cmd(c,mtype))(
472
+ m.chat.id,
473
+ UwU,
474
+ caption=tek,
475
+ reply_markup=button,
476
+ )
477
  return
478
 
479
 
 
501
  return
502
  if args[1].lower() == "on":
503
  db.set_current_goodbye_settings(True)
504
+ await m.reply_text("I don't want but I will say goodbye to the fugitives")
505
  return
506
  if args[1].lower() == "off":
507
  db.set_current_goodbye_settings(False)
508
+ await m.reply_text("I will stay quiet for fugitives")
509
  return
510
  await m.reply_text("what are you trying to do ??")
511
  return
 
517
  Goodbye text:
518
  """,
519
  )
520
+ UwU = db.get_goodbye_media()
521
+ mtype = db.get_goodbye_msgtype()
522
  tek, button = await parse_button(oo)
523
  button = await build_keyboard(button)
524
+ button = ikb(button) if button else None
525
+ if not UwU:
526
+ await c.send_message(
527
+ m.chat.id,
528
+ text=tek,
529
+ reply_markup=button,
530
+ disable_web_page_preview=True,
531
+ )
532
+ elif UwU:
533
+ await (await send_cmd(c,mtype))(
534
+ m.chat.id,
535
+ UwU,
536
+ caption=tek,
537
+ reply_markup=button,
538
+ )
539
+ return
540
  return
541
 
542
 
Powers/plugins/info.py CHANGED
@@ -9,9 +9,10 @@ from pyrogram.raw.functions.channels import GetFullChannel
9
  from pyrogram.raw.functions.users import GetFullUser
10
  from pyrogram.types import Message
11
 
12
- from Powers import LOGGER, OWNER_ID, get_support_staff
13
  from Powers.bot_class import Gojo
14
  from Powers.database.antispam_db import GBan
 
15
  from Powers.utils.custom_filters import command
16
  from Powers.utils.extract_user import extract_user
17
  from Powers.vars import Config
 
9
  from pyrogram.raw.functions.users import GetFullUser
10
  from pyrogram.types import Message
11
 
12
+ from Powers import LOGGER, OWNER_ID
13
  from Powers.bot_class import Gojo
14
  from Powers.database.antispam_db import GBan
15
+ from Powers.supports import get_support_staff
16
  from Powers.utils.custom_filters import command
17
  from Powers.utils.extract_user import extract_user
18
  from Powers.vars import Config
Powers/plugins/locks.py CHANGED
@@ -6,21 +6,17 @@ from pyrogram.enums import MessageEntityType as MET
6
  from pyrogram.errors import ChatAdminRequired, ChatNotModified, RPCError
7
  from pyrogram.types import ChatPermissions, Message
8
 
9
- from Powers import LOGGER, get_support_staff
10
  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
  from Powers.vars import Config
15
 
16
  SUDO_LEVEL = get_support_staff("sudo_level")
17
 
18
- anti_c_send = [-1001604479593]
19
- anti_forward = [-1001604479593]
20
- anti_forward_u = []
21
- anti_forward_c = []
22
- anti_links = []
23
-
24
  l_t = """
25
  **Lock Types:**
26
  - `all` = Everything
@@ -84,6 +80,8 @@ async def lock_perm(c: Gojo, m: Message):
84
  await prevent_approved(m)
85
  return
86
 
 
 
87
  if lock_type == "msg":
88
  msg = False
89
  perm = "messages"
@@ -128,51 +126,36 @@ async def lock_perm(c: Gojo, m: Message):
128
  pin = False
129
  perm = "pin"
130
  elif lock_type in ["links", "url"]:
131
- if not len(anti_links):
132
- anti_links.append(m.chat.id)
133
- elif m.chat.id not in anti_links:
134
- anti_links.append(m.chat.id)
135
- else:
136
  await m.reply_text("It is already on")
137
  return
138
  await m.reply_text("Locked links in the chat")
139
  return
140
  elif lock_type == "anonchannel":
141
- if not len(anti_c_send):
142
- anti_c_send.append(m.chat.id)
143
- elif m.chat.id not in anti_c_send:
144
- anti_c_send.append(m.chat.id)
145
- else:
146
  await m.reply_text("It is already on")
147
  return
148
  await m.reply_text("Locked Send As Chat")
149
  return
150
  elif lock_type == "forwardall":
151
- if not len(anti_forward):
152
- anti_forward.append(m.chat.id)
153
- elif m.chat.id not in anti_forward:
154
- anti_forward.append(m.chat.id)
155
- else:
156
  await m.reply_text("It is already on")
157
  return
158
  await m.reply_text("Locked Forward from user as well as channel")
159
  return
160
  elif lock_type == "forwardu":
161
- if not len(anti_forward_u):
162
- anti_forward_u.append(m.chat.id)
163
- elif m.chat.id not in anti_forward:
164
- anti_forward_u.append(m.chat.id)
165
- else:
166
  await m.reply_text("It is already on")
167
  return
168
  await m.reply_text("Locked Forward message from user")
169
  return
170
  elif lock_type == "forwardc":
171
- if not len(anti_forward_c):
172
- anti_forward_c.append(m.chat.id)
173
- elif m.chat.id not in anti_forward:
174
- anti_forward_c.append(m.chat.id)
175
- else:
176
  await m.reply_text("It is already on")
177
  return
178
  await m.reply_text("Locked Forward message from channel")
@@ -220,6 +203,13 @@ async def view_locks(_, m: Message):
220
  if val:
221
  return "✅"
222
  return "❌"
 
 
 
 
 
 
 
223
  anon = False
224
  if m.chat.id in anti_c_send:
225
  anon = True
@@ -324,6 +314,8 @@ async def unlock_perm(c: Gojo, m: Message):
324
  upin = get_uperm.can_pin_messages
325
  ustickers = uanimations = ugames = uinlinebots = None
326
 
 
 
327
  if unlock_type == "msg":
328
  umsg = True
329
  uperm = "messages"
@@ -368,57 +360,49 @@ async def unlock_perm(c: Gojo, m: Message):
368
  upin = True
369
  uperm = "pin"
370
  elif unlock_type == "anonchannel":
371
- try:
372
- if not len(anti_c_send) or m.chat.id not in anti_c_send:
373
- await m.reply_text("Already off")
374
- return
375
- anti_c_send.remove(m.chat.id)
376
- await m.reply_text("Send as chat is now enabled for this chat")
377
- return
378
- except ValueError:
379
- await m.reply_text("It is already off")
380
  return
 
 
381
  elif unlock_type in ["links", "url"]:
382
- try:
383
- anti_links.remove(m.chat.id)
384
  await m.reply_text("Sending link is now allowed")
385
  return
386
- except ValueError:
387
- await m.reply_text("Already allowed")
388
  return
389
  elif unlock_type == "forwardall":
390
- try:
391
- if not len(anti_forward) or m.chat.id not in anti_forward:
392
- await m.reply_text("Already off")
393
- return
394
- anti_forward.remove(m.chat.id)
395
- await m.reply_text("Forwarding content is now enabled for this chat")
396
- return
397
- except ValueError:
398
- await m.reply_text("It is already off")
399
  return
 
 
 
400
  elif unlock_type == "forwardu":
401
- try:
402
- if not len(anti_forward_u) or m.chat.id not in anti_forward_u:
403
- await m.reply_text("Already off")
404
- return
405
- anti_forward_u.remove(m.chat.id)
406
- await m.reply_text("Forwarding content is now enabled for this chat")
407
- return
408
- except ValueError:
409
- await m.reply_text("It is already off")
410
  return
 
 
 
 
411
  elif unlock_type == "forwardc":
412
- try:
413
- if not len(anti_forward_c) or m.chat.id not in anti_forward_c:
414
- await m.reply_text("Already off")
415
- return
416
- anti_forward_c.remove(m.chat.id)
417
- await m.reply_text("Forwarding content is now enabled for this chat")
418
- return
419
- except ValueError:
420
- await m.reply_text("It is already off")
421
  return
 
 
 
422
  else:
423
  await m.reply_text(
424
  text="""Invalid Lock Type!
@@ -489,7 +473,10 @@ async def is_approved_user(c:Gojo, m: Message):
489
 
490
  @Gojo.on_message(filters.all & ~filters.me,18)
491
  async def lock_del_mess(c:Gojo, m: Message):
492
- all_chats = anti_c_send + anti_forward + anti_forward_c + anti_forward_u + anti_links
 
 
 
493
  if m.chat.id not in all_chats:
494
  return
495
  if m.sender_chat and not (m.forward_from_chat or m.forward_from):
@@ -507,13 +494,13 @@ async def lock_del_mess(c:Gojo, m: Message):
507
  return
508
  elif m.forward_from or m.forward_from_chat:
509
  if not is_approved:
510
- if m.chat.id in anti_forward:
511
  await delete_messages(c,m)
512
  return
513
- elif m.chat.id in anti_forward_u and not m.forward_from_chat:
514
  await delete_messages(c,m)
515
  return
516
- elif m.chat.id in anti_forward_c and m.forward_from_chat:
517
  await delete_messages(c,m)
518
  return
519
 
 
6
  from pyrogram.errors import ChatAdminRequired, ChatNotModified, RPCError
7
  from pyrogram.types import ChatPermissions, Message
8
 
9
+ from Powers import LOGGER
10
  from Powers.bot_class import Gojo
11
  from Powers.database.approve_db import Approve
12
+ from Powers.database.locks_db import LOCKS
13
+ from Powers.supports import get_support_staff
14
  from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
15
  from Powers.utils.custom_filters import command, restrict_filter
16
  from Powers.vars import Config
17
 
18
  SUDO_LEVEL = get_support_staff("sudo_level")
19
 
 
 
 
 
 
 
20
  l_t = """
21
  **Lock Types:**
22
  - `all` = Everything
 
80
  await prevent_approved(m)
81
  return
82
 
83
+ lock = LOCKS()
84
+
85
  if lock_type == "msg":
86
  msg = False
87
  perm = "messages"
 
126
  pin = False
127
  perm = "pin"
128
  elif lock_type in ["links", "url"]:
129
+ curr = lock.insert_lock_channel(m.chat.id, "anti_links")
130
+ if not curr:
 
 
 
131
  await m.reply_text("It is already on")
132
  return
133
  await m.reply_text("Locked links in the chat")
134
  return
135
  elif lock_type == "anonchannel":
136
+ curr = lock.insert_lock_channel(m.chat.id,"anti_c_send")
137
+ if not curr:
 
 
 
138
  await m.reply_text("It is already on")
139
  return
140
  await m.reply_text("Locked Send As Chat")
141
  return
142
  elif lock_type == "forwardall":
143
+ curr = lock.insert_lock_channel(m.chat.id,"anti_fwd")
144
+ if not curr:
 
 
 
145
  await m.reply_text("It is already on")
146
  return
147
  await m.reply_text("Locked Forward from user as well as channel")
148
  return
149
  elif lock_type == "forwardu":
150
+ curr = lock.insert_lock_channel(m.chat.id,"anti_fwd_u")
151
+ if not curr:
 
 
 
152
  await m.reply_text("It is already on")
153
  return
154
  await m.reply_text("Locked Forward message from user")
155
  return
156
  elif lock_type == "forwardc":
157
+ curr = lock.insert_lock_channel(m.chat.id,"anti_fwd_c")
158
+ if not curr:
 
 
 
159
  await m.reply_text("It is already on")
160
  return
161
  await m.reply_text("Locked Forward message from channel")
 
203
  if val:
204
  return "✅"
205
  return "❌"
206
+
207
+ lock = LOCKS()
208
+ anti_c_send = lock.get_lock_channel("anti_c_send")
209
+ anti_forward = lock.get_lock_channel("anti_fwd")
210
+ anti_forward_u = lock.get_lock_channel("anti_fwd_u")
211
+ anti_forward_c = lock.get_lock_channel("anti_fwd_c")
212
+ anti_links = lock.get_lock_channel("anti_links")
213
  anon = False
214
  if m.chat.id in anti_c_send:
215
  anon = True
 
314
  upin = get_uperm.can_pin_messages
315
  ustickers = uanimations = ugames = uinlinebots = None
316
 
317
+ lock = LOCKS()
318
+
319
  if unlock_type == "msg":
320
  umsg = True
321
  uperm = "messages"
 
360
  upin = True
361
  uperm = "pin"
362
  elif unlock_type == "anonchannel":
363
+ curr = lock.remove_lock_channel(m.chat.id,"anti_c_send")
364
+
365
+ if not curr:
366
+ await m.reply_text("Send as chat is not allowed in this chat")
 
 
 
 
 
367
  return
368
+ await m.reply_text("Send as chat is now enabled for this chat")
369
+ return
370
  elif unlock_type in ["links", "url"]:
371
+ curr = lock.remove_lock_channel(m.chat.id,"anti_links")
372
+ if curr:
373
  await m.reply_text("Sending link is now allowed")
374
  return
375
+ else:
376
+ await m.reply_text("Sending link is not allowed")
377
  return
378
  elif unlock_type == "forwardall":
379
+ curr = lock.remove_lock_channel(m.chat.id,"anti_fwd")
380
+
381
+ if not curr:
382
+ await m.reply_text("Forwarding content is not allowed in this chat")
 
 
 
 
 
383
  return
384
+ await m.reply_text("Forwarding content is now enabled for this chat")
385
+ return
386
+
387
  elif unlock_type == "forwardu":
388
+ curr = lock.remove_lock_channel(m.chat.id,"anti_fwd_u")
389
+
390
+ if not curr:
391
+ await m.reply_text("Forwarding content from users is not allowed in this chat")
 
 
 
 
 
392
  return
393
+
394
+ await m.reply_text("Forwarding content from users is now enabled for this chat")
395
+ return
396
+
397
  elif unlock_type == "forwardc":
398
+ curr = lock.remove_lock_channel(m.chat.id,"anti_fwd_c")
399
+
400
+ if not curr:
401
+ await m.reply_text("Forwarding content from channel is not allowed in this chat")
 
 
 
 
 
402
  return
403
+ await m.reply_text("Forwarding content from channel is now enabled for this chat")
404
+ return
405
+
406
  else:
407
  await m.reply_text(
408
  text="""Invalid Lock Type!
 
473
 
474
  @Gojo.on_message(filters.all & ~filters.me,18)
475
  async def lock_del_mess(c:Gojo, m: Message):
476
+ lock = LOCKS()
477
+ all_chats = lock.get_lock_channel()
478
+ if not all_chats:
479
+ return
480
  if m.chat.id not in all_chats:
481
  return
482
  if m.sender_chat and not (m.forward_from_chat or m.forward_from):
 
494
  return
495
  elif m.forward_from or m.forward_from_chat:
496
  if not is_approved:
497
+ if lock.is_particular_lock(m.chat.id,"anti_fwd"):
498
  await delete_messages(c,m)
499
  return
500
+ elif lock.is_particular_lock(m.chat.id,"anti_fwd_u") and not m.forward_from_chat:
501
  await delete_messages(c,m)
502
  return
503
+ elif lock.is_particular_lock(m.chat.id,"anti_fwd_c") and m.forward_from_chat:
504
  await delete_messages(c,m)
505
  return
506
 
Powers/plugins/muting.py CHANGED
@@ -9,8 +9,9 @@ from pyrogram.types import (CallbackQuery, ChatPermissions,
9
  InlineKeyboardButton, InlineKeyboardMarkup,
10
  Message)
11
 
12
- from Powers import LOGGER, MESSAGE_DUMP, OWNER_ID, get_support_staff
13
  from Powers.bot_class import Gojo
 
14
  from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
15
  from Powers.utils.custom_filters import command, restrict_filter
16
  from Powers.utils.extract_user import extract_user
 
9
  InlineKeyboardButton, InlineKeyboardMarkup,
10
  Message)
11
 
12
+ from Powers import LOGGER, MESSAGE_DUMP, OWNER_ID
13
  from Powers.bot_class import Gojo
14
+ from Powers.supports import get_support_staff
15
  from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
16
  from Powers.utils.custom_filters import command, restrict_filter
17
  from Powers.utils.extract_user import extract_user
Powers/plugins/pin.py CHANGED
@@ -97,7 +97,7 @@ async def unpin_message(c: Gojo, m: Message):
97
  async def unpinall_message(_, m: Message):
98
  await m.reply_text(
99
  "Do you really want to unpin all messages in this chat?",
100
- reply_markup=ikb([[("Yes", "unpin all in this chat"), ("No", "close_admin")]]),
101
  )
102
  return
103
 
 
97
  async def unpinall_message(_, m: Message):
98
  await m.reply_text(
99
  "Do you really want to unpin all messages in this chat?",
100
+ reply_markup=ikb([[("Yes", "unpin_all_in_this_chat"), ("No", "close_admin")]]),
101
  )
102
  return
103
 
Powers/plugins/report.py CHANGED
@@ -6,9 +6,10 @@ from pyrogram.enums import ChatType
6
  from pyrogram.errors import RPCError
7
  from pyrogram.types import CallbackQuery, Message
8
 
9
- from Powers import LOGGER, get_support_staff
10
  from Powers.bot_class import Gojo
11
  from Powers.database.reporting_db import Reporting
 
12
  from Powers.utils.custom_filters import admin_filter, command
13
  from Powers.utils.kbhelpers import ikb
14
  from Powers.utils.parser import mention_html
 
6
  from pyrogram.errors import RPCError
7
  from pyrogram.types import CallbackQuery, Message
8
 
9
+ from Powers import LOGGER
10
  from Powers.bot_class import Gojo
11
  from Powers.database.reporting_db import Reporting
12
+ from Powers.supports import get_support_staff
13
  from Powers.utils.custom_filters import admin_filter, command
14
  from Powers.utils.kbhelpers import ikb
15
  from Powers.utils.parser import mention_html
Powers/plugins/scheduled_jobs.py ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import time
2
+ from asyncio import sleep
3
+ from traceback import format_exc
4
+
5
+ from apscheduler.schedulers.asyncio import AsyncIOScheduler
6
+ from pyrogram import Client
7
+ from pyrogram.enums import ChatMemberStatus as CMS
8
+ from pyrogram.errors import UserNotParticipant
9
+
10
+ from Powers import BDB_URI, LOGGER, MESSAGE_DUMP, TIME_ZONE
11
+ from Powers.database.approve_db import Approve
12
+ from Powers.database.blacklist_db import Blacklist
13
+ from Powers.database.chats_db import Chats
14
+ from Powers.database.disable_db import Disabling
15
+ from Powers.database.filters_db import Filters
16
+ from Powers.database.flood_db import Floods
17
+ from Powers.database.greetings_db import Greetings
18
+ from Powers.database.notes_db import Notes, NotesSettings
19
+ from Powers.database.pins_db import Pins
20
+ from Powers.database.reporting_db import Reporting
21
+ # from Powers.database.users_db import Users
22
+ from Powers.database.warns_db import Warns, WarnSettings
23
+ from Powers.utils.custom_filters import command
24
+ from Powers.vars import Config
25
+
26
+
27
+ async def clean_my_db(c:Client,is_cmd=False, id=None):
28
+ to_clean = list()
29
+ chats_list = Chats.list_chats_by_id()
30
+ to_clean.clear()
31
+ start = time.time()
32
+ for chats in chats_list:
33
+ try:
34
+ stat = await c.get_chat_member(chat_id=chats,user_id=Config.BOT_ID)
35
+ if stat.status not in [CMS.MEMBER, CMS.ADMINISTRATOR, CMS.OWNER]:
36
+ to_clean.append(chats)
37
+ except UserNotParticipant:
38
+ to_clean.append(chats)
39
+ except Exception as e:
40
+ LOGGER.error(e)
41
+ LOGGER.error(format_exc())
42
+ if not is_cmd:
43
+ return e
44
+ else:
45
+ to_clean.append(chats)
46
+ for i in to_clean:
47
+ Approve(i).clean_approve()
48
+ Blacklist(i).clean_blacklist()
49
+ Chats.remove_chat(i)
50
+ Disabling(i).clean_disable()
51
+ Filters().rm_all_filters(i)
52
+ Floods().rm_flood(i)
53
+ Greetings(i).clean_greetings()
54
+ Notes().rm_all_notes(i)
55
+ NotesSettings().clean_notes(i)
56
+ Pins(i).clean_pins()
57
+ Reporting(i).clean_reporting()
58
+ Warns(i).clean_warn()
59
+ WarnSettings(i).clean_warns()
60
+ x = len(to_clean)
61
+ txt = f"#INFO\n\nCleaned db:\nTotal chats removed: {x}"
62
+ to_clean.clear()
63
+ nums = time.time()-start
64
+ if is_cmd:
65
+ txt += f"\nClean type: Forced\nInitiated by: {(await c.get_users(user_ids=id)).mention}"
66
+ txt += f"\nClean type: Manual\n\tTook {round(nums,2)} seconds to complete the process"
67
+ await c.send_message(chat_id=MESSAGE_DUMP,text=txt)
68
+ return txt
69
+ else:
70
+ txt += f"\nClean type: Auto\n\tTook {round(nums,2)} seconds to complete the process"
71
+ await c.send_message(chat_id=MESSAGE_DUMP,text=txt)
72
+ return txt
73
+
74
+
75
+ if BDB_URI:
76
+ from Powers.plugins import bday_cinfo, bday_info
77
+
78
+ from datetime import datetime, time
79
+ from random import choice
80
+
81
+ from pyrogram.enums import ChatMemberStatus
82
+
83
+ from Powers.utils.extras import birthday_wish
84
+
85
+
86
+ def give_date(date,form = "%d/%m/%Y"):
87
+ datee = datetime.strptime(date,form).date()
88
+ return datee
89
+
90
+ scheduler = AsyncIOScheduler()
91
+ scheduler.timezone = TIME_ZONE
92
+ scheduler_time = time(0,0,0)
93
+ async def send_wishish(JJK: Client):
94
+ c_list = Chats.list_chats_by_id()
95
+ blist = list(bday_info.find())
96
+ curr = datetime.now(TIME_ZONE).date()
97
+ cclist = list(bday_cinfo.find())
98
+ for i in blist:
99
+ dob = give_date(i["dob"])
100
+ if dob.month == curr.month and dob.day == curr.day:
101
+ for j in c_list:
102
+ if cclist and (j in cclist):
103
+ return
104
+ try:
105
+ agee = ""
106
+ if i["is_year"]:
107
+ agee = curr.year - dob.year
108
+ if str(agee).endswith("1"):
109
+ agee = f"{agee}st"
110
+ elif str(agee).endswith("2"):
111
+ agee = f"{agee}nd"
112
+ elif str(agee).endswith("3"):
113
+ agee = f"{agee}rd"
114
+ else:
115
+ agee = f"{agee}th"
116
+ U = await JJK.get_chat_member(chat_id=j,user_id=i["user_id"])
117
+ wish = choice(birthday_wish)
118
+ if U.status in [ChatMemberStatus.MEMBER,ChatMemberStatus.ADMINISTRATOR, ChatMemberStatus.OWNER]:
119
+ xXx = await JJK.send_message(j,f"Happy {agee} birthday {U.user.mention}🥳\n{wish}")
120
+ try:
121
+ await xXx.pin()
122
+ except Exception:
123
+ pass
124
+ except Exception:
125
+ pass
126
+
127
+ """"
128
+ from datetime import date, datetime
129
+
130
+ #form =
131
+ num = "18/05/2005"
132
+ st = "18 May 2005"
133
+ timm = datetime.strptime(num,"%d/%m/%Y").date()
134
+ x = datetime.now().date()
135
+ if timm.month < x.month:
136
+ next_b = date(x.year + 1, timm.month, timm.day)
137
+ days_left = (next_b - x).days
138
+ else:
139
+ timmm = date(x.year, timm.month, timm.day)
140
+ days_left = (timmm - x).days
141
+ print(days_left)
142
+ print(x.year - timm.year)
143
+ """
144
+
Powers/plugins/search.py CHANGED
@@ -1,6 +1,6 @@
1
  from traceback import format_exc
2
 
3
- from pyrogram.types import Message
4
  from search_engine_parser.core.engines.google import Search as GoogleSearch
5
  from search_engine_parser.core.engines.myanimelist import Search as AnimeSearch
6
  from search_engine_parser.core.engines.stackoverflow import \
@@ -11,6 +11,7 @@ from search_engine_parser.core.exceptions import (NoResultsFound,
11
  from Powers import LOGGER, SUPPORT_CHANNEL
12
  from Powers.bot_class import Gojo
13
  from Powers.utils.custom_filters import command
 
14
  from Powers.utils.kbhelpers import ikb
15
 
16
  #have to add youtube
@@ -225,6 +226,47 @@ async def stack_search(c: Gojo, m: Message):
225
  return
226
 
227
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
228
  __PLUGIN__ = "search"
229
 
230
 
@@ -241,7 +283,7 @@ __HELP__ = """
241
  • /google `<query>` : Search the google for the given query.
242
  • /anime `<query>` : Search myanimelist for the given query.
243
  • /stack `<query>` : Search stackoverflow for the given query.
244
-
245
 
246
  **Example:**
247
  `/google pyrogram`: return top 5 reuslts.
 
1
  from traceback import format_exc
2
 
3
+ from pyrogram.types import InputMediaPhoto, Message
4
  from search_engine_parser.core.engines.google import Search as GoogleSearch
5
  from search_engine_parser.core.engines.myanimelist import Search as AnimeSearch
6
  from search_engine_parser.core.engines.stackoverflow import \
 
11
  from Powers import LOGGER, SUPPORT_CHANNEL
12
  from Powers.bot_class import Gojo
13
  from Powers.utils.custom_filters import command
14
+ from Powers.utils.http_helper import *
15
  from Powers.utils.kbhelpers import ikb
16
 
17
  #have to add youtube
 
226
  return
227
 
228
 
229
+ async def getText(message: Message):
230
+ # Credits: https://t.me/NovaXMod
231
+ # https://t.me/NovaXMod/98
232
+ """Extract Text From Commands"""
233
+ text_to_return = message.text
234
+ if message.text is None:
235
+ return None
236
+ if " " in text_to_return:
237
+ try:
238
+ return message.text.split(None, 1)[1]
239
+ except IndexError:
240
+ return None
241
+ except Exception:
242
+ return None
243
+ else:
244
+ return None
245
+
246
+ @Gojo.on_message(command(["images","imgs"]))
247
+ async def get_image_search(_, m: Message):
248
+ # Credits: https://t.me/NovaXMod
249
+ # https://t.me/NovaXMod/98
250
+ query = await getText(m)
251
+ if not query:
252
+ await m.reply_text("**USAGE**\n /images [query]")
253
+ return
254
+ text = query.replace(" ", "%")
255
+ resp = get(f"https://nova-api-seven.vercel.app/api/images?name={text}")
256
+ if type(resp) == int:
257
+ await m.reply_text(f"Status code: {resp}\nUnable find any results regarding your query :/")
258
+ return
259
+ image_urls = resp.get("image_urls", [])[:10]
260
+ ab = await m.reply_text("Getting Your Images... Wait A Min..\nCredits: @NovaXMod")
261
+ Ok = []
262
+ for a in image_urls:
263
+ Ok.append(InputMediaPhoto(a))
264
+ try:
265
+ await m.reply_media_group(media=Ok)
266
+ await ab.delete()
267
+ except Exception:
268
+ await ab.edit("Error occurred while sending images. Please try again.")
269
+
270
  __PLUGIN__ = "search"
271
 
272
 
 
283
  • /google `<query>` : Search the google for the given query.
284
  • /anime `<query>` : Search myanimelist for the given query.
285
  • /stack `<query>` : Search stackoverflow for the given query.
286
+ • /images (/imgs) `<query>` : Get the images regarding to your query
287
 
288
  **Example:**
289
  `/google pyrogram`: return top 5 reuslts.
Powers/plugins/start.py CHANGED
@@ -126,7 +126,7 @@ async def start(c: Gojo, m: Message):
126
  try:
127
  cpt = f"""
128
  Hey [{m.from_user.first_name}](http://t.me/{m.from_user.username})! I am Gojo ✨.
129
- I'm here to help you manage your groups!
130
  Hit /help to find out more about how to use me in my full potential!
131
 
132
  Join my [News Channel](https://t.me/gojo_bots_network) to get information on all the latest updates."""
@@ -165,7 +165,7 @@ async def start_back(_, q: CallbackQuery):
165
  try:
166
  cpt = f"""
167
  Hey [{q.from_user.first_name}](http://t.me/{q.from_user.username})! I am Gojo ✨.
168
- I'm here to help you manage your groups!
169
  Hit /help to find out more about how to use me in my full potential!
170
 
171
  Join my [News Channel](http://t.me/gojo_bots_network) to get information on all the latest updates."""
@@ -187,7 +187,7 @@ async def commands_menu(_, q: CallbackQuery):
187
  try:
188
  cpt = f"""
189
  Hey **[{q.from_user.first_name}](http://t.me/{q.from_user.username})**! I am Gojo✨.
190
- I'm here to help you manage your groups!
191
  Commands available:
192
  × /start: Start the bot
193
  × /help: Give's you this message.
@@ -260,7 +260,7 @@ async def help_menu(_, m: Message):
260
  keyboard = ikb(ou, True)
261
  msg = f"""
262
  Hey **[{m.from_user.first_name}](http://t.me/{m.from_user.username})**!I am Gojo✨.
263
- I'm here to help you manage your groups!
264
  Commands available:
265
  × /start: Start the bot
266
  × /help: Give's you this message."""
 
126
  try:
127
  cpt = f"""
128
  Hey [{m.from_user.first_name}](http://t.me/{m.from_user.username})! I am Gojo ✨.
129
+ I'm here to help you manage your group(s)!
130
  Hit /help to find out more about how to use me in my full potential!
131
 
132
  Join my [News Channel](https://t.me/gojo_bots_network) to get information on all the latest updates."""
 
165
  try:
166
  cpt = f"""
167
  Hey [{q.from_user.first_name}](http://t.me/{q.from_user.username})! I am Gojo ✨.
168
+ I'm here to help you manage your group(s)!
169
  Hit /help to find out more about how to use me in my full potential!
170
 
171
  Join my [News Channel](http://t.me/gojo_bots_network) to get information on all the latest updates."""
 
187
  try:
188
  cpt = f"""
189
  Hey **[{q.from_user.first_name}](http://t.me/{q.from_user.username})**! I am Gojo✨.
190
+ I'm here to help you manage your group(s)!
191
  Commands available:
192
  × /start: Start the bot
193
  × /help: Give's you this message.
 
260
  keyboard = ikb(ou, True)
261
  msg = f"""
262
  Hey **[{m.from_user.first_name}](http://t.me/{m.from_user.username})**!I am Gojo✨.
263
+ I'm here to help you manage your group(s)!
264
  Commands available:
265
  × /start: Start the bot
266
  × /help: Give's you this message."""
Powers/plugins/stickers.py CHANGED
@@ -1,4 +1,3 @@
1
- import imghdr
2
  import os
3
  from asyncio import gather
4
  from random import choice
@@ -94,7 +93,7 @@ async def kang(c:Gojo, m: Message):
94
  try:
95
  if is_requ or m.reply_to_message.video or m.reply_to_message.photo or (m.reply_to_message.document and m.reply_to_message.document.mime_type.split("/")[0]=="image"):
96
  sizee = (await get_file_size(m.reply_to_message)).split()
97
- if (sizee[1] == "mb" and sizee > 10) or sizee[1] == "gb":
98
  await m.reply_text("File size is too big")
99
  return
100
  path = await m.reply_to_message.download()
@@ -113,11 +112,17 @@ async def kang(c:Gojo, m: Message):
113
  LOGGER.error(format_exc())
114
  return
115
  try:
116
- if is_requ or not m.reply_to_message.sticker or m.reply_to_message.animation or m.reply_to_message.video or (m.reply_to_message.document and m.reply_to_message.document.mime_type.split("/")[0] == "video"):
117
  # telegram doesn't allow animated and video sticker to be kanged as we do for normal stickers
118
  if m.reply_to_message.animation or m.reply_to_message.video or (m.reply_to_message.document and m.reply_to_message.document.mime_type.split("/")[0] == "video"):
119
- path = m.reply_to_message.download()
120
- path = Vsticker(path)
 
 
 
 
 
 
121
  sticker = await create_sticker(
122
  await upload_document(
123
  c, path, m.chat.id
@@ -145,7 +150,7 @@ async def kang(c:Gojo, m: Message):
145
  # Find an available pack & add the sticker to the pack; create a new pack if needed
146
  # Would be a good idea to cache the number instead of searching it every single time...
147
  kang_lim = 120
148
- st_in = m.reply_to_message.sticker
149
  st_type = "norm"
150
  is_anim = is_vid = False
151
  if st_in:
@@ -157,6 +162,19 @@ async def kang(c:Gojo, m: Message):
157
  st_type = "vid"
158
  kang_lim = 50
159
  is_vid = True
 
 
 
 
 
 
 
 
 
 
 
 
 
160
  packnum = 0
161
  limit = 0
162
  volume = 0
@@ -282,34 +300,41 @@ async def memify_it(c: Gojo, m: Message):
282
  @Gojo.on_message(command(["getsticker","getst"]))
283
  async def get_sticker_from_file(c: Gojo, m: Message):
284
  Caption = f"Converted by:\n@{Config.BOT_USERNAME}"
285
- if not m.reply_to_message:
 
286
  await m.reply_text("Reply to a sticker or file")
287
  return
288
- repl = m.reply_to_message
289
  to_vid = False
290
- if not (repl.sticker.is_animated or repl.video or repl.sticker or repl.photo or (repl.document and repl.document.mime_type.split("/")[0] in ["image","video"])):
291
- await m.reply_text("I only support conversion of plain stickers and images for now")
292
  return
293
- if repl.video or (repl.document and repl.document.mime_type.split("/")[0]=="video"):
294
  to_vid = True
295
  x = await m.reply_text("Converting...")
296
- upp = await repl.download()
297
  if repl.sticker:
298
  if repl.sticker.is_animated:
 
299
  up = tgs_to_gif(upp,True)
300
  await x.delete()
301
  await m.reply_animation(up,caption=Caption)
 
 
302
  elif repl.sticker.is_video:
303
- up = webm_to_gif(upp)
 
304
  await x.delete()
305
  await m.reply_animation(up,caption=Caption)
 
 
306
  else:
 
307
  up = toimage(upp,is_direc=True)
308
  await x.delete()
309
  await m.reply_photo(up,caption=Caption)
310
  os.remove(up)
311
  return
312
  elif repl.photo:
 
313
  up = tosticker(upp,is_direc=True)
314
  await x.delete()
315
  await m.reply_sticker(up)
@@ -317,9 +342,11 @@ async def get_sticker_from_file(c: Gojo, m: Message):
317
  return
318
 
319
  elif to_vid:
320
- up = Vsticker(upp)
321
  await x.delete()
322
  await m.reply_sticker(up)
 
 
323
 
324
 
325
  __PLUGIN__ = "sticker"
@@ -331,7 +358,7 @@ __HELP__ = """
331
  **User Commands:**
332
  • /kang (/steal) <emoji>: Reply to a sticker or any supported media
333
  • /stickerinfo (/stinfo) : Reply to any sticker to get it's info
334
- • /getsticker (/getst) : Get sticker as photo or vice versa.
335
  • /stickerid (/stid) : Reply to any sticker to get it's id
336
  • /mmf <your text>: Reply to a normal sticker or a photo or video file to memify it. If you want to right text at bottom use `;right your message`
337
  ■ For e.g.
 
 
1
  import os
2
  from asyncio import gather
3
  from random import choice
 
93
  try:
94
  if is_requ or m.reply_to_message.video or m.reply_to_message.photo or (m.reply_to_message.document and m.reply_to_message.document.mime_type.split("/")[0]=="image"):
95
  sizee = (await get_file_size(m.reply_to_message)).split()
96
+ if (sizee[1] == "mb" and int(sizee[0]) > 10) or sizee[1] == "gb":
97
  await m.reply_text("File size is too big")
98
  return
99
  path = await m.reply_to_message.download()
 
112
  LOGGER.error(format_exc())
113
  return
114
  try:
115
+ if is_requ or m.reply_to_message.animation or m.reply_to_message.video or (m.reply_to_message.document and m.reply_to_message.document.mime_type.split("/")[0] == "video"):
116
  # telegram doesn't allow animated and video sticker to be kanged as we do for normal stickers
117
  if m.reply_to_message.animation or m.reply_to_message.video or (m.reply_to_message.document and m.reply_to_message.document.mime_type.split("/")[0] == "video"):
118
+ path = await Vsticker(c, m.reply_to_message)
119
+ SIZE = os.path.getsize(path)
120
+ if SIZE > 261120:
121
+ await m.reply_text("File is too big")
122
+ os.remove(path)
123
+ return
124
+ else:
125
+ path = await m.reply_to_message.download()
126
  sticker = await create_sticker(
127
  await upload_document(
128
  c, path, m.chat.id
 
150
  # Find an available pack & add the sticker to the pack; create a new pack if needed
151
  # Would be a good idea to cache the number instead of searching it every single time...
152
  kang_lim = 120
153
+ st_in = m.reply_to_message.sticker
154
  st_type = "norm"
155
  is_anim = is_vid = False
156
  if st_in:
 
162
  st_type = "vid"
163
  kang_lim = 50
164
  is_vid = True
165
+ elif m.reply_to_message.document:
166
+ if m.reply_to_message.document.mime_type in ["application/x-bad-tgsticker", "application/x-tgsticker"]:
167
+ st_type = "ani"
168
+ kang_lim = 50
169
+ is_anim = True
170
+ elif m.reply_to_message.document.mime_type == "video/webm":
171
+ st_type = "vid"
172
+ kang_lim = 50
173
+ is_vid = True
174
+ elif m.reply_to_message.video or m.reply_to_message.animation or (m.reply_to_message.document and m.reply_to_message.document.mime_type.split("/")[0] == "video"):
175
+ st_type = "vid"
176
+ kang_lim = 50
177
+ is_vid = True
178
  packnum = 0
179
  limit = 0
180
  volume = 0
 
300
  @Gojo.on_message(command(["getsticker","getst"]))
301
  async def get_sticker_from_file(c: Gojo, m: Message):
302
  Caption = f"Converted by:\n@{Config.BOT_USERNAME}"
303
+ repl = m.reply_to_message
304
+ if not repl:
305
  await m.reply_text("Reply to a sticker or file")
306
  return
 
307
  to_vid = False
308
+ if not (repl.animation or repl.video or repl.sticker or repl.photo or (repl.document and repl.document.mime_type.split("/")[0] in ["image","video"])):
309
+ await m.reply_text("I only support conversion of plain stickers, images, videos and animation for now")
310
  return
311
+ if repl.animation or repl.video or (repl.document and repl.document.mime_type.split("/")[0]=="video"):
312
  to_vid = True
313
  x = await m.reply_text("Converting...")
 
314
  if repl.sticker:
315
  if repl.sticker.is_animated:
316
+ upp = await repl.download()
317
  up = tgs_to_gif(upp,True)
318
  await x.delete()
319
  await m.reply_animation(up,caption=Caption)
320
+ os.remove(up)
321
+ return
322
  elif repl.sticker.is_video:
323
+ upp = await repl.download()
324
+ up = await webm_to_gif(upp)
325
  await x.delete()
326
  await m.reply_animation(up,caption=Caption)
327
+ os.remove(up)
328
+ return
329
  else:
330
+ upp = await repl.download()
331
  up = toimage(upp,is_direc=True)
332
  await x.delete()
333
  await m.reply_photo(up,caption=Caption)
334
  os.remove(up)
335
  return
336
  elif repl.photo:
337
+ upp = await repl.download()
338
  up = tosticker(upp,is_direc=True)
339
  await x.delete()
340
  await m.reply_sticker(up)
 
342
  return
343
 
344
  elif to_vid:
345
+ up = await Vsticker(c,repl)
346
  await x.delete()
347
  await m.reply_sticker(up)
348
+ os.remove(up)
349
+ return
350
 
351
 
352
  __PLUGIN__ = "sticker"
 
358
  **User Commands:**
359
  • /kang (/steal) <emoji>: Reply to a sticker or any supported media
360
  • /stickerinfo (/stinfo) : Reply to any sticker to get it's info
361
+ • /getsticker (/getst) : Get sticker as photo, gif or vice versa.
362
  • /stickerid (/stid) : Reply to any sticker to get it's id
363
  • /mmf <your text>: Reply to a normal sticker or a photo or video file to memify it. If you want to right text at bottom use `;right your message`
364
  ■ For e.g.
Powers/plugins/utils.py CHANGED
@@ -14,6 +14,7 @@ from wikipedia.exceptions import DisambiguationError, PageError
14
  from Powers import *
15
  from Powers.bot_class import Gojo
16
  from Powers.database.users_db import Users
 
17
  from Powers.utils.clean_file import remove_markdown_and_html
18
  from Powers.utils.custom_filters import command
19
  from Powers.utils.extract_user import extract_user
@@ -418,7 +419,6 @@ async def reporting_query(c: Gojo, m: Message):
418
  await c.send_message(OWNER_ID,f"New bug report\n{ppost}",disable_web_page_preview=True)
419
  return
420
 
421
-
422
  __PLUGIN__ = "utils"
423
  _DISABLE_CMDS_ = ["paste", "wiki", "id", "gifid", "tr", "github", "git", "bug"]
424
  __alt_name__ = ["util", "misc", "tools"]
 
14
  from Powers import *
15
  from Powers.bot_class import Gojo
16
  from Powers.database.users_db import Users
17
+ from Powers.supports import get_support_staff
18
  from Powers.utils.clean_file import remove_markdown_and_html
19
  from Powers.utils.custom_filters import command
20
  from Powers.utils.extract_user import extract_user
 
419
  await c.send_message(OWNER_ID,f"New bug report\n{ppost}",disable_web_page_preview=True)
420
  return
421
 
 
422
  __PLUGIN__ = "utils"
423
  _DISABLE_CMDS_ = ["paste", "wiki", "id", "gifid", "tr", "github", "git", "bug"]
424
  __alt_name__ = ["util", "misc", "tools"]
Powers/plugins/warns.py CHANGED
@@ -6,11 +6,12 @@ from pyrogram.types import (CallbackQuery, ChatPermissions,
6
  InlineKeyboardButton, InlineKeyboardMarkup,
7
  Message)
8
 
9
- from Powers import LOGGER, TIME_ZONE, get_support_staff
10
  from Powers.bot_class import Gojo
11
  from Powers.database.rules_db import Rules
12
  from Powers.database.users_db import Users
13
  from Powers.database.warns_db import Warns, WarnSettings
 
14
  from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
15
  from Powers.utils.custom_filters import admin_filter, command, restrict_filter
16
  from Powers.utils.extract_user import extract_user
 
6
  InlineKeyboardButton, InlineKeyboardMarkup,
7
  Message)
8
 
9
+ from Powers import LOGGER, TIME_ZONE
10
  from Powers.bot_class import Gojo
11
  from Powers.database.rules_db import Rules
12
  from Powers.database.users_db import Users
13
  from Powers.database.warns_db import Warns, WarnSettings
14
+ from Powers.supports import get_support_staff
15
  from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
16
  from Powers.utils.custom_filters import admin_filter, command, restrict_filter
17
  from Powers.utils.extract_user import extract_user
Powers/plugins/watchers.py CHANGED
@@ -7,7 +7,7 @@ from pyrogram import filters
7
  from pyrogram.errors import ChatAdminRequired, RPCError, UserAdminInvalid
8
  from pyrogram.types import ChatPermissions, Message
9
 
10
- from Powers import LOGGER, MESSAGE_DUMP, get_support_staff
11
  from Powers.bot_class import Gojo
12
  from Powers.database.antispam_db import ANTISPAM_BANNED, GBan
13
  from Powers.database.approve_db import Approve
@@ -15,6 +15,7 @@ from Powers.database.blacklist_db import Blacklist
15
  from Powers.database.group_blacklist import BLACKLIST_CHATS
16
  from Powers.database.pins_db import Pins
17
  from Powers.database.warns_db import Warns, WarnSettings
 
18
  from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
19
  from Powers.utils.parser import mention_html
20
  from Powers.utils.regex_utils import regex_searcher
 
7
  from pyrogram.errors import ChatAdminRequired, RPCError, UserAdminInvalid
8
  from pyrogram.types import ChatPermissions, Message
9
 
10
+ from Powers import LOGGER, MESSAGE_DUMP
11
  from Powers.bot_class import Gojo
12
  from Powers.database.antispam_db import ANTISPAM_BANNED, GBan
13
  from Powers.database.approve_db import Approve
 
15
  from Powers.database.group_blacklist import BLACKLIST_CHATS
16
  from Powers.database.pins_db import Pins
17
  from Powers.database.warns_db import Warns, WarnSettings
18
+ from Powers.supports import get_support_staff
19
  from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
20
  from Powers.utils.parser import mention_html
21
  from Powers.utils.regex_utils import regex_searcher
Powers/plugins/web_con.py CHANGED
@@ -262,7 +262,7 @@ async def song_down_up(c: Gojo, m: Message):
262
  query = splited
263
  XnX = await m.reply_text("⏳")
264
  try:
265
- x = await youtube_downloader(c,m,query,is_direct,"a")
266
  await XnX.delete()
267
  return
268
  except KeyError:
 
262
  query = splited
263
  XnX = await m.reply_text("⏳")
264
  try:
265
+ await youtube_downloader(c,m,query,is_direct,"a")
266
  await XnX.delete()
267
  return
268
  except KeyError:
Powers/supports.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from Powers import DEV_USERS, OWNER_ID, SUDO_USERS, WHITELIST_USERS
2
+ from Powers.database.support_db import SUPPORTS
3
+
4
+
5
+ async def load_support_users():
6
+ support = SUPPORTS()
7
+ for i in DEV_USERS:
8
+ support.insert_support_user(int(i),"dev")
9
+ for i in SUDO_USERS:
10
+ support.insert_support_user(int(i),"sudo")
11
+ for i in WHITELIST_USERS:
12
+ support.insert_support_user(int(i),"whitelist")
13
+ return
14
+
15
+ def get_support_staff(want = "all"):
16
+ """
17
+ dev, sudo, whitelist, dev_level, sudo_level, all
18
+ """
19
+ support = SUPPORTS()
20
+ devs = support.get_particular_support("dev")
21
+ sudo = support.get_particular_support("sudo")
22
+ whitelist = support.get_particular_support("whitelist")
23
+
24
+ if want in ["dev","dev_level"]:
25
+ wanted = devs
26
+ elif want == "sudo":
27
+ wanted = sudo
28
+ elif want == "whitelist":
29
+ wanted = whitelist
30
+ elif want == "sudo_level":
31
+ wanted = sudo + devs
32
+ else:
33
+ wanted = list(set([int(OWNER_ID)] + devs + sudo + whitelist))
34
+
35
+ return wanted
Powers/utils/custom_filters.py CHANGED
@@ -9,8 +9,9 @@ from pyrogram.errors import RPCError, UserNotParticipant
9
  from pyrogram.filters import create
10
  from pyrogram.types import CallbackQuery, Message
11
 
12
- from Powers import OWNER_ID, get_support_staff
13
  from Powers.database.disable_db import Disabling
 
14
  from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
15
  from Powers.vars import Config
16
 
@@ -60,7 +61,7 @@ def command(
60
  if not text:
61
  return False
62
  regex = r"^[{prefix}](\w+)(@{bot_name})?(?: |$)(.*)".format(
63
- prefix="|".join(escape(x) for x in Config.PREFIX_HANDLER),
64
  bot_name=Config.BOT_USERNAME,
65
  )
66
  matches = compile_re(regex).search(text)
 
9
  from pyrogram.filters import create
10
  from pyrogram.types import CallbackQuery, Message
11
 
12
+ from Powers import OWNER_ID, PREFIX_HANDLER
13
  from Powers.database.disable_db import Disabling
14
+ from Powers.supports import get_support_staff
15
  from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
16
  from Powers.vars import Config
17
 
 
61
  if not text:
62
  return False
63
  regex = r"^[{prefix}](\w+)(@{bot_name})?(?: |$)(.*)".format(
64
+ prefix="|".join(escape(x) for x in PREFIX_HANDLER),
65
  bot_name=Config.BOT_USERNAME,
66
  )
67
  matches = compile_re(regex).search(text)
Powers/utils/extras.py CHANGED
@@ -695,6 +695,15 @@ StartPic = [
695
  "https://graph.org/file/6d18195f6e0e55af91228.png",
696
  "https://i.imgur.com/8l6cByn.jpg",
697
  "https://graph.org/file/259a92d3482fc8627fe68.png",
 
 
 
 
 
 
 
 
 
698
  ]
699
 
700
 
 
695
  "https://graph.org/file/6d18195f6e0e55af91228.png",
696
  "https://i.imgur.com/8l6cByn.jpg",
697
  "https://graph.org/file/259a92d3482fc8627fe68.png",
698
+ "https://graph.org/file/d328fb0a7e30b866979d5.jpg",
699
+ "https://graph.org/file/cdbc22231afb0937e1a5d.jpg",
700
+ "https://graph.org/file/dd32af83434be92ef4f72.jpg",
701
+ "https://graph.org/file/9c97627158a8b6c23cd8b.jpg",
702
+ "https://graph.org/file/0bd63482afbc2844cb77d.jpg",
703
+ "https://graph.org/file/798a33ee39bca8014116c.jpg",
704
+ "https://graph.org/file/d0beb924887f45ab1c84e.jpg",
705
+ "https://graph.org/file/9e92625135caffcadcbae.jpg",
706
+ "https://graph.org/file/f377781fe8a1fe09fea55.jpg",
707
  ]
708
 
709
 
Powers/utils/http_helper.py CHANGED
@@ -6,6 +6,8 @@ import requests
6
 
7
  def get(url: str, *args, **kwargs):
8
  resp = requests.get(url, *args, **kwargs)
 
 
9
  try:
10
  data = resp.json()
11
  except Exception:
@@ -24,6 +26,8 @@ def head(url: str, *args, **kwargs):
24
 
25
  def post(url: str, *args, **kwargs):
26
  resp = requests.post(url, *args, **kwargs)
 
 
27
  try:
28
  data = resp.json()
29
  except Exception:
 
6
 
7
  def get(url: str, *args, **kwargs):
8
  resp = requests.get(url, *args, **kwargs)
9
+ if resp.status_code != 200:
10
+ return resp.status_code
11
  try:
12
  data = resp.json()
13
  except Exception:
 
26
 
27
  def post(url: str, *args, **kwargs):
28
  resp = requests.post(url, *args, **kwargs)
29
+ if resp.status_code != 200:
30
+ return resp.status_code
31
  try:
32
  data = resp.json()
33
  except Exception:
Powers/utils/msg_types.py CHANGED
@@ -50,7 +50,7 @@ async def get_note_type(m: Message):
50
  data_type = Types.STICKER
51
 
52
  elif m.reply_to_message.document:
53
- if m.reply_to_message.document.mime_type == "application/x-bad-tgsticker":
54
  data_type = Types.ANIMATED_STICKER
55
  else:
56
  data_type = Types.DOCUMENT
@@ -118,7 +118,7 @@ async def get_filter_type(m: Message):
118
  data_type = Types.STICKER
119
 
120
  elif m.reply_to_message.document:
121
- if m.reply_to_message.document.mime_type == "application/x-bad-tgsticker":
122
  data_type = Types.ANIMATED_STICKER
123
  else:
124
  data_type = Types.DOCUMENT
@@ -158,15 +158,12 @@ async def get_filter_type(m: Message):
158
 
159
  async def get_wlcm_type(m: Message):
160
  """Get wlcm type."""
161
- if len(m.text.split()) <= 1:
162
- return None, None, None
163
-
164
  data_type = None
165
  content = None
166
  raw_text = m.text.markdown if m.text else m.caption.markdown
167
  args = raw_text.split(None, 1)
168
 
169
- if not m.reply_to_message and m.text and len(m.text.split()) >= 2:
170
  content = None
171
  text = m.text.markdown.split(None, 1)[1]
172
  data_type = Types.TEXT
@@ -183,15 +180,66 @@ async def get_wlcm_type(m: Message):
183
  if len(args) >= 1 and m.reply_to_message.text: # not caption, text
184
  data_type = Types.TEXT
185
 
186
- elif m.reply_to_message.sticker:
187
- content = m.reply_to_message.sticker.file_id
188
- data_type = Types.STICKER
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
189
 
190
  elif m.reply_to_message.document:
191
- if m.reply_to_message.document.mime_type == "application/x-bad-tgsticker":
192
- data_type = Types.ANIMATED_STICKER
193
- else:
194
- data_type = Types.DOCUMENT
195
  content = m.reply_to_message.document.file_id
196
 
197
  elif m.reply_to_message.photo:
 
50
  data_type = Types.STICKER
51
 
52
  elif m.reply_to_message.document:
53
+ if m.reply_to_message.document.mime_type in ["application/x-bad-tgsticker", "application/x-tgsticker"]:
54
  data_type = Types.ANIMATED_STICKER
55
  else:
56
  data_type = Types.DOCUMENT
 
118
  data_type = Types.STICKER
119
 
120
  elif m.reply_to_message.document:
121
+ if m.reply_to_message.document.mime_type in ["application/x-bad-tgsticker", "application/x-tgsticker"]:
122
  data_type = Types.ANIMATED_STICKER
123
  else:
124
  data_type = Types.DOCUMENT
 
158
 
159
  async def get_wlcm_type(m: Message):
160
  """Get wlcm type."""
 
 
 
161
  data_type = None
162
  content = None
163
  raw_text = m.text.markdown if m.text else m.caption.markdown
164
  args = raw_text.split(None, 1)
165
 
166
+ if not m.reply_to_message and m.text and len(m.text.strip().split()) >= 2:
167
  content = None
168
  text = m.text.markdown.split(None, 1)[1]
169
  data_type = Types.TEXT
 
180
  if len(args) >= 1 and m.reply_to_message.text: # not caption, text
181
  data_type = Types.TEXT
182
 
183
+ elif m.reply_to_message.document:
184
+ data_type = Types.DOCUMENT
185
+ content = m.reply_to_message.document.file_id
186
+
187
+ elif m.reply_to_message.photo:
188
+ content = m.reply_to_message.photo.file_id # last elem = best quality
189
+ data_type = Types.PHOTO
190
+
191
+ elif m.reply_to_message.audio:
192
+ content = m.reply_to_message.audio.file_id
193
+ data_type = Types.AUDIO
194
+
195
+ elif m.reply_to_message.voice:
196
+ content = m.reply_to_message.voice.file_id
197
+ data_type = Types.VOICE
198
+
199
+ elif m.reply_to_message.video:
200
+ content = m.reply_to_message.video.file_id
201
+ data_type = Types.VIDEO
202
+
203
+ elif m.reply_to_message.video_note:
204
+ content = m.reply_to_message.video_note.file_id
205
+ data_type = Types.VIDEO_NOTE
206
+
207
+ elif m.reply_to_message.animation:
208
+ content = m.reply_to_message.animation.file_id
209
+ data_type = Types.ANIMATION
210
+
211
+ else:
212
+ text = None
213
+ data_type = None
214
+ content = None
215
+
216
+ return text, data_type, content
217
+
218
+ async def get_afk_type(m: Message):
219
+ data_type = None
220
+ content = None
221
+ raw_text = m.text.markdown if m.text else m.caption.markdown
222
+ args = raw_text.split(None, 1)
223
+
224
+ if not m.reply_to_message and m.text and len(m.text.strip().split()) >= 2:
225
+ content = None
226
+ text = m.text.markdown.split(None, 1)[1]
227
+ data_type = Types.TEXT
228
+
229
+ elif m.reply_to_message:
230
+
231
+ if m.reply_to_message.text:
232
+ text = m.reply_to_message.text.markdown
233
+ elif m.reply_to_message.caption:
234
+ text = m.reply_to_message.caption.markdown
235
+ else:
236
+ text = ""
237
+
238
+ if len(args) >= 1 and m.reply_to_message.text: # not caption, text
239
+ data_type = Types.TEXT
240
 
241
  elif m.reply_to_message.document:
242
+ data_type = Types.DOCUMENT
 
 
 
243
  content = m.reply_to_message.document.file_id
244
 
245
  elif m.reply_to_message.photo:
Powers/utils/sticker_help.py CHANGED
@@ -8,6 +8,7 @@ from typing import List, Tuple
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
 
@@ -118,7 +119,7 @@ async def tgs_to_gif(file, tgs=False, video=False):
118
  cmd = f"ffmpeg -i '{file}' -c copy 'gojo_satoru.gif'"
119
  await runcmd(cmd)
120
  os.remove(file)
121
- return 'hellbot.gif'
122
 
123
  async def webm_to_gif(file):
124
  cmd = f"ffmpeg -i '{file}' 'goJo.gif'"
@@ -126,13 +127,18 @@ async def webm_to_gif(file):
126
  os.remove(file)
127
  return "goJo.gif"
128
 
129
- async def Vsticker(file: str):
130
- _width_ = file.file.width
131
- _height_ = file.file.height
 
 
 
 
132
  if _height_ > _width_:
133
  _height_, _width_ = (512, -1)
134
  else:
135
  _height_, _width_ = (-1, 512)
 
136
  await runcmd(
137
  f"ffmpeg -to 00:00:02.900 -i '{file}' -vf scale={_width_}:{_height_} -c:v libvpx-vp9 -crf 30 -b:v 560k -maxrate 560k -bufsize 256k -an 'VideoSticker.webm'"
138
  )
 
8
  from PIL import Image, ImageDraw, ImageFont
9
  from pyrogram import errors, raw
10
  from pyrogram.file_id import FileId
11
+ from pyrogram.types import Message
12
 
13
  from Powers.bot_class import Gojo
14
 
 
119
  cmd = f"ffmpeg -i '{file}' -c copy 'gojo_satoru.gif'"
120
  await runcmd(cmd)
121
  os.remove(file)
122
+ return 'gojo_satoru.gif'
123
 
124
  async def webm_to_gif(file):
125
  cmd = f"ffmpeg -i '{file}' 'goJo.gif'"
 
127
  os.remove(file)
128
  return "goJo.gif"
129
 
130
+ async def Vsticker(c: Gojo, file: Message):
131
+ if file.animation:
132
+ file = file.animation
133
+ elif file.video:
134
+ file = file.video
135
+ _width_ = file.width
136
+ _height_ = file.height
137
  if _height_ > _width_:
138
  _height_, _width_ = (512, -1)
139
  else:
140
  _height_, _width_ = (-1, 512)
141
+ file = await c.download_media(file)
142
  await runcmd(
143
  f"ffmpeg -to 00:00:02.900 -i '{file}' -vf scale={_width_}:{_height_} -c:v libvpx-vp9 -crf 30 -b:v 560k -maxrate 560k -bufsize 256k -an 'VideoSticker.webm'"
144
  )
Powers/utils/web_helpers.py CHANGED
@@ -3,10 +3,11 @@ import os
3
  from traceback import format_exc
4
  from urllib import parse
5
 
6
- import yt_dlp
7
  from pyrogram.types import InlineKeyboardButton as IKB
8
  from pyrogram.types import InlineKeyboardMarkup as IKM
9
  from pyrogram.types import Message
 
 
10
  from youtubesearchpython.__future__ import Video, VideosSearch
11
 
12
  from Powers.bot_class import LOGGER, MESSAGE_DUMP, Gojo
@@ -24,6 +25,12 @@ async def get_file_size(file: Message):
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"
@@ -36,6 +43,13 @@ async def get_file_size(file: Message):
36
  return f"{round(size)} gb"
37
 
38
 
 
 
 
 
 
 
 
39
 
40
  # Gets yt result of given query.
41
  async def song_search(query, is_direct, max_results=1):
@@ -49,9 +63,7 @@ async def song_search(query, is_direct, max_results=1):
49
  videos = VideosSearch(query,max_results)
50
  results = await videos.next()
51
  except Exception as e:
52
- LOGGER.error(e)
53
- LOGGER.error(format_exc())
54
- return e
55
 
56
  nums = 1
57
  for i in results["result"]:
@@ -70,7 +82,8 @@ async def song_search(query, is_direct, max_results=1):
70
  "views": i["viewCount"]["short"],
71
  "channel": i["channel"]["link"],
72
  "duration": i["accessibility"]['duration'],
73
- "thumbnail": i["richThumbnail"],
 
74
  "published": i["publishedTime"],
75
  "uploader": i ["channel"]["name"]
76
  }
@@ -80,7 +93,7 @@ async def song_search(query, is_direct, max_results=1):
80
  pass
81
  return yt_dict
82
 
83
- song_opts = {
84
  "format": "bestaudio",
85
  "addmetadata": True,
86
  "key": "FFmpegMetadata",
@@ -117,20 +130,20 @@ video_opts = {
117
  "outtmpl": "%(id)s.mp4",
118
  "logtostderr": False,
119
  "quiet": True,
120
- }
121
 
122
 
123
 
124
  async def youtube_downloader(c:Gojo,m:Message,query:str,is_direct:bool,type_:str):
125
  if type_ == "a":
126
- opts = song_opts
127
  video = False
128
  song = True
129
  elif type_ == "v":
130
- opts = video_opts
131
  video = True
132
  song = False
133
- ydl = yt_dlp.YoutubeDL(opts)
134
  dicti = await song_search(query, is_direct,1)
135
  if not dicti and type(dicti) != str:
136
  await m.reply_text("File with duration less than or equals to 5 minutes is allowed only")
@@ -140,33 +153,27 @@ async def youtube_downloader(c:Gojo,m:Message,query:str,is_direct:bool,type_:str
140
  try:
141
  query = dicti[1]['link']
142
  except KeyError:
143
- z = "KeyError"
144
- return z
145
-
146
  f_name = dicti["title"]
147
  views = dicti["views"]
148
  up_url = dicti["channel"]
149
  uploader = dicti["uploader"]
 
150
  thumb = dicti["thumbnail"]
151
- published_on = dicti["publishedON"]
152
-
153
- FILE = ydl.extract_info(query,download=video)
 
154
  url = query
155
- thumb_ = await c.send_photo(MESSAGE_DUMP, thumb)
156
  thumb = await thumb_.download()
157
  await thumb_.delete()
158
- if song:
159
- f_down = ydl.prepare_filename(FILE)
160
- f_path = f"{f_down}.mp3"
161
- ydl.download([query])
162
- ext = ".mp3"
163
- elif video:
164
- f_path = open(f"{FILE['id']}.mp4","rb")
165
- ext = ".mp4"
166
  cap = f"""
167
  ⤷ Name: `{f_name}`
 
168
  ⤷ Views: `{views}`
169
- ⤷ Published date: `{published_on}`
170
  """
171
  kb = IKM(
172
  [
@@ -178,20 +185,21 @@ async def youtube_downloader(c:Gojo,m:Message,query:str,is_direct:bool,type_:str
178
  ]
179
  ]
180
  )
181
-
182
- file_path = f_name.strip() + ext
183
- os.rename(f_path,file_path)
184
-
185
-
186
- if video:
187
- await m.reply_video(file_path,caption=cap,reply_markup=kb,duration=int(FILE['duration']))
188
  os.remove(file_path)
189
  os.remove(thumb)
190
  return
191
- elif song:
192
- await m.reply_audio(file_path,caption=cap,reply_markup=kb,duration=int(FILE['duration']),thumb=thumb,title=f_name)
193
- os.remove(f_path)
 
 
 
194
  os.remove(thumb)
195
- return
196
-
197
-
 
3
  from traceback import format_exc
4
  from urllib import parse
5
 
 
6
  from pyrogram.types import InlineKeyboardButton as IKB
7
  from pyrogram.types import InlineKeyboardMarkup as IKM
8
  from pyrogram.types import Message
9
+ # import yt_dlp
10
+ from pytube import YouTube
11
  from youtubesearchpython.__future__ import Video, VideosSearch
12
 
13
  from Powers.bot_class import LOGGER, MESSAGE_DUMP, Gojo
 
25
  size = file.audio.file_size/1024
26
  elif file.sticker:
27
  size = file.sticker.file_size/1024
28
+ elif file.animation:
29
+ size = file.animation.file_size/1024
30
+ elif file.voice:
31
+ size = file.voice.file_size/1024
32
+ elif file.video_note:
33
+ size = file.video_note.file_size/1024
34
 
35
  if size <= 1024:
36
  return f"{round(size)} kb"
 
43
  return f"{round(size)} gb"
44
 
45
 
46
+ def get_duration_in_sec(dur: str):
47
+ duration = dur.split(":")
48
+ if len(duration) == 2:
49
+ dur = (int(duration[0]) * 60) + int(duration[1])
50
+ else:
51
+ dur = int(duration[0])
52
+ return dur
53
 
54
  # Gets yt result of given query.
55
  async def song_search(query, is_direct, max_results=1):
 
63
  videos = VideosSearch(query,max_results)
64
  results = await videos.next()
65
  except Exception as e:
66
+ print(e)
 
 
67
 
68
  nums = 1
69
  for i in results["result"]:
 
82
  "views": i["viewCount"]["short"],
83
  "channel": i["channel"]["link"],
84
  "duration": i["accessibility"]['duration'],
85
+ "DURATION": i["duration"],
86
+ "thumbnail": i["richThumbnail"]["url"],
87
  "published": i["publishedTime"],
88
  "uploader": i ["channel"]["name"]
89
  }
 
93
  pass
94
  return yt_dict
95
 
96
+ """song_opts = {
97
  "format": "bestaudio",
98
  "addmetadata": True,
99
  "key": "FFmpegMetadata",
 
130
  "outtmpl": "%(id)s.mp4",
131
  "logtostderr": False,
132
  "quiet": True,
133
+ }"""
134
 
135
 
136
 
137
  async def youtube_downloader(c:Gojo,m:Message,query:str,is_direct:bool,type_:str):
138
  if type_ == "a":
139
+ # opts = song_opts
140
  video = False
141
  song = True
142
  elif type_ == "v":
143
+ # opts = video_opts
144
  video = True
145
  song = False
146
+ # ydl = yt_dlp.YoutubeDL(opts)
147
  dicti = await song_search(query, is_direct,1)
148
  if not dicti and type(dicti) != str:
149
  await m.reply_text("File with duration less than or equals to 5 minutes is allowed only")
 
153
  try:
154
  query = dicti[1]['link']
155
  except KeyError:
156
+ return
157
+ yt = YouTube(query)
158
+ dicti = dicti[1]
159
  f_name = dicti["title"]
160
  views = dicti["views"]
161
  up_url = dicti["channel"]
162
  uploader = dicti["uploader"]
163
+ dura = dicti["duration"]
164
  thumb = dicti["thumbnail"]
165
+ vid_dur = get_duration_in_sec(dicti["DURATION"])
166
+ published_on = dicti["published"]
167
+ thumb_ = await c.send_photo(-1001586309125,thumb)
168
+ # FILE = ydl.extract_info(query,download=video)
169
  url = query
 
170
  thumb = await thumb_.download()
171
  await thumb_.delete()
 
 
 
 
 
 
 
 
172
  cap = f"""
173
  ⤷ Name: `{f_name}`
174
+ ⤷ Duration: `{dura}`
175
  ⤷ Views: `{views}`
176
+ ⤷ Published: `{published_on}`
177
  """
178
  kb = IKM(
179
  [
 
185
  ]
186
  ]
187
  )
188
+ if song:
189
+ audio_stream= yt.streams.filter(only_audio=True).first()
190
+ f_path = audio_stream.download("/youtube_downloads")
191
+ file_path = f"/youtube_downloads/{f_name.strip()}.mp3"
192
+ os.rename(f_path,file_path)
193
+ await m.reply_audio(file_path,caption=cap,reply_markup=kb,duration=vid_dur,thumb=thumb,title=f_name)
194
+ os.remove(f_path)
195
  os.remove(file_path)
196
  os.remove(thumb)
197
  return
198
+ elif video:
199
+ video_stream = yt.streams.get_highest_resolution()
200
+ video_stream.download("/youtube_downloads",f"{f_name}.mp4")
201
+ file_path = f"/youtube_downloads/{f_name}.mp4"
202
+ await m.reply_video(file_path,caption=cap,reply_markup=kb,duration=vid_dur,thumb=thumb)
203
+ os.remove(file_path)
204
  os.remove(thumb)
205
+ return
 
 
Version/version 2.2.0.md ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # V 2.1.1
2
+ ### Changes made:
3
+ - Added `AFK` support.
4
+ - Added `Captcha verification` for new joined members.
5
+ - Added support for `join request` in the chat.
6
+ - Now `lock types` will be stored in database.
7
+ - Improved **youtube support** to provide best quality.
8
+ - Now you can kang `video sticker` by replying to **videos** and **animations**.
9
+ - Added few commands for **devs**.
10
+ - Improved stability and few minor improvements.
11
+ - Few bug fixes.
12
+ - Bug known: 0
13
+ - Deployed and tested locally
14
+
15
+ ## Report issues [here](https://github.com/Gojo-Bots/Gojo_Satoru/issues/new/choose) if find any.
16
+
17
+ ## Give ideas [here](https://github.com/Gojo-Bots/Gojo_Satoru/discussions/new?category=ideas) for next update.
18
+
19
+ ## Trying our best to give the best
20
+
21
+ ## Regards 🧑‍💻: [Captain D. Ezio](https://github.com/iamgojoof6eyes)