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

New update v2.1.0

Browse files
Powers/__init__.py CHANGED
@@ -9,8 +9,14 @@ from time import time
9
  from traceback import format_exc
10
 
11
  import lyricsgenius
 
 
12
 
13
- LOG_DATETIME = datetime.now().strftime("%d_%m_%Y-%H_%M_%S")
 
 
 
 
14
  LOGDIR = f"{__name__}/logs"
15
 
16
  # Make Logs directory if it does not exixts
@@ -59,6 +65,12 @@ LOGGER.info(f"Version: {Config.VERSION}")
59
  LOGGER.info(f"Owner: {str(Config.OWNER_ID)}")
60
  LOGGER.info("Source Code: https://github.com/Gojo-Bots/Gojo_Satoru\n")
61
  LOGGER.info("Checking lyrics genius api...")
 
 
 
 
 
 
62
  if Config.GENIUS_API_TOKEN:
63
  LOGGER.info("Found genius api token initialising client")
64
  genius_lyrics = lyricsgenius.Genius(
@@ -74,6 +86,19 @@ if Config.GENIUS_API_TOKEN:
74
  elif not Config.GENIUS_API_TOKEN:
75
  LOGGER.error("Genius api not found lyrics command will not work")
76
  is_genius_lyrics = False
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  # Account Related
78
  BOT_TOKEN = Config.BOT_TOKEN
79
  API_ID = Config.API_ID
@@ -105,6 +130,7 @@ DB_URI = Config.DB_URI
105
  DB_NAME = Config.DB_NAME
106
  NO_LOAD = Config.NO_LOAD
107
  WORKERS = Config.WORKERS
 
108
 
109
  # Prefixes
110
 
 
9
  from traceback import format_exc
10
 
11
  import lyricsgenius
12
+ import pytz
13
+ from telegraph import Telegraph
14
 
15
+ #time zone
16
+ TIME_ZONE = pytz.timezone(Config.TIME_ZONE)
17
+
18
+
19
+ LOG_DATETIME = datetime.now(TIME_ZONE).strftime("%d_%m_%Y-%H_%M_%S")
20
  LOGDIR = f"{__name__}/logs"
21
 
22
  # Make Logs directory if it does not exixts
 
65
  LOGGER.info(f"Owner: {str(Config.OWNER_ID)}")
66
  LOGGER.info("Source Code: https://github.com/Gojo-Bots/Gojo_Satoru\n")
67
  LOGGER.info("Checking lyrics genius api...")
68
+ LOGGER.info("Initialising telegraph client")
69
+ telegraph = Telegraph()
70
+ telegraph.create_account(Config.BOT_USERNAME)
71
+ LOGGER.info(f"Created telegraph client with name {Config.BOT_USERNAME}")
72
+
73
+ # API based clients
74
  if Config.GENIUS_API_TOKEN:
75
  LOGGER.info("Found genius api token initialising client")
76
  genius_lyrics = lyricsgenius.Genius(
 
86
  elif not Config.GENIUS_API_TOKEN:
87
  LOGGER.error("Genius api not found lyrics command will not work")
88
  is_genius_lyrics = False
89
+
90
+ is_audd = False
91
+ Audd = None
92
+ if Config.AuDD_API:
93
+ is_audd = True
94
+ Audd = Config.AuDD_API
95
+ LOGGER.info("Found Audd api")
96
+
97
+ is_rmbg = False
98
+ RMBG = None
99
+ if Config.RMBG_API:
100
+ is_rmbg = True
101
+ RMBG = Config.RMBG_API
102
  # Account Related
103
  BOT_TOKEN = Config.BOT_TOKEN
104
  API_ID = Config.API_ID
 
130
  DB_NAME = Config.DB_NAME
131
  NO_LOAD = Config.NO_LOAD
132
  WORKERS = Config.WORKERS
133
+ BDB_URI = Config.BDB_URI
134
 
135
  # Prefixes
136
 
Powers/database/antispam_db.py CHANGED
@@ -1,6 +1,7 @@
1
  from datetime import datetime
2
  from threading import RLock
3
 
 
4
  from Powers.database import MongoDB
5
 
6
  INSERTION_LOCK = RLock()
@@ -27,7 +28,7 @@ class GBan(MongoDB):
27
  return self.update_gban_reason(user_id, reason)
28
 
29
  # If not already gbanned, then add to gban
30
- time_rn = datetime.now()
31
  return self.insert_one(
32
  {
33
  "_id": user_id,
 
1
  from datetime import datetime
2
  from threading import RLock
3
 
4
+ from Powers import TIME_ZONE as TZ
5
  from Powers.database import MongoDB
6
 
7
  INSERTION_LOCK = RLock()
 
28
  return self.update_gban_reason(user_id, reason)
29
 
30
  # If not already gbanned, then add to gban
31
+ time_rn = datetime.now(TZ)
32
  return self.insert_one(
33
  {
34
  "_id": user_id,
Powers/database/giveaway_db.py DELETED
@@ -1,110 +0,0 @@
1
- from threading import RLock
2
- from traceback import format_exc
3
-
4
- from Powers import LOGGER
5
- from Powers.database import MongoDB
6
- from Powers.utils.msg_types import Types
7
-
8
- INSERTION_LOCK = RLock()
9
-
10
- class GIVEAWAY(MongoDB):
11
- """Class to store giveaway info of the chat"""
12
- db_name = "giveaway"
13
-
14
- def __init__(self):
15
- super().__init__(self.db_name)
16
-
17
- def save_give(
18
- self,
19
- chat_id:int, # Chat id for in which user want to do giveaway
20
- group_id:int, # entries chat id
21
- user_id: int, # User id of the person who have started the giveaway
22
- is_new:int=0, # Can old user vote? 0 for yes 1 for no
23
- entries:int=1, # Entries are allowed? 0 for no 1 for yes
24
- give:int = 1, # Giveaway is on or not? 1 for on 0 for off
25
- force_c:bool = False # Force change the info
26
- ):
27
- with INSERTION_LOCK:
28
- curr = self.find_one({"user_id":user_id})
29
- if curr and not force_c:
30
- return False
31
- else:
32
- if force_c:
33
- self.delete_one({"user_id":user_id,})
34
- self.insert_one(
35
- {
36
- "chat_id":chat_id,
37
- "where":group_id,
38
- "user_id":user_id,
39
- "is_new":is_new,
40
- "entries":entries,
41
- "is_give":give
42
- }
43
- )
44
- return True
45
-
46
- def give_info(self,group_id = 0, u_id = 0):
47
- with INSERTION_LOCK:
48
- if u_id and group_id:
49
- curr = self.find_one({"where":group_id, "user_id":u_id})
50
- if curr:
51
- return curr
52
- else:
53
- curr = self.find_one({"chat_id":group_id, "user_id":u_id})
54
- if curr:
55
- return curr
56
- else:
57
- return False
58
- elif u_id:
59
- curr = self.find_one({"user_id":u_id})
60
- if curr:
61
- return curr
62
- elif group_id:
63
- curr = self.find_one({"where":group_id})
64
- if curr:
65
- return curr
66
- else:
67
- curr = self.find_one({"chat_id":group_id})
68
- if curr:
69
- return curr
70
- else:
71
- return False
72
-
73
- def is_vote(self, group_id):
74
- with INSERTION_LOCK:
75
- curr = self.find_one({"where": group_id})
76
- if curr:
77
- return True
78
- return False
79
-
80
- def start_vote(self,user_id, start=1):
81
- with INSERTION_LOCK:
82
- curr = self.find_one({"user_id":user_id})
83
- if curr:
84
- self.update({"user_id":user_id},{"is_give":start})
85
- return True
86
- return False
87
-
88
- def stop_entries(self,user_id,entries=0):
89
- with INSERTION_LOCK:
90
- curr = self.find_one({"user_id":user_id})
91
- if curr:
92
- self.update({"user_id":user_id},{"entries":entries})
93
- return True
94
- return False
95
-
96
- def update_is_old(self,user_id,old):
97
- with INSERTION_LOCK:
98
- curr = self.find_one({"user_id":user_id})
99
- if curr:
100
- self.update({"user_id":user_id},{"is_new":old})
101
- return True
102
- return False
103
-
104
- def stop_give(self, user_id, is_give=0):
105
- with INSERTION_LOCK:
106
- curr = self.find_one({"user_id":user_id})
107
- if curr:
108
- self.update({"user_id":user_id},{"is_give":is_give})
109
- return True
110
- return True
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Powers/database/greetings_db.py CHANGED
@@ -42,6 +42,21 @@ class Greetings(MongoDB):
42
  with INSERTION_LOCK:
43
  return self.chat_info["welcome_text"]
44
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  def get_goodbye_text(self):
46
  with INSERTION_LOCK:
47
  return self.chat_info["goodbye_text"]
@@ -63,19 +78,32 @@ class Greetings(MongoDB):
63
  with INSERTION_LOCK:
64
  return self.update({"_id": self.chat_id}, {"goodbye": status})
65
 
66
- def set_welcome_text(self, welcome_text: str):
67
  with INSERTION_LOCK:
68
- return self.update(
69
  {"_id": self.chat_id},
70
- {"welcome_text": welcome_text},
71
  )
 
 
 
 
 
72
 
73
- def set_goodbye_text(self, goodbye_text: str):
 
 
74
  with INSERTION_LOCK:
75
- return self.update(
76
  {"_id": self.chat_id},
77
- {"goodbye_text": goodbye_text},
78
  )
 
 
 
 
 
 
79
 
80
  def set_current_cleanservice_settings(self, status: bool):
81
  with INSERTION_LOCK:
@@ -126,6 +154,10 @@ class Greetings(MongoDB):
126
  "welcome_text": "Hey {first}, welcome to {chatname}!",
127
  "welcome": True,
128
  "goodbye": True,
 
 
 
 
129
  }
130
  self.insert_one(new_data)
131
  LOGGER.info(f"Initialized Greetings Document for chat {self.chat_id}")
 
42
  with INSERTION_LOCK:
43
  return self.chat_info["welcome_text"]
44
 
45
+ def get_welcome_media(self):
46
+ with INSERTION_LOCK:
47
+ return self.chat_info["welcome_media"]
48
+ def get_welcome_msgtype(self):
49
+ with INSERTION_LOCK:
50
+ return self.chat_info["welcome_mtype"]
51
+
52
+ def get_goodbye_msgtype(self):
53
+ with INSERTION_LOCK:
54
+ return self.chat_info["goodbye_mtype"]
55
+
56
+ def get_goodbye_media(self):
57
+ with INSERTION_LOCK:
58
+ return self.chat_info["goodbye_media"]
59
+
60
  def get_goodbye_text(self):
61
  with INSERTION_LOCK:
62
  return self.chat_info["goodbye_text"]
 
78
  with INSERTION_LOCK:
79
  return self.update({"_id": self.chat_id}, {"goodbye": status})
80
 
81
+ def set_welcome_text(self, welcome_text: str, mtype,media=None):
82
  with INSERTION_LOCK:
83
+ self.update(
84
  {"_id": self.chat_id},
85
+ {"welcome_text": welcome_text,"welcome_mtype":mtype},
86
  )
87
+ if media:
88
+ self.update(
89
+ {"_id": self.chat_id},
90
+ {"welcome_media": media,"welcome_mtype":mtype}
91
+ )
92
 
93
+ return
94
+
95
+ def set_goodbye_text(self, goodbye_text: str,mtype,media=None):
96
  with INSERTION_LOCK:
97
+ self.update(
98
  {"_id": self.chat_id},
99
+ {"goodbye_text": goodbye_text,"goodbye_mtype":mtype},
100
  )
101
+ if media:
102
+ self.update(
103
+ {"_id": self.chat_id},
104
+ {"goodbye_media": media,"goodbye_mtype":mtype}
105
+ )
106
+ return
107
 
108
  def set_current_cleanservice_settings(self, status: bool):
109
  with INSERTION_LOCK:
 
154
  "welcome_text": "Hey {first}, welcome to {chatname}!",
155
  "welcome": True,
156
  "goodbye": True,
157
+ "welcome_media":None,
158
+ "welcome_mtype":None,
159
+ "goodbye_media":None,
160
+ "goodbye_mtype":None
161
  }
162
  self.insert_one(new_data)
163
  LOGGER.info(f"Initialized Greetings Document for chat {self.chat_id}")
Powers/plugins/__init__.py CHANGED
@@ -12,3 +12,20 @@ async def all_plugins():
12
  if isfile(f) and f.endswith(".py") and not f.endswith("__init__.py")
13
  ]
14
  return sorted(all_plugs)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  if isfile(f) and f.endswith(".py") and not f.endswith("__init__.py")
13
  ]
14
  return sorted(all_plugs)
15
+
16
+ from sys import exit as exiter
17
+
18
+ from pymongo import MongoClient
19
+ from pymongo.errors import PyMongoError
20
+
21
+ from Powers import BDB_URI, LOGGER
22
+
23
+ try:
24
+ BIRTHDAY_DB = MongoClient(BDB_URI)
25
+ except PyMongoError as f:
26
+ LOGGER.error(f"Error in Mongodb2: {f}")
27
+ exiter(1)
28
+ Birth_main_db = BIRTHDAY_DB["birthdays"]
29
+
30
+ bday_info = Birth_main_db['users_bday']
31
+ bday_cinfo = Birth_main_db["chat_bday"]
Powers/plugins/admin.py CHANGED
@@ -190,16 +190,18 @@ async def fullpromote_usr(c: Gojo, m: Message):
190
  if m.chat.type in [ChatType.SUPERGROUP, ChatType.GROUP]:
191
  title = "Gojo" # Default fullpromote title
192
  if len(m.text.split()) == 3 and not m.reply_to_message:
193
- title = m.text.split()[2]
194
- elif len(m.text.split()) == 2 and m.reply_to_message:
195
- title = m.text.split()[1]
196
- if title and len(title) > 16:
197
- title = title[0:16] # trim title to 16 characters
198
 
199
  try:
200
  await c.set_administrator_title(m.chat.id, user_id, title)
201
  except RPCError as e:
202
  LOGGER.error(e)
 
 
 
 
203
  LOGGER.info(
204
  f"{m.from_user.id} fullpromoted {user_id} in {m.chat.id} with title '{title}'",
205
  )
@@ -291,17 +293,18 @@ async def promote_usr(c: Gojo, m: Message):
291
  title = ""
292
  if m.chat.type in [ChatType.SUPERGROUP, ChatType.GROUP]:
293
  title = "Itadori" # Deafult title
294
- if len(m.text.split()) == 3 and not m.reply_to_message:
295
- title = m.text.split()[2]
296
- elif len(m.text.split()) == 2 and m.reply_to_message:
297
- title = m.text.split()[1]
298
- if title and len(title) > 16:
299
- title = title[0:16] # trim title to 16 characters
300
-
301
  try:
302
  await c.set_administrator_title(m.chat.id, user_id, title)
303
  except RPCError as e:
304
  LOGGER.error(e)
 
 
 
 
305
  LOGGER.info(
306
  f"{m.from_user.id} promoted {user_id} in {m.chat.id} with title '{title}'",
307
  )
 
190
  if m.chat.type in [ChatType.SUPERGROUP, ChatType.GROUP]:
191
  title = "Gojo" # Default fullpromote title
192
  if len(m.text.split()) == 3 and not m.reply_to_message:
193
+ title = m.text.split()[2:16] # trim title to 16 characters
194
+ elif len(m.text.split()) >= 2 and m.reply_to_message:
195
+ title = m.text.split()[1:16] # trim title to 16 characters
 
 
196
 
197
  try:
198
  await c.set_administrator_title(m.chat.id, user_id, title)
199
  except RPCError as e:
200
  LOGGER.error(e)
201
+ LOGGER.error(format_exc())
202
+ except Exception as e:
203
+ LOGGER.error(e)
204
+ LOGGER.error(format_exc())
205
  LOGGER.info(
206
  f"{m.from_user.id} fullpromoted {user_id} in {m.chat.id} with title '{title}'",
207
  )
 
293
  title = ""
294
  if m.chat.type in [ChatType.SUPERGROUP, ChatType.GROUP]:
295
  title = "Itadori" # Deafult title
296
+ if len(m.text.split()) >= 3 and not m.reply_to_message:
297
+ title = m.text.split()[2:16] # trim title to 16 characters
298
+ elif len(m.text.split()) >= 2 and m.reply_to_message:
299
+ title = m.text.split()[1:16] # trim title to 16 characters
 
 
 
300
  try:
301
  await c.set_administrator_title(m.chat.id, user_id, title)
302
  except RPCError as e:
303
  LOGGER.error(e)
304
+ LOGGER.error(format_exc())
305
+ except Exception as e:
306
+ LOGGER.error(e)
307
+ LOGGER.error(format_exc())
308
  LOGGER.info(
309
  f"{m.from_user.id} promoted {user_id} in {m.chat.id} with title '{title}'",
310
  )
Powers/plugins/antispam.py CHANGED
@@ -5,7 +5,8 @@ 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, SUPPORT_STAFF
 
9
  from Powers.bot_class import Gojo
10
  from Powers.database.antispam_db import GBan
11
  from Powers.database.users_db import Users
 
5
  from pyrogram.errors import MessageTooLong, PeerIdInvalid, UserIsBlocked
6
  from pyrogram.types import Message
7
 
8
+ from Powers import (LOGGER, MESSAGE_DUMP, SUPPORT_GROUP, SUPPORT_STAFF,
9
+ TIME_ZONE)
10
  from Powers.bot_class import Gojo
11
  from Powers.database.antispam_db import GBan
12
  from Powers.database.users_db import Users
Powers/plugins/birthday.py ADDED
@@ -0,0 +1,247 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from datetime import date, datetime, time
2
+
3
+ from apscheduler.schedulers.asyncio import AsyncIOScheduler
4
+ from pyrogram import filters
5
+ from pyrogram.enums import ChatMemberStatus, ChatType
6
+ from pyrogram.types import CallbackQuery
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 TIME_ZONE
12
+ from Powers.bot_class import Gojo
13
+ from Powers.database.chats_db import Chats
14
+ from Powers.plugins import bday_cinfo, bday_info
15
+ from Powers.utils.custom_filters import command
16
+
17
+
18
+ @Gojo.on_message(command("remember"))
19
+ async def remember_me(c: Gojo, m: Message):
20
+ splited = m.text.split()
21
+ if len(splited) != 2 and m.reply_to_message:
22
+ await m.reply_text("**USAGE**:\n/remember [username or user id or reply to user] [DOB]\nDOB should be in format of dd/mm/yyyy\nYear is optional it is not necessary to pass it")
23
+ return
24
+ elif len(splited) != 3 and not m.reply_to_message:
25
+ await m.reply_text("**USAGE**:\n/remember [username or user id or reply to user] [DOB]\nDOB should be in format of dd/mm/yyyy\nYear is optional it is not necessary to pass it")
26
+ return
27
+ DOB = splited[1] if len(splited) == 2 else splited[2]
28
+ if len(splited) == 2:
29
+ user = m.reply_to_message.from_user.id
30
+ else:
31
+ try:
32
+ u_id = int(splited[1])
33
+ except ValueError:
34
+ pass
35
+ try:
36
+ user = await c.get_users(u_id)
37
+ except Exception:
38
+ u_u = await c.resolve_peer(u_id)
39
+ try:
40
+ user = (await c.get_users(u_u.user_id)).id
41
+ except KeyError:
42
+ await m.reply_text("Unable to find the user")
43
+ return
44
+ DOB = DOB.split("/")
45
+ if len(DOB) != 3 or len(DOB) != 2:
46
+ await m.reply_text("DOB should be in format of dd/mm/yyyy\nYear is optional it is not necessary to pass it")
47
+ return
48
+ if len(DOB) == 3:
49
+ is_correct = (len(DOB[2]) == 3)
50
+ if len(DOB[0]) != 2 or len(DOB[1]) !=2 or not is_correct:
51
+ await m.reply_text("DOB should be in format of dd/mm/yyyy\nYear is optional it is not necessary to pass it")
52
+ return
53
+ try:
54
+ date = int(DOB[0])
55
+ month = int(DOB[1])
56
+ if is_correct:
57
+ year = int(DOB[2])
58
+ is_year = 1
59
+ else:
60
+ year = "1800"
61
+ is_year = 0
62
+ DOB = f"{str(date)}/{str(month)}/{year}"
63
+ form = "%d/%m/%Y"
64
+ datee = datetime.strptime(DOB,form).date()
65
+ except ValueError:
66
+ await m.reply_text("DOB should be numbers only")
67
+ return
68
+
69
+ data = {"user_id":user,"dob":datee,"is_year":is_year}
70
+ try:
71
+ result = bday_info.find_one({"user_id":user})
72
+ if result:
73
+ await m.reply_text("User is already in my database")
74
+ return
75
+ except Exception as e:
76
+ await m.reply_text(f"Got an error\n{e}")
77
+
78
+ try:
79
+ bday_info.insert_one(data)
80
+ except Exception as e:
81
+ await m.reply_text(f"Got an error\n{e}")
82
+ return
83
+
84
+ @Gojo.on_message(command(["removebday","rmbday"]))
85
+ async def who_are_you_again(c: Gojo, m: Message):
86
+ user = m.from_user.id
87
+ try:
88
+ result = bday_info.find_one({"user_id":user})
89
+ if not result:
90
+ await m.reply_text("User is not in my database")
91
+ return
92
+ elif result:
93
+ bday_info.delete_one({"user_id":user})
94
+ await m.reply_text("Removed your birthday")
95
+ return
96
+ except Exception as e:
97
+ await m.reply_text(f"Got an error\n{e}")
98
+ return
99
+
100
+ @Gojo.on_message(command(["nextbdays","nbdays"]))
101
+ async def who_is_next(c: Gojo, m: Message):
102
+ blist = list(bday_info.find())
103
+ curr = datetime.now(TIME_ZONE).date()
104
+ xx = await m.reply_text("📆")
105
+ if blist:
106
+ users = []
107
+ for i in blist:
108
+ if i["dob"].month >= curr.month:
109
+ if i["dob"].month == curr.month and i["dob"].days < curr.days:
110
+ continue
111
+ users.append(i)
112
+ elif i["dob"].month < curr.month:
113
+ continue
114
+ if len(users) == 10:
115
+ break
116
+ if not users:
117
+ xx.delete()
118
+ await m.reply_text("No birthdays found :/")
119
+ txt = "🎊 Upcomming Birthdays Are 🎊\n"
120
+ for i in users:
121
+ DOB = i["dob"]
122
+ dete = date(curr.year, DOB.month, DOB.day)
123
+ leff = (dete - curr).days
124
+ txt += f"`{i['user_id']}` : {leff} days left"
125
+ txt += "\nYou can use /info [user id] to get info about the user"
126
+ await xx.delete()
127
+ await m.reply_text(txt)
128
+ return
129
+
130
+ @Gojo.on_message(command(["getbday","gbday"]))
131
+ async def cant_recall_it(c: Gojo, m: Message):
132
+ user = m.from_user.id
133
+ if m.reply_to_message:
134
+ user = m.reply_to_message.from_user.id
135
+ try:
136
+ result = bday_info.find_one({"user_id":user})
137
+ if not result:
138
+ await m.reply_text("User is not in my database")
139
+ return
140
+ except Exception as e:
141
+ await m.reply_text(f"Got an error\n{e}")
142
+ return
143
+
144
+ curr = datetime.now(TIME_ZONE).date()
145
+ u_dob = result["dob"]
146
+ if u_dob.month < curr.month:
147
+ next_b = date(curr.year + 1, u_dob.month, u_dob.day)
148
+ days_left = (next_b - curr).days
149
+ txt = f"User's birthday is passed 🫤\nDays left until next one {days_left}"
150
+ else:
151
+ u_dobm = date(curr.year, u_dob.month, u_dob.day)
152
+ days_left = (u_dobm - curr).days
153
+ txt = f"User's birthday is coming🥳\nDays left until next one {days_left}"
154
+ await m.reply_text(txt)
155
+ return
156
+
157
+ @Gojo.on_message(command(["settingbday","sbday"]))
158
+ async def chat_birthday_settings(c: Gojo, m: Message):
159
+ if m.chat.type == ChatType.PRIVATE:
160
+ await m.reply_text("Use in groups")
161
+ return
162
+ chats = m.chat.id
163
+ c_in = bday_cinfo.find_one({"chat_id":chats})
164
+ kb = IKM(
165
+ [
166
+ [
167
+ IKB(f"{'Yes' if not c_in else 'No'}",f"switchh_{'yes' if not c_in else 'no'}"),
168
+ IKB("Close", "f_close")
169
+ ]
170
+ ]
171
+ )
172
+ await m.reply_text("Do you want to wish members for their birthday in the group?",reply_markup=kb)
173
+ return
174
+
175
+ @Gojo.on_callback_query(filters.regex("^switchh_"))
176
+ async def switch_on_off(c:Gojo, q: CallbackQuery):
177
+ user = (await q.message.chat.get_member(q.from_user.id)).status
178
+ await q.message.chat.get_member(q.from_user.id)
179
+ if user not in [ChatMemberStatus.ADMINISTRATOR, ChatMemberStatus.OWNER]:
180
+ await q.answer("...")
181
+ return
182
+ data = q.data.split("_")[1]
183
+ chats = q.message.chat.id
184
+ xXx = {"chat_id":chats}
185
+ if data == "yes":
186
+ bday_cinfo.delete_one(xXx)
187
+ elif data == "no":
188
+ bday_cinfo.insert_one(xXx)
189
+ await q.edit_message_text(f"Done! I will {'wish' if data == 'yes' else 'not wish'}",reply_markup=IKM([[IKB("Close", "f_close")]]))
190
+ return
191
+
192
+ scheduler = AsyncIOScheduler()
193
+ scheduler.timezone = TIME_ZONE
194
+ scheduler_time = time(0,0,0)
195
+ async def send_wishish(client):
196
+ c_list = Chats.list_chats_by_id()
197
+ blist = list(bday_info.find())
198
+ curr = datetime.now(TIME_ZONE).date()
199
+ for i in blist:
200
+ if i["dob"].month == curr.month and i["dob"].day == curr.day:
201
+ for j in c_list:
202
+ try:
203
+ U = await Gojo.get_chat_member(j,i)
204
+ if U.status in [ChatMemberStatus.MEMBER,ChatMemberStatus.ADMINISTRATOR, ChatMemberStatus.OWNER]:
205
+ xXx = await Gojo.send_message(j,f"Happy birthday\n{U.user.mention}")
206
+ try:
207
+ await xXx.pin()
208
+ except Exception:
209
+ pass
210
+ except Exception:
211
+ pass
212
+
213
+ """"
214
+ from datetime import date, datetime
215
+
216
+ #form =
217
+ num = "18/05/2005"
218
+ st = "18 May 2005"
219
+ timm = datetime.strptime(num,"%d/%m/%Y").date()
220
+ x = datetime.now().date()
221
+ if timm.month < x.month:
222
+ next_b = date(x.year + 1, timm.month, timm.day)
223
+ days_left = (next_b - x).days
224
+ else:
225
+ timmm = date(x.year, timm.month, timm.day)
226
+ days_left = (timmm - x).days
227
+ print(days_left)
228
+ print(x.year - timm.year)
229
+
230
+
231
+ """
232
+
233
+ scheduler.add_job(send_wishish,'cron',hour=0,minute=0,second=0)
234
+ scheduler.start()
235
+
236
+ __PLUGIN__ = "birthday"
237
+
238
+ __HELP__ = """
239
+ • /remember [username or user id or reply to user] [DOB] : To registers user date of birth in my database
240
+ • /nextbdays (/nbdays) : Return upcoming birthdays of 10 users
241
+ • /removebday (/rmbday) : To remove birthday from database (One can only remove their data from database not of others)
242
+ • /settingbday (/sbday) : To configure the settings for wishing and all for the chat
243
+ • /getbday (/gbday) [reply to user] : If replied to user get the replied user's birthday else returns your birthday
244
+
245
+ DOB should be in format of dd/mm/yyyy
246
+ Year is optional it is not necessary to pass it
247
+ """
Powers/plugins/dev.py CHANGED
@@ -20,7 +20,6 @@ from Powers.database.chats_db import Chats
20
  from Powers.utils.clean_file import remove_markdown_and_html
21
  from Powers.utils.custom_filters import command
22
  from Powers.utils.extract_user import extract_user
23
- from Powers.utils.http_helper import *
24
  from Powers.utils.parser import mention_markdown
25
 
26
 
@@ -32,11 +31,13 @@ async def add_dev(c: Gojo, m:Message):
32
  split = m.text.split(None)
33
  reply_to = m.reply_to_message
34
  if len(split) != 2:
35
- await m.reply_text("Reply to message to add the user in dev")
36
- return
37
- elif not reply_to:
38
- await m.reply_text("Give me an id")
39
- return
 
 
40
  elif reply_to:
41
  user = reply_to.from_user.id
42
  elif len(split) == 2:
@@ -138,8 +139,12 @@ async def evaluate_code(c: Gojo, m: Message):
138
  return
139
  sm = await m.reply_text("`Processing...`")
140
  cmd = m.text.split(None, maxsplit=1)[1]
141
- if "for" in cmd or "while" in cmd or "with" in cmd:
142
  if m.from_user.id != OWNER_ID:
 
 
 
 
143
  await m.reply_text("Spam kro gaye vai.\nEse kese")
144
  return
145
  if "while True:" in cmd:
@@ -150,7 +155,11 @@ async def evaluate_code(c: Gojo, m: Message):
150
  f"@{m.from_user.username} TREID TO USE `while True` \n userid = {m.from_user.id}"
151
  )
152
  return
153
-
 
 
 
 
154
  reply_to_id = m.id
155
  if m.reply_to_message:
156
  reply_to_id = m.reply_to_message.id
@@ -321,7 +330,7 @@ async def stop_and_send_logger(c:Gojo,is_update=False):
321
  )
322
  return
323
 
324
- @Gojo.on_message(command(["restart", "update"], owner_cmd=True))
325
  async def restart_the_bot(c:Gojo,m:Message):
326
  try:
327
  cmds = m.command
 
20
  from Powers.utils.clean_file import remove_markdown_and_html
21
  from Powers.utils.custom_filters import command
22
  from Powers.utils.extract_user import extract_user
 
23
  from Powers.utils.parser import mention_markdown
24
 
25
 
 
31
  split = m.text.split(None)
32
  reply_to = m.reply_to_message
33
  if len(split) != 2:
34
+ if not reply_to:
35
+ await m.reply_text("Reply to message to add the user in dev")
36
+ return
37
+ if not reply_to:
38
+ if len(split) != 2:
39
+ await m.reply_text("Give me an id")
40
+ return
41
  elif reply_to:
42
  user = reply_to.from_user.id
43
  elif len(split) == 2:
 
139
  return
140
  sm = await m.reply_text("`Processing...`")
141
  cmd = m.text.split(None, maxsplit=1)[1]
142
+ if "for" in cmd or "while" in cmd or "with" in cmd or "RiZoeLX" in cmd:
143
  if m.from_user.id != OWNER_ID:
144
+ await sm.delete()
145
+ if "RiZoeLX" in cmd:
146
+ await m.reply_text("BROSDK")
147
+ return
148
  await m.reply_text("Spam kro gaye vai.\nEse kese")
149
  return
150
  if "while True:" in cmd:
 
155
  f"@{m.from_user.username} TREID TO USE `while True` \n userid = {m.from_user.id}"
156
  )
157
  return
158
+ if m.reply_to_message.document:
159
+ if m.reply_to_message.document.mime_type.split("/")[1] == "x-python" or m.reply_to_message.document.file_name.endswith("py"):
160
+ await sm.delete()
161
+ await m.reply_text("Loading external plugin is prohibited")
162
+ return
163
  reply_to_id = m.id
164
  if m.reply_to_message:
165
  reply_to_id = m.reply_to_message.id
 
330
  )
331
  return
332
 
333
+ @Gojo.on_message(command(["restart", "update"], owner_cmd=True),group=-100)
334
  async def restart_the_bot(c:Gojo,m:Message):
335
  try:
336
  cmds = m.command
Powers/plugins/giveaway.py DELETED
@@ -1,639 +0,0 @@
1
- import os
2
- from asyncio import sleep
3
- from datetime import datetime, timedelta
4
- from random import choice
5
- from traceback import format_exc
6
-
7
- from pyrogram import filters
8
- from pyrogram.enums import ChatMemberStatus as CMS
9
- from pyrogram.enums import ChatType as CT
10
- from pyrogram.enums import MessageMediaType as MMT
11
- from pyrogram.errors import UserNotParticipant
12
- from pyrogram.types import CallbackQuery
13
- from pyrogram.types import InlineKeyboardButton as IKB
14
- from pyrogram.types import InlineKeyboardMarkup as IKM
15
- from pyrogram.types import Message
16
-
17
- from Powers import LOGGER
18
- from Powers.bot_class import Gojo
19
- from Powers.database.giveaway_db import GIVEAWAY
20
- from Powers.utils.custom_filters import command
21
- from Powers.vars import Config
22
-
23
- user_entry = {} # {c_id : {participants_id : 0}}} dict be like
24
- voted_user = {} # {c_id : [voter_ids]}} dict be like
25
- total_entries = {} # {c_id : [user_id]} dict be like for participants
26
- left_deduct = {} # {c_id:{u_id:p_id}} u_id = user who have voted, p_id = participant id. Will deduct vote from participants account if user leaves
27
- rejoin_try = {} # store the id of the user who lefts the chat while giveaway under-process {c_id:[]}
28
- is_start_vote = [] # store id of chat where voting is started
29
-
30
- @Gojo.on_message(command(["startgiveaway", "startga"]))
31
- async def start_give_one(c: Gojo, m: Message):
32
- uWu = True
33
- try:
34
- if m.chat.type != CT.PRIVATE:
35
- await m.reply_text("**USAGE**\n/startgiveaway\nMeant to be used in private")
36
- return
37
- GA = GIVEAWAY()
38
- g_id = await c.ask(text="Send me number of giveaway", chat_id = m.chat.id, filters=filters.text)
39
- give_id = g_id.text.markdown
40
- curr = GA.give_info(u_id=m.from_user.id)
41
- if curr:
42
- gc_id = curr["chat_id"]
43
- c_id = curr["where"]
44
- if curr["is_give"]:
45
- await m.reply_text("One giveaway is already in progress")
46
- return
47
- while True:
48
- con = await c.ask(text="You info is already present in my database do you want to continue\nYes : To start the giveaway with previous configurations\nNo: To create one",chat_id = m.chat.id,filters=filters.text)
49
- if con.text.lower() == "/cancel":
50
- await m.reply_text("cancelled")
51
- return
52
- if con.text.lower() == "yes":
53
- await c.send_message(m.chat.id,"Done")
54
- while True:
55
- yes_no = await c.ask(text="Ok.\nDo you want to allow old member of the channel can vote in this giveaway.\n**Yes: To allow**\n**No: To don't allow**\nNote that old mean user who is present in the chat for more than 48 hours",chat_id = m.from_user.id,filters=filters.text)
56
- if yes_no.text.lower() == "/cancel":
57
- await m.reply_text("cancelled")
58
- return
59
- if yes_no.text.lower() == "yes":
60
- is_old = 0
61
- break
62
- elif yes_no.text.lower() == "no":
63
- is_old = 1
64
- break
65
- else:
66
- await c.send_message(m.chat.id,"Type yes or no only")
67
- f_c_id = gc_id
68
- s_c_id = c_id
69
- is_old = is_old
70
- GA.update_is_old(m.from_user.id, is_old)
71
- GA.stop_entries(m.from_user.id, entries = 1) # To start entries
72
- GA.stop_give(m.from_user.id, is_give=1) # To start giveaway
73
- link = await c.export_chat_invite_link(s_c_id)
74
- uWu = False
75
- await c.send_message(m.chat.id,"Done")
76
- break
77
- elif con.text.lower() == "no":
78
- uWu = True
79
- break
80
- else:
81
- await c.send_message(m.chat.id,"Type yes or no only")
82
- if uWu:
83
- while True:
84
- channel_id = await c.ask(text="OK....send me id of the channel and make sure I am admin their. If you don't have id forward a post from your chat.\nType /cancel cancel the current process",chat_id = m.chat.id,filters=filters.text)
85
- if channel_id.text:
86
- if str(channel_id.text).lower() == "/cancel":
87
- await c.send_message(m.from_user.id, "Cancelled")
88
- return
89
- try:
90
- c_id = int(channel_id.text)
91
- try:
92
- bot_stat = (await c.get_chat_member(c_id,Config.BOT_ID)).status
93
- if bot_stat in [CMS.ADMINISTRATOR,CMS.OWNER]:
94
- break
95
- else:
96
- await c.send_message(m.chat.id,f"Looks like I don't have admin privileges in the chat {c_id}\n Make me admin and then send me channel id again")
97
- except UserNotParticipant:
98
- await c.send_message(m.chat.id,f"Looks like I am not part of the chat {c_id}\n")
99
-
100
-
101
- except ValueError:
102
- await c.send_message(m.chat.id,"Channel id should be integer type")
103
-
104
- else:
105
- if channel_id.forward_from_chat:
106
- try:
107
- bot_stat = (await c.get_chat_member(c_id,Config.BOT_ID)).status
108
- if bot_stat in [CMS.ADMINISTRATOR,CMS.OWNER]:
109
- break
110
- else:
111
- await c.send_message(m.chat.id,f"Looks like I don't have admin privileges in the chat {c_id}\n Make me admin and then send me channel id again")
112
- except UserNotParticipant:
113
- await c.send_message(m.chat.id,f"Looks like I am not part of the chat {c_id}\n")
114
- else:
115
- await c.send_message(m.chat.id,f"Forward me content from chat where you want to start giveaway")
116
- f_c_id = c_id
117
- await c.send_message(m.chat.id,"Channel id received")
118
- while True:
119
- chat_id = await c.ask(text="Sende me id of the chat and make sure I am admin their. If you don't have id go in the chat and type /id.\nType /cancel to cancel the current process",chat_id = m.chat.id,filters=filters.text)
120
- if chat_id.text:
121
- if str(chat_id.text).lower() == "/cancel":
122
- await c.send_message(m.from_user.id, "Cancelled")
123
- return
124
- try:
125
- cc_id = int(chat_id.text)
126
- try:
127
- cc_id = (await c.get_chat(cc_id)).id
128
- s_c_id = cc_id
129
- break
130
- except Exception:
131
- try:
132
- cc_id = await c.resolve_peer(cc_id)
133
- cc_id = (await c.get_chat(cc_id.channel_id)).id
134
- s_c_id = cc_id
135
- break
136
- except Exception as e:
137
- await c.send_message(m.chat.id,f"Looks like chat doesn't exist{e}")
138
- except ValueError:
139
- await c.send_message(m.chat.id,"Chat id should be integer type")
140
- try:
141
- bot_stat = (await c.get_chat_member(s_c_id,Config.BOT_ID)).status
142
- if bot_stat in [CMS.ADMINISTRATOR,CMS.OWNER]:
143
- break
144
- else:
145
- await c.send_message(m.chat.id,f"Looks like I don't have admin privileges in the chat {s_c_id}\n Make me admin and then send me channel id again")
146
- except UserNotParticipant:
147
- await c.send_message(m.chat.id,f"Looks like I am not part of the chat {s_c_id}\n")
148
-
149
- await c.send_message(m.chat.id,"Chat id received")
150
-
151
- link = await c.export_chat_invite_link(cc_id)
152
-
153
- yes_no = await c.ask(text="Do you want to allow old member of the channel can vote in this giveaway.\n**Yes: To allow**\n**No: To don't allow**\nNote that old mean user who is present in the chat for more than 48 hours",chat_id = m.from_user.id,filters=filters.text)
154
- if yes_no.text.lower() == "yes":
155
- is_old = 0
156
- elif yes_no.text.lower() == "no":
157
- is_old = 1
158
- curr = GA.save_give(f_c_id, s_c_id, m.from_user.id, is_old, force_c=True)
159
- except Exception as e:
160
- LOGGER.error(e)
161
- LOGGER.error(format_exc())
162
- return
163
-
164
- reply = m.reply_to_message
165
- giveaway_text = f"""
166
- **#Giveaway {give_id} 》**
167
- ➖➖➖➖➖➖➖➖➖➖➖
168
- __To win this logo giveaway__
169
- __participate in the contest__,
170
- __Comment /enter to begin__
171
-
172
- Bot should be started!!
173
- ➖➖➖➖➖➖➖➖➖➖➖
174
- **Status : Entries open**
175
- """
176
-
177
- kb = IKM([[IKB("Join the chat", url=link)],[IKB("Start the bot", url=f"https://{Config.BOT_USERNAME}.t.me/")]])
178
- try:
179
- if reply and (reply.media in [MMT.VIDEO, MMT.PHOTO] or (reply.document.mime_type.split("/")[0]=="image")):
180
- if reply.photo:
181
- pin = await c.send_photo(f_c_id, reply.photo.file_id, giveaway_text, reply_markup=kb)
182
- elif reply.video:
183
- pin = await c.send_video(f_c_id, reply.video.file_id, giveaway_text, reply_markup=kb)
184
- elif reply.document:
185
- download = await reply.download()
186
- pin = await c.send_photo(f_c_id, download, giveaway_text, reply_markup=kb)
187
- os.remove(download)
188
- else:
189
- pin = await c.send_message(f_c_id,giveaway_text, reply_markup=kb, disable_web_page_preview=True)
190
- except Exception as e:
191
- LOGGER.error(e)
192
- LOGGER.error(format_exc())
193
- await m.reply_text(f"Failed to send message to channel due to\n{e}")
194
- return
195
- c_in = await c.get_chat(f_c_id)
196
- name = c_in.title
197
- await m.reply_text(f"✨ Giveaway post has been sent to [{name}]({c_in.invite_link})", disable_web_page_preview=True, reply_markup=IKM([[IKB("Go To Post", url=pin.link)]]))
198
-
199
-
200
- async def message_editor(c:Gojo, m: Message, c_id):
201
- txt = f"""
202
- **#Giveaway 》**
203
- ➖➖➖➖➖➖➖➖➖➖➖
204
- __To win this logo giveaway__
205
- __participate in the contest__,
206
- __Comment /enter to begin__
207
-
208
- Note: Bot should be started!!
209
- ➖➖➖➖➖➖➖➖➖➖➖
210
- **Status : Entries closed**
211
- **Total entries : {len(total_entries[c_id])}**
212
- """
213
- try:
214
- m_id = int(m.text.split(None)[1].split("/")[-1])
215
- except ValueError:
216
- await m.reply_text("The link doesn't contain any message id")
217
- return False
218
- try:
219
- mess = await c.get_messages(c_id,m_id)
220
- except Exception as e:
221
- await m.reply_text(f"Failed to get message form the chat id {c_id}. Due to following error\n{e}")
222
- return False
223
- try:
224
- if mess.caption:
225
- await mess.edit_caption(txt)
226
- else:
227
- await mess.edit_text(txt)
228
- return True
229
- except Exception as e:
230
- await m.reply_text(f"Failed to update the message due to following error\n{e}")
231
- await m.reply_text(f"Here is the text you can edit the message by your self\n`{txt}`\nSorry for inconvenience")
232
- return False
233
-
234
-
235
- @Gojo.on_message(command("stopentry"))
236
- async def stop_give_entry(c:Gojo, m: Message):
237
- GA = GIVEAWAY()
238
- u_id = m.from_user.id
239
- curr = GA.give_info(u_id=u_id)
240
- if not curr:
241
- await m.reply_text("You have not started any giveaway yeat.")
242
- return
243
- if not curr["entries"]:
244
- await m.reply_text("You have not started any giveaway yeat.")
245
- return
246
- user = curr["user_id"]
247
- if u_id != user:
248
- await m.reply_text("You are not the one who have started the giveaway")
249
- return
250
- c_id = curr["chat_id"]
251
- if len(m.text.split(None)) != 2:
252
- await m.reply_text("**Usage**\n`/stopentry <post link>`")
253
- return
254
- GA.stop_entries(u_id)
255
- z = await message_editor(c,m,c_id)
256
- if not z:
257
- return
258
- await m.reply_text("Stopped the further entries")
259
- return
260
-
261
- def clean_values(c_id):
262
- try:
263
- rejoin_try[c_id].clear()
264
- except KeyError:
265
- pass
266
- try:
267
- user_entry[c_id].clear()
268
- except KeyError:
269
- pass
270
- try:
271
- left_deduct[c_id].clear()
272
- except KeyError:
273
- pass
274
- try:
275
- total_entries[c_id].clear()
276
- except KeyError:
277
- pass
278
- try:
279
- is_start_vote.remove(c_id)
280
- except ValueError:
281
- pass
282
- try:
283
- voted_user[c_id].clear()
284
- except KeyError:
285
- pass
286
- return
287
-
288
- @Gojo.on_message(command(["stopgiveaway","stopga"]))
289
- async def stop_give_away(c:Gojo, m: Message):
290
- GA = GIVEAWAY()
291
- u_id = m.from_user.id
292
- curr = GA.give_info(u_id=u_id)
293
- if not curr:
294
- await m.reply_text("You have not started any giveaway yet")
295
- return
296
- if not curr["is_give"]:
297
- await m.reply_text("You have not started any giveaway yet")
298
- return
299
- user = curr["user_id"]
300
- c_id = curr["chat_id"]
301
-
302
- GA.stop_entries(u_id)
303
- GA.start_vote(u_id,0)
304
- try:
305
- if not len(total_entries[c_id]):
306
- await m.reply_text("No entires found")
307
- GA.stop_give(u_id)
308
- clean_values(c_id)
309
- await m.reply_text("Stopped the giveaway")
310
- return
311
- except KeyError:
312
- await m.reply_text("No entires found")
313
- GA.stop_give(u_id)
314
- clean_values(c_id)
315
- await m.reply_text("Stopped the giveaway")
316
- return
317
- if u_id != user:
318
- await m.reply_text("You are not the one who have started the giveaway")
319
- return
320
- try:
321
- if not len(user_entry[c_id]):
322
- await m.reply_text("No entries found")
323
- GA.stop_give(u_id)
324
- clean_values(c_id)
325
- await m.reply_text("Stopped the giveaway")
326
- return
327
- except KeyError:
328
- GA.stop_give(u_id)
329
- clean_values(c_id)
330
- await m.reply_text("Stopped the giveaway")
331
- return
332
- GA.stop_give(u_id)
333
- try:
334
- if not len(voted_user[c_id]):
335
- clean_values(c_id)
336
- await m.reply_text("No voters found")
337
- GA.stop_give(u_id)
338
- await m.reply_text("Stopped the giveaway")
339
- return
340
- except KeyError:
341
- GA.stop_give(u_id)
342
- clean_values(c_id)
343
- await m.reply_text("Stopped the giveaway")
344
- return
345
- # highest = max(user_entry[c_id], key=lambda k:user_entry[c_id][k])
346
- # high = user_entry[c_id][highest]
347
- max_value = max(user_entry[c_id].values())
348
- max_user = []
349
- for k,v in user_entry[c_id].items():
350
- if v == max_value:
351
- max_user.append(k)
352
- if len(max_user) == 1:
353
-
354
- high = max_value
355
- user_high = (await c.get_users(max_user[0])).mention
356
- txt = f"""
357
- **Giveaway complete** ✅
358
- ➖➖➖➖➖➖➖➖➖➖➖
359
- ≡ Total participants: {len(total_entries[c_id])}
360
- ≡ Total number of votes: {len(voted_user[c_id])}
361
-
362
- ≡ Winner 🏆 : {user_high}
363
- ≡ Vote got 🗳 : `{high}` votes
364
- ➖➖➖➖➖➖➖➖➖➖➖
365
- >>>Thanks for participating
366
- """
367
- else:
368
- to_key = ["Jai hind", "Jai Jawaan","Jai Bharat", "Jai shree ram", "Jai shree shyam", "Jai shree Krishn", "Jai shree radhe", "Radhe radhe", "Sambhu", "Jai mata di", "Jai mahakaal", "Jai bajarangbali"]
369
- key = choice(to_key)
370
- high = max_value
371
- user_h = [i.mention for i in await c.get_users(max_user)]
372
- txt = f"""
373
- **Giveaway complete** ✅
374
- ➖➖➖➖➖➖➖➖➖➖➖
375
- ≡ Total participants: {len(total_entries[c_id])}
376
- ≡ Total number of votes: {len(voted_user[c_id])}
377
-
378
- ≡ It's a tie between following users:
379
- {", ".join(user_h)}
380
- ≡ They each got 🗳 : `{high}` votes
381
- ➖➖➖➖➖➖➖➖➖➖➖
382
- >>>Thanks for participating
383
-
384
- The user who will comment the code will win
385
- Code: `{key}`
386
- """
387
- await c.send_message(c_id, txt)
388
- clean_values(c_id)
389
- await m.reply_text("Stopped giveaway")
390
-
391
- @Gojo.on_message(command("startvote"))
392
- async def start_the_vote(c: Gojo, m: Message):
393
- GA = GIVEAWAY()
394
- u_id = m.from_user.id
395
- curr = GA.give_info(u_id=m.from_user.id)
396
- if not curr:
397
- await m.reply_text("You have not started any giveaway yet")
398
- return
399
- if not curr["is_give"]:
400
- await m.reply_text("You have not started any giveaway yet")
401
- return
402
- c_id = curr["chat_id"]
403
- user = curr["user_id"]
404
- if len(is_start_vote):
405
- if m.chat.id in is_start_vote:
406
- await m.reply_text("Voting is already started for this chat")
407
- return
408
- if len(m.text.split(None)) == 2:
409
- await message_editor(c,m,c_id)
410
- else:
411
- await m.reply_text("No message link provided to update status to closed")
412
- GA.stop_entries(u_id)
413
- if u_id != user:
414
- await m.reply_text("You are not the one who have started the giveaway")
415
- return
416
- try:
417
- if not len(total_entries[c_id]):
418
- clean_values(c_id)
419
- await m.reply_text("No entires found")
420
- return
421
- except KeyError:
422
- clean_values(c_id)
423
- await m.reply_text("No entires found")
424
- return
425
- users = await c.get_users(total_entries[c_id])
426
- c_link = await c.export_chat_invite_link(c_id)
427
- for user in users:
428
- u_id = user.id
429
- full_name = user.first_name
430
- if user.last_name and user.first_name:
431
- full_name = user.first_name +" "+ user.last_name
432
- u_name = user.username if user.username else user.mention
433
- txt = f"""
434
- **Participant's info:** 🔍 》
435
- ➖➖➖➖➖➖➖➖➖➖➖
436
- ≡ Participant's name : {full_name}
437
- ≡ Participant's ID : `{u_id}`
438
- ≡ Participant's {'username' if user.username else "mention"} : {'@'if user.username else ""}{u_name}
439
- ➖➖➖➖➖➖➖➖➖➖➖
440
- >>>Thanks for participating
441
- """
442
- if not len(user_entry):
443
- user_entry[c_id] = {u_id:0}
444
- else:
445
- try:
446
- user_entry[c_id][u_id] = 0
447
- except KeyError:
448
- user_entry[c_id] = {u_id:0}
449
- vote_kb = IKM([[IKB("❤️", f"vote_{c_id}_{u_id}")]])
450
- um = await c.send_message(c_id, txt, reply_markup=vote_kb)
451
- if m.chat.username and not c_link:
452
- c_link = f"https://t.me/{m.chat.username}"
453
- join_channel_kb = IKM([[IKB("Giveaway Channel", url=c_link)]])
454
- txt_ib = f"Voting has been started 》\n\n>>>Here is your vote link :\nHere is your vote message link {um.link}.\n\n**Things to keep in mind**\n■ If user lefts the chat after voting your vote count will be deducted.\n■ If an user left and rejoins the chat he will not be able to vote.\n■ If an user is not part of the chat then he'll not be able to vote"
455
- await c.send_message(u_id, txt_ib, reply_markup=join_channel_kb,disable_web_page_preview=True)
456
- await sleep(5) # To avoid flood
457
- GA.start_vote(u_id)
458
- is_start_vote.append(c_id)
459
- await m.reply_text("Started the voting")
460
- return
461
-
462
-
463
- @Gojo.on_message(command(["enter","register","participate"]))
464
- async def register_user(c: Gojo, m: Message):
465
- GA = GIVEAWAY()
466
- curr = GA.is_vote(m.chat.id)
467
- if not curr:
468
- await m.reply_text("No giveaway to participate in.\nOr may be entries are closed now")
469
- return
470
- curr = GA.give_info(m.chat.id)
471
- if not curr["is_give"]:
472
- await m.reply_text("No giveaway to participate in. Wait for the next one")
473
- return
474
- elif not curr["entries"]:
475
- await m.reply_text("You are late,\nentries are closed 🫤\nTry again in next giveaway")
476
- return
477
- c_id = curr["chat_id"]
478
- if len(total_entries):
479
- try:
480
- if m.from_user.id in total_entries[c_id]:
481
- await m.reply_text("You are already registered")
482
- return
483
- except KeyError:
484
- pass
485
- try:
486
- await c.send_message(m.from_user.id, "Thanks for participating in the giveaway")
487
- except Exception:
488
- await m.reply_text("Start the bot first\nAnd try again",reply_markup=IKM([[IKB("Star the bot", url=f"https://{Config.BOT_USERNAME}.t.me/")]]))
489
- return
490
- curr = GA.give_info(m.chat.id)
491
- c_id = curr["chat_id"]
492
- if not len(total_entries):
493
- total_entries[c_id] = [m.from_user.id]
494
- else:
495
- try:
496
- if m.from_user.id not in total_entries[c_id]:
497
- total_entries[c_id].append(m.from_user.id)
498
- else:
499
- pass
500
- except KeyError:
501
- total_entries[c_id] = [m.from_user.id]
502
- await m.reply_text("You are registered successfully\n**Don't block the bot because you are going to get info about giveaway via bot**")
503
- return
504
-
505
- def get_curr_votes(p_id,c_id):
506
- votess = []
507
- if votess:
508
- votess.clear()
509
- if not len(left_deduct[c_id]):
510
- votes = 0
511
- return 0
512
- for i,j in left_deduct[c_id].items():
513
- if j == p_id:
514
- votess.append(i)
515
- votes = len(votess)
516
- return votes
517
-
518
- @Gojo.on_callback_query(filters.regex("^vote_"))
519
- async def vote_increment(c: Gojo, q: CallbackQuery):
520
- GA = GIVEAWAY()
521
- data = q.data.split("_")
522
- c_id = int(data[1])
523
- u_id = int(data[2])
524
- curr = GA.give_info(c_id)
525
- if not curr["is_give"]:
526
- await q.answer("Voting is closed")
527
- return
528
- if not curr:
529
- return
530
- if len(rejoin_try):
531
- try:
532
- if q.from_user.id in rejoin_try[c_id]:
533
- await q.answer("You can't vote. Because your rejoined the chat during giveaway")
534
- return
535
- except KeyError:
536
- pass
537
- is_old = curr["is_new"]
538
- can_old = False
539
- if is_old:
540
- can_old = datetime.now() - timedelta(days=2)
541
- try:
542
- is_part = await c.get_chat_member(c_id,q.from_user.id)
543
- except UserNotParticipant:
544
- await q.answer("Join the channel to vote", True)
545
- return
546
- if is_part.status not in [CMS.MEMBER, CMS.OWNER, CMS.ADMINISTRATOR]:
547
- await q.answer("Join the channel to vote", True)
548
- return
549
- if can_old and can_old < is_part.joined_date:
550
- await q.answer("Old member can't vote", True)
551
- return
552
- if not len(voted_user):
553
- voted_user[c_id] = [q.from_user.id]
554
- elif len(voted_user):
555
- try:
556
- if q.from_user.id in voted_user[c_id]:
557
- await q.answer("You have already voted once", True)
558
- return
559
- voted_user[c_id].append(q.from_user.id)
560
- except KeyError:
561
- voted_user[c_id] = [q.from_user.id]
562
- try:
563
- left_deduct[c_id][q.from_user.id] = u_id
564
- except KeyError:
565
- left_deduct[c_id] = {q.from_user.id:u_id}
566
- votes = get_curr_votes(u_id,c_id)
567
- try:
568
- user_entry[c_id][u_id] += 1
569
- new_vote = IKM([[IKB(f"❤️ {votes}", f"vote_{c_id}_{u_id}")]])
570
- await q.answer("Voted.")
571
- await q.edit_message_reply_markup(new_vote)
572
- except KeyError:
573
- await q.answer("Voting has been closed for this giveaway",True)
574
- return
575
- except Exception as e:
576
- LOGGER.error(e)
577
- LOGGER.error(format_exc())
578
-
579
-
580
- @Gojo.on_message(filters.left_chat_member)
581
- async def rejoin_try_not(c:Gojo, m: Message):
582
- user = m.left_chat_member
583
- if not user:
584
- return
585
- GA = GIVEAWAY()
586
- Ezio = GA.give_info(m.chat.id)
587
- if not Ezio:
588
- return
589
- Captain = user.id
590
- if len(voted_user):
591
- if Captain in voted_user[m.chat.id]:
592
- GB = int(left_deduct[m.chat.id][Captain])
593
- user_entry[m.chat.id][GB] -= 1
594
- await c.send_message(GB,f"One user who have voted you left the chat so his vote is reduced from your total votes.\nNote that he will not able to vote if he rejoins the chat\nLeft user : {Captain}")
595
- try:
596
- rejoin_try[m.chat.id].append(Captain)
597
- except KeyError:
598
- rejoin_try[m.chat.id] = [Captain]
599
- else:
600
- try:
601
- rejoin_try[m.chat.id].append(Captain)
602
- except KeyError:
603
- rejoin_try[m.chat.id] = [Captain]
604
- return
605
-
606
-
607
- __PLUGIN__ = "giveaway"
608
-
609
- __alt_name__ = [
610
- "giveaway",
611
- "events"
612
- ]
613
-
614
- __HELP__ = """
615
- **Giveaway**
616
- • /enter (/register, /participate): To participate in giveaway. Make sure the bot is started to get registered.
617
-
618
- **Admin commands:**
619
- • /startgiveaway (/startga) : Start the giveaway. Reply to media to send giveaway start message with tagged media (Will only wrok in bot ib).
620
-
621
- **User dependent commands**
622
- • /stopentry <post link>: Stop the further entries. Channel for which you want to stop the entries. Pass the post link of the post you want to edit the msg and set it as closed message
623
- • /stopgiveaway (/stopga) : Stop the giveaway. Channel for which you want to stop the giveaway. Will also close voting at same time.
624
- • /startvote <post link>: Start uploading all the user info and will start voting. Pass the post link of the post you want to edit the msg and set it as closed message. Not necessary to give post link.
625
-
626
- **Post link (For Channels) = Message link (For chats)**
627
-
628
- **All the above command (except `/startgiveaway`) can only be valid iff the user who started the giveaway gives them**
629
-
630
- **TO USE THE ADMIN COMMANDS YOU MUST BE ADMIN IN BOTH CHANNEL AS WELL AS CHAT**
631
-
632
- **USER DEPENDENT COMMANDS ARE THOSE COMMANDS WHICH CAN ONLY BE USED BY THE USER WHO HAVE GIVEN `/startgiveaway` COMMAND
633
-
634
- **Example:**
635
- `/enter`
636
-
637
- **NOTE**
638
- Bot should be admin where you are doing giveaway and where you are taking entries.
639
- """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Powers/plugins/greetings.py CHANGED
@@ -10,6 +10,7 @@ from Powers import DEV_USERS
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.custom_filters import admin_filter, bot_admin_filter, command
14
  from Powers.utils.msg_types import Types, get_wlcm_type
15
  from Powers.utils.parser import escape_markdown, mention_html
@@ -143,13 +144,12 @@ async def save_wlcm(_, m: Message):
143
  "Error: There is no text in here! and only text with buttons are supported currently !",
144
  )
145
  return
146
- text, msgtype, _ = await get_wlcm_type(m)
147
-
148
  if not m.reply_to_message and msgtype == Types.TEXT and len(m.command) <= 2:
149
  await m.reply_text(f"<code>{m.text}</code>\n\nError: There is no data in here!")
150
  return
151
 
152
- if not text and not msgtype:
153
  await m.reply_text(
154
  "Please provide some data!",
155
  )
@@ -159,7 +159,7 @@ async def save_wlcm(_, m: Message):
159
  await m.reply_text("Please provide some data for this to reply with!")
160
  return
161
 
162
- db.set_welcome_text(text)
163
  await m.reply_text("Saved welcome!")
164
  return
165
 
@@ -181,13 +181,13 @@ async def save_gdbye(_, m: Message):
181
  "Error: There is no text in here! and only text with buttons are supported currently !",
182
  )
183
  return
184
- text, msgtype, _ = await get_wlcm_type(m)
185
 
186
  if not m.reply_to_message and msgtype == Types.TEXT and len(m.command) <= 2:
187
  await m.reply_text(f"<code>{m.text}</code>\n\nError: There is no data in here!")
188
  return
189
 
190
- if not text and not msgtype:
191
  await m.reply_text(
192
  "Please provide some data!",
193
  )
@@ -197,7 +197,7 @@ async def save_gdbye(_, m: Message):
197
  await m.reply_text("Please provide some data for this to reply with!")
198
  return
199
 
200
- db.set_goodbye_text(text)
201
  await m.reply_text("Saved goodbye!")
202
  return
203
 
@@ -274,6 +274,8 @@ async def member_has_joined(c: Gojo, member: ChatMemberUpdated):
274
  return
275
  status = db.get_welcome_status()
276
  oo = db.get_welcome_text()
 
 
277
  parse_words = [
278
  "first",
279
  "last",
@@ -302,12 +304,21 @@ async def member_has_joined(c: Gojo, member: ChatMemberUpdated):
302
  except RPCError:
303
  pass
304
  try:
305
- jj = await c.send_message(
306
- member.chat.id,
307
- text=teks,
308
- reply_markup=button,
309
- disable_web_page_preview=True,
310
- )
 
 
 
 
 
 
 
 
 
311
  if jj:
312
  db.set_cleanwlcm_id(int(jj.id))
313
  except RPCError as e:
@@ -331,6 +342,8 @@ async def member_has_left(c: Gojo, member: ChatMemberUpdated):
331
  db = Greetings(member.chat.id)
332
  status = db.get_goodbye_status()
333
  oo = db.get_goodbye_text()
 
 
334
  parse_words = [
335
  "first",
336
  "last",
@@ -368,12 +381,21 @@ async def member_has_left(c: Gojo, member: ChatMemberUpdated):
368
  )
369
  return
370
  try:
371
- ooo = await c.send_message(
372
- member.chat.id,
373
- text=teks,
374
- reply_markup=button,
375
- disable_web_page_preview=True,
376
- )
 
 
 
 
 
 
 
 
 
377
  if ooo:
378
  db.set_cleangoodbye_id(int(ooo.id))
379
  return
 
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
 
144
  "Error: There is no text in here! and only text with buttons are supported currently !",
145
  )
146
  return
147
+ text, msgtype, file = await get_wlcm_type(m)
 
148
  if not m.reply_to_message and msgtype == Types.TEXT and len(m.command) <= 2:
149
  await m.reply_text(f"<code>{m.text}</code>\n\nError: There is no data in here!")
150
  return
151
 
152
+ if not text and not file:
153
  await m.reply_text(
154
  "Please provide some data!",
155
  )
 
159
  await m.reply_text("Please provide some data for this to reply with!")
160
  return
161
 
162
+ db.set_welcome_text(text,file)
163
  await m.reply_text("Saved welcome!")
164
  return
165
 
 
181
  "Error: There is no text in here! and only text with buttons are supported currently !",
182
  )
183
  return
184
+ text, msgtype, file = await get_wlcm_type(m)
185
 
186
  if not m.reply_to_message and msgtype == Types.TEXT and len(m.command) <= 2:
187
  await m.reply_text(f"<code>{m.text}</code>\n\nError: There is no data in here!")
188
  return
189
 
190
+ if not text and not file:
191
  await m.reply_text(
192
  "Please provide some data!",
193
  )
 
197
  await m.reply_text("Please provide some data for this to reply with!")
198
  return
199
 
200
+ db.set_goodbye_text(text,file)
201
  await m.reply_text("Saved goodbye!")
202
  return
203
 
 
274
  return
275
  status = db.get_welcome_status()
276
  oo = db.get_welcome_text()
277
+ UwU = db.get_welcome_media()
278
+ mtype = db.get_welcome_msgtype()
279
  parse_words = [
280
  "first",
281
  "last",
 
304
  except RPCError:
305
  pass
306
  try:
307
+ if not UwU:
308
+ jj = await c.send_message(
309
+ member.chat.id,
310
+ text=teks,
311
+ reply_markup=button,
312
+ disable_web_page_preview=True,
313
+ )
314
+ elif UwU:
315
+ jj = await (await send_cmd(c,mtype))(
316
+ member.chat.id,
317
+ UwU,
318
+ caption=teks,
319
+ reply_markup=button,
320
+ )
321
+
322
  if jj:
323
  db.set_cleanwlcm_id(int(jj.id))
324
  except RPCError as e:
 
342
  db = Greetings(member.chat.id)
343
  status = db.get_goodbye_status()
344
  oo = db.get_goodbye_text()
345
+ UwU = db.get_goodbye_media()
346
+ mtype = db.get_goodbye_msgtype()
347
  parse_words = [
348
  "first",
349
  "last",
 
381
  )
382
  return
383
  try:
384
+ if not UwU:
385
+ ooo = await c.send_message(
386
+ member.chat.id,
387
+ text=teks,
388
+ reply_markup=button,
389
+ disable_web_page_preview=True,
390
+ )
391
+ elif UwU:
392
+ ooo = await (await send_cmd(c,mtype))(
393
+ member.chat.id,
394
+ UwU,
395
+ caption=teks,
396
+ reply_markup=button,
397
+ )
398
+
399
  if ooo:
400
  db.set_cleangoodbye_id(int(ooo.id))
401
  return
Powers/plugins/info.py CHANGED
@@ -5,6 +5,8 @@ from traceback import format_exc
5
 
6
  from pyrogram import enums
7
  from pyrogram.errors import EntityBoundsInvalid, MediaCaptionTooLong, RPCError
 
 
8
  from pyrogram.types import Message
9
 
10
  from Powers import (DEV_USERS, LOGGER, OWNER_ID, SUDO_USERS, SUPPORT_STAFF,
@@ -72,6 +74,17 @@ async def user_info(c: Gojo, user, already=False):
72
  reason = "User is not gbanned"
73
 
74
  user_id = user.id
 
 
 
 
 
 
 
 
 
 
 
75
  username = user.username
76
  first_name = user.first_name
77
  last_name = user.last_name
@@ -130,6 +143,7 @@ async def user_info(c: Gojo, user, already=False):
130
  <b>🗣 First Name</b>: <code>{first_name}</code>
131
  <b>🔅 Second Name</b>: <code>{last_name}</code>
132
  <b>🔍 Username</b>: {("@" + username) if username else "NA"}
 
133
  <b>🧑‍💻 Support</b>: {is_support}
134
  <b>🥷 Support user type</b>: <code>{omp}</code>
135
  <b>💣 Gbanned</b>: {gban}
@@ -148,18 +162,42 @@ async def user_info(c: Gojo, user, already=False):
148
 
149
 
150
  async def chat_info(c: Gojo, chat, already=False):
 
151
  if not already:
152
  try:
153
  chat = await c.get_chat(chat)
 
 
 
 
 
 
 
 
 
 
154
  except Exception:
155
  try:
156
  chat_r = await c.resolve_peer(chat)
157
  chat = await c.get_chat(chat_r.channel_id)
 
 
 
 
 
 
 
 
 
 
158
  except KeyError as e:
159
  caption = f"Failed to find the chat due to\n{e}"
160
  return caption, None
161
  chat_id = chat.id
162
- username = chat.username
 
 
 
163
  total_bot, total_admin, total_bot_admin, total_banned = await count(c, chat.id)
164
  title = chat.title
165
  type_ = str(chat.type).split(".")[1]
 
5
 
6
  from pyrogram import enums
7
  from pyrogram.errors import EntityBoundsInvalid, MediaCaptionTooLong, RPCError
8
+ 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 (DEV_USERS, LOGGER, OWNER_ID, SUDO_USERS, SUPPORT_STAFF,
 
74
  reason = "User is not gbanned"
75
 
76
  user_id = user.id
77
+ user = await c.resolve_peer(user_id)
78
+ about = "NA"
79
+ try:
80
+ ll = await c.invoke(
81
+ GetFullUser(
82
+ id=user
83
+ )
84
+ )
85
+ about = ll.full_user.about
86
+ except Exception:
87
+ pass
88
  username = user.username
89
  first_name = user.first_name
90
  last_name = user.last_name
 
143
  <b>🗣 First Name</b>: <code>{first_name}</code>
144
  <b>🔅 Second Name</b>: <code>{last_name}</code>
145
  <b>🔍 Username</b>: {("@" + username) if username else "NA"}
146
+ <b> Bio</b>: {about}
147
  <b>🧑‍💻 Support</b>: {is_support}
148
  <b>🥷 Support user type</b>: <code>{omp}</code>
149
  <b>💣 Gbanned</b>: {gban}
 
162
 
163
 
164
  async def chat_info(c: Gojo, chat, already=False):
165
+ u_name = False
166
  if not already:
167
  try:
168
  chat = await c.get_chat(chat)
169
+ try:
170
+ chat = (await c.resolve_peer(chat.id))
171
+ ll = await c.invoke(
172
+ GetFullChannel(
173
+ channel=chat
174
+ )
175
+ )
176
+ u_name = ll.chats[0].usernames
177
+ except Exception:
178
+ pass
179
  except Exception:
180
  try:
181
  chat_r = await c.resolve_peer(chat)
182
  chat = await c.get_chat(chat_r.channel_id)
183
+ try:
184
+ chat = (await c.resolve_peer(chat_r))
185
+ ll = await c.invoke(
186
+ GetFullChannel(
187
+ channel=chat
188
+ )
189
+ )
190
+ u_name = ll.chats[0].usernames
191
+ except Exception:
192
+ pass
193
  except KeyError as e:
194
  caption = f"Failed to find the chat due to\n{e}"
195
  return caption, None
196
  chat_id = chat.id
197
+ if u_name:
198
+ username = " ".join([f"@{i}"for i in u_name])
199
+ elif not u_name:
200
+ username = chat.username
201
  total_bot, total_admin, total_bot_admin, total_banned = await count(c, chat.id)
202
  title = chat.title
203
  type_ = str(chat.type).split(".")[1]
Powers/plugins/locks.py CHANGED
@@ -2,6 +2,7 @@ from asyncio import sleep
2
  from traceback import format_exc
3
 
4
  from pyrogram import filters
 
5
  from pyrogram.errors import ChatAdminRequired, ChatNotModified, RPCError
6
  from pyrogram.types import ChatPermissions, Message
7
 
@@ -17,6 +18,7 @@ anti_c_send = [-1001604479593]
17
  anti_forward = [-1001604479593]
18
  anti_forward_u = []
19
  anti_forward_c = []
 
20
  @Gojo.on_message(command("locktypes"))
21
  async def lock_types(_, m: Message):
22
  await m.reply_text(
@@ -38,6 +40,7 @@ async def lock_types(_, m: Message):
38
  " - `forwardall` = Forwarding from channel and user\n"
39
  " - `forwardu` = Forwarding from user\n"
40
  " - `forwardc` = Forwarding from channel"
 
41
  ),
42
  )
43
  return
@@ -121,6 +124,15 @@ async def lock_perm(c: Gojo, m: Message):
121
  elif lock_type == "pin":
122
  pin = False
123
  perm = "pin"
 
 
 
 
 
 
 
 
 
124
  elif lock_type == "anonchannel":
125
  if not len(anti_c_send):
126
  anti_c_send.append(m.chat.id)
@@ -214,6 +226,9 @@ async def view_locks(_, m: Message):
214
  anti_f_u = True
215
  if m.chat.id in anti_forward_c:
216
  anti_f_c = True
 
 
 
217
  vmsg = await convert_to_emoji(v_perm.can_send_messages)
218
  vmedia = await convert_to_emoji(v_perm.can_send_media_messages)
219
  vother = await convert_to_emoji(v_perm.can_send_other_messages)
@@ -226,6 +241,7 @@ async def view_locks(_, m: Message):
226
  vanti = await convert_to_emoji(anti_f)
227
  vantiu = await convert_to_emoji(anti_f_u)
228
  vantic = await convert_to_emoji(anti_f_c)
 
229
 
230
  if v_perm is not None:
231
  try:
@@ -246,6 +262,7 @@ async def view_locks(_, m: Message):
246
  <b>Can forward:</b> {vanti}
247
  <b>Can forward from user:</b> {vantiu}
248
  <b>Can forward from channel and chats:</b> {vantic}
 
249
  """
250
  LOGGER.info(f"{m.from_user.id} used locks cmd in {m.chat.id}")
251
  await chkmsg.edit_text(permission_view_str)
@@ -357,6 +374,14 @@ async def unlock_perm(c: Gojo, m: Message):
357
  except ValueError:
358
  await m.reply_text("It is already off")
359
  return
 
 
 
 
 
 
 
 
360
  elif unlock_type == "forwardall":
361
  try:
362
  if not len(anti_forward) or m.chat.id not in anti_forward:
@@ -453,15 +478,25 @@ async def is_approved_user(c:Gojo, m: Message):
453
  elif x_chat and x_chat.id == m.chat.id:
454
  return True
455
  return False
 
 
 
 
456
 
457
  @Gojo.on_message(filters.all & ~filters.me,18)
458
  async def lock_del_mess(c:Gojo, m: Message):
459
- all_chats = anti_c_send + anti_forward + anti_forward_c + anti_forward_u
460
  if m.chat.id not in all_chats:
461
  return
462
  if m.sender_chat and not (m.forward_from_chat or m.forward_from):
463
  await delete_messages(c,m)
464
  return
 
 
 
 
 
 
465
  elif m.forward_from or m.forward_from_chat:
466
  is_approved = await is_approved_user(c,m)
467
  if not is_approved:
 
2
  from traceback import format_exc
3
 
4
  from pyrogram import filters
5
+ from pyrogram.enums import MessageEntityType as MET
6
  from pyrogram.errors import ChatAdminRequired, ChatNotModified, RPCError
7
  from pyrogram.types import ChatPermissions, Message
8
 
 
18
  anti_forward = [-1001604479593]
19
  anti_forward_u = []
20
  anti_forward_c = []
21
+ anti_links = []
22
  @Gojo.on_message(command("locktypes"))
23
  async def lock_types(_, m: Message):
24
  await m.reply_text(
 
40
  " - `forwardall` = Forwarding from channel and user\n"
41
  " - `forwardu` = Forwarding from user\n"
42
  " - `forwardc` = Forwarding from channel"
43
+ " - `links` = Lock links"
44
  ),
45
  )
46
  return
 
124
  elif lock_type == "pin":
125
  pin = False
126
  perm = "pin"
127
+ elif lock_type == "links":
128
+ if not len(anti_links):
129
+ anti_links.append(m.chat.id)
130
+ elif m.chat.id not in anti_links:
131
+ anti_links.append(m.chat.id)
132
+ else:
133
+ await m.reply_text("It is already on")
134
+ return
135
+ await m.reply_text("Locked links in the chat")
136
  elif lock_type == "anonchannel":
137
  if not len(anti_c_send):
138
  anti_c_send.append(m.chat.id)
 
226
  anti_f_u = True
227
  if m.chat.id in anti_forward_c:
228
  anti_f_c = True
229
+ antil = False
230
+ if m.chat.id in anti_links:
231
+ antil = True
232
  vmsg = await convert_to_emoji(v_perm.can_send_messages)
233
  vmedia = await convert_to_emoji(v_perm.can_send_media_messages)
234
  vother = await convert_to_emoji(v_perm.can_send_other_messages)
 
241
  vanti = await convert_to_emoji(anti_f)
242
  vantiu = await convert_to_emoji(anti_f_u)
243
  vantic = await convert_to_emoji(anti_f_c)
244
+ vantil = await convert_to_emoji(antil)
245
 
246
  if v_perm is not None:
247
  try:
 
262
  <b>Can forward:</b> {vanti}
263
  <b>Can forward from user:</b> {vantiu}
264
  <b>Can forward from channel and chats:</b> {vantic}
265
+ <b>Can send links:</b> {antil}
266
  """
267
  LOGGER.info(f"{m.from_user.id} used locks cmd in {m.chat.id}")
268
  await chkmsg.edit_text(permission_view_str)
 
374
  except ValueError:
375
  await m.reply_text("It is already off")
376
  return
377
+ elif unlock_type == "locks":
378
+ try:
379
+ anti_links.remove(m.chat.id)
380
+ await m.reply_text("Sending link is now allowed")
381
+ return
382
+ except ValueError:
383
+ await m.reply_text("Already allowed")
384
+ return
385
  elif unlock_type == "forwardall":
386
  try:
387
  if not len(anti_forward) or m.chat.id not in anti_forward:
 
478
  elif x_chat and x_chat.id == m.chat.id:
479
  return True
480
  return False
481
+ else:
482
+ if m.from_user.id in ul or m.from_user.id in SUDO_LEVEL or m.from_user.id in admins_group:
483
+ return True
484
+ return False
485
 
486
  @Gojo.on_message(filters.all & ~filters.me,18)
487
  async def lock_del_mess(c:Gojo, m: Message):
488
+ all_chats = anti_c_send + anti_forward + anti_forward_c + anti_forward_u + anti_links
489
  if m.chat.id not in all_chats:
490
  return
491
  if m.sender_chat and not (m.forward_from_chat or m.forward_from):
492
  await delete_messages(c,m)
493
  return
494
+ entity = m.entities if m.text else m.caption_entities
495
+ if entity in [MET.URL or MET.TEXT_LINK]:
496
+ is_approved = await is_approved_user(c,m)
497
+ if not is_approved:
498
+ await delete_messages(c,m)
499
+ return
500
  elif m.forward_from or m.forward_from_chat:
501
  is_approved = await is_approved_user(c,m)
502
  if not is_approved:
Powers/plugins/rules.py CHANGED
@@ -1,11 +1,12 @@
1
  from pyrogram import filters
2
- from pyrogram.types import CallbackQuery, Message
3
 
4
  from Powers import LOGGER
5
  from Powers.bot_class import Gojo
6
  from Powers.database.rules_db import Rules
7
  from Powers.utils.custom_filters import admin_filter, command
8
  from Powers.utils.kbhelpers import ikb
 
9
  from Powers.vars import Config
10
 
11
 
@@ -49,12 +50,16 @@ async def get_rules(_, m: Message):
49
  return
50
 
51
  formated = rules
52
-
 
 
 
53
  await m.reply_text(
54
  text=f"""The rules for <b>{m.chat.title} are:</b>
55
- {formated}""",
56
  disable_web_page_preview=True,
57
  reply_to_message_id=msg_id,
 
58
  )
59
  return
60
 
@@ -161,4 +166,8 @@ Set rules for you chat so that members know what to do and what not to do in you
161
  **Admin only:**
162
  • /setrules `<rules>`: Set the rules for this chat, also works as a reply to a message.
163
  • /clearrules: Clear the rules for this chat.
164
- • /privrules `<on/yes/no/off>`: Turns on/off the option to send the rules to PM of user or group."""
 
 
 
 
 
1
  from pyrogram import filters
2
+ from pyrogram.types import CallbackQuery, InlineKeyboardMarkup, Message
3
 
4
  from Powers import LOGGER
5
  from Powers.bot_class import Gojo
6
  from Powers.database.rules_db import Rules
7
  from Powers.utils.custom_filters import admin_filter, command
8
  from Powers.utils.kbhelpers import ikb
9
+ from Powers.utils.string import build_keyboard, parse_button
10
  from Powers.vars import Config
11
 
12
 
 
50
  return
51
 
52
  formated = rules
53
+ teks, button = await parse_button(formated)
54
+ button = await build_keyboard(button)
55
+ button = InlineKeyboardMarkup(button) if button else None
56
+ textt = teks
57
  await m.reply_text(
58
  text=f"""The rules for <b>{m.chat.title} are:</b>
59
+ {textt}""",
60
  disable_web_page_preview=True,
61
  reply_to_message_id=msg_id,
62
+ reply_markup=button
63
  )
64
  return
65
 
 
166
  **Admin only:**
167
  • /setrules `<rules>`: Set the rules for this chat, also works as a reply to a message.
168
  • /clearrules: Clear the rules for this chat.
169
+ • /privrules `<on/yes/no/off>`: Turns on/off the option to send the rules to PM of user or group.
170
+
171
+ **Note Format**
172
+ Check /markdownhelp for help related to formatting!
173
+ """
Powers/plugins/start.py CHANGED
@@ -82,15 +82,16 @@ async def start(c: Gojo, m: Message):
82
 
83
  if not help_msg:
84
  return
85
- if help_option.split("_")[1] == "help":
86
- await m.reply_photo(
87
- photo=str(choice(StartPic)),
88
- caption=help_msg,
89
- parse_mode=enums.ParseMode.MARKDOWN,
90
- reply_markup=help_kb,
91
- quote=True,
92
- )
93
- return
 
94
  try:
95
  cpt = f"""
96
  Hey [{m.from_user.first_name}](http://t.me/{m.from_user.username})! My self Gojo ✨.
 
82
 
83
  if not help_msg:
84
  return
85
+ if len(help_option.split("_")) == 2:
86
+ if help_option.split("_")[1] == "help":
87
+ await m.reply_photo(
88
+ photo=str(choice(StartPic)),
89
+ caption=help_msg,
90
+ parse_mode=enums.ParseMode.MARKDOWN,
91
+ reply_markup=help_kb,
92
+ quote=True,
93
+ )
94
+ return
95
  try:
96
  cpt = f"""
97
  Hey [{m.from_user.first_name}](http://t.me/{m.from_user.username})! My self Gojo ✨.
Powers/plugins/stickers.py ADDED
@@ -0,0 +1,290 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import imghdr
2
+ import os
3
+ from asyncio import gather
4
+ from random import choice
5
+ from traceback import format_exc
6
+
7
+ from pyrogram.errors import (PeerIdInvalid, ShortnameOccupyFailed,
8
+ StickerEmojiInvalid, StickerPngDimensions,
9
+ StickerPngNopng, UserIsBlocked)
10
+ from pyrogram.types import InlineKeyboardButton as IKB
11
+ from pyrogram.types import InlineKeyboardMarkup as IKM
12
+ from pyrogram.types import Message
13
+
14
+ from Powers import LOGGER
15
+ from Powers.bot_class import Gojo
16
+ from Powers.utils.custom_filters import command
17
+ from Powers.utils.sticker_help import *
18
+ from Powers.utils.web_helpers import get_file_size
19
+ from Powers.vars import Config
20
+
21
+
22
+ @Gojo.on_message(command(["stickerinfo","stinfo"]))
23
+ async def give_st_info(c: Gojo , m: Message):
24
+ if not m.reply_to_message:
25
+ await m.reply_text("Reply to a sticker")
26
+ return
27
+ elif not m.reply_to_message.sticker:
28
+ await m.reply_text("Reply to a sticker")
29
+ return
30
+ st_in = m.reply_to_message.sticker
31
+ st_type = "Normal"
32
+ if st_in.is_animated:
33
+ st_type = "Animated"
34
+ elif st_in.is_video:
35
+ st_type = "Video"
36
+ st_to_gib = f"""[Sticker]({m.reply_to_message.link}) info:
37
+ File ID : `{st_in.file_id}`
38
+ File name : {st_in.file_name}
39
+ File unique ID : `{st_in.file_unique_id}`
40
+ Date and time sticker created : `{st_in.date}`
41
+ Sticker type : `{st_type}`
42
+ Emoji : {st_in.emoji}
43
+ Pack name : {st_in.set_name}
44
+ """
45
+ kb = IKM([[IKB("➕ Add sticker to pack", url=f"https://t.me/addstickers/{st_in.set_name}")]])
46
+ await m.reply_text(st_to_gib,reply_markup=kb)
47
+ return
48
+
49
+ @Gojo.on_message(command(["stickerid","stid"]))
50
+ async def sticker_id_gib(c: Gojo, m: Message):
51
+ if not m.reply_to_message:
52
+ await m.reply_text("Reply to a sticker")
53
+ return
54
+ elif not m.reply_to_message.sticker:
55
+ await m.reply_text("Reply to a sticker")
56
+ return
57
+ st_in = m.reply_to_message.sticker
58
+ await m.reply_text(f"Sticker id: `{st_in.file_id}`\nSticker unique ID : `{st_in.file_unique_id}`")
59
+ return
60
+
61
+
62
+ @Gojo.on_message(command(["kang", "steal"]))
63
+ async def kang(c:Gojo, m: Message):
64
+ if not m.reply_to_message:
65
+ return await m.reply_text("Reply to a sticker to kang it.")
66
+ elif not (m.reply_to_message.sticker or m.reply_to_message.photo):
67
+ return await m.reply_text("Reply to a sticker to kang it.")
68
+ if not m.from_user:
69
+ return await m.reply_text("You are anon admin, kang stickers in my pm.")
70
+ msg = await m.reply_text("Kanging Sticker..")
71
+
72
+ # Find the proper emoji
73
+ args = m.text.split()
74
+ if len(args) > 1:
75
+ sticker_emoji = str(args[1])
76
+ else:
77
+ edit_ = await m.reply_text("No emoji provided choosing a random emoji")
78
+ ran = ["🤣", "😑", "😁", "👍", "🔥", "🙈", "🙏", "😍", "😘", "😱", "☺️", "🙃", "😌", "🤧", "😐", "😬", "🤩", "😀", "🙂", "🥹", "🥺", "🫥", "🙄", "🫡", "🫠", "🤫", "😓", "🥵", "🥶", "😤", "😡", "🤬", "🤯", "🥴", "🤢", "🤮", "💀", "🗿", "💩", "🤡", "🫶", "🙌", "👐", "✊", "👎", "🫰", "🤌", "👌", "👀", "💃", "🕺", "👩‍❤️‍💋‍👩", "👩‍❤️‍💋‍👨","👨‍❤️‍👨", "💑", "👩‍❤️‍👩", "👩‍❤️‍👨", "💏", "👨‍❤️‍💋‍👨", "😪", "😴", "😭", "🥸", "🤓", "🫤", "😮", "😧", "😲", "🥱", "😈", "👿", "🤖", "👾", "🙌", "🥴", "🥰", "😇", "🤣" ,"😂", "😜", "😎"]
79
+ sticker_emoji = choice(ran)
80
+ await edit_.edit_text(f"Makeing a sticker with {sticker_emoji} emoji")
81
+
82
+ # Get the corresponding fileid, resize the file if necessary
83
+ try:
84
+
85
+ if not m.reply_to_message.photo or m.reply_to_message.document.file_name.endswith(("png","jpeg","jpg")):
86
+ sizee = (await get_file_size(m.reply_to_message)).split()
87
+ if (sizee[1] == "mb" and sizee > 10) or sizee[1] == "gb":
88
+ await m.reply_text("File size is too big")
89
+ return
90
+ path = await m.reply_to_message.download()
91
+ try:
92
+ path = await resize_file_to_sticker_size(path)
93
+ except OSError as e:
94
+ await m.reply_text(f"Error\n{e}")
95
+ LOGGER.error(e)
96
+ LOGGER.error(format_exc)
97
+ os.remove(path)
98
+ return
99
+ except Exception as e:
100
+ await m.reply_text(f"Got an error:\n{e}")
101
+ LOGGER.error(e)
102
+ LOGGER.error(format_exc())
103
+ return
104
+ try:
105
+ if not m.reply_to_message.sticker:
106
+ sticker = await create_sticker(
107
+ await upload_document(
108
+ c, path, m.chat.id
109
+ ),
110
+ sticker_emoji
111
+ )
112
+ await edit_.delete()
113
+ os.remove(path)
114
+ elif m.reply_to_message.sticker:
115
+ sticker = await create_sticker(
116
+ await get_document_from_file_id(
117
+ m.reply_to_message.sticker.file_id
118
+ ),
119
+ sticker_emoji
120
+ )
121
+ except ShortnameOccupyFailed:
122
+ await m.reply_text("Change Your Name Or Username")
123
+ return
124
+
125
+ except Exception as e:
126
+ await m.reply_text(str(e))
127
+ e = format_exc()
128
+ LOGGER.error(e)
129
+ LOGGER.error(format_exc())
130
+
131
+ # Find an available pack & add the sticker to the pack; create a new pack if needed
132
+ # Would be a good idea to cache the number instead of searching it every single time...
133
+ kang_lim = 120
134
+ st_in = m.reply_to_message.sticker
135
+ st_type = "norm"
136
+ is_anim = is_vid = False
137
+ if st_in:
138
+ if st_in.is_animated:
139
+ st_type = "ani"
140
+ kang_lim = 50
141
+ is_anim = True
142
+ elif st_in.is_video:
143
+ st_type = "vid"
144
+ kang_lim = 50
145
+ is_vid = True
146
+ packnum = 0
147
+ limit = 0
148
+ volume = 0
149
+ packname_found = False
150
+
151
+ try:
152
+ while not packname_found:
153
+ packname = f"CE{str(m.from_user.id)}{st_type}_{packnum}by{Config.BOT_ID}"
154
+ kangpack = f"{('@'+m.from_user.username) if m.from_user.username else m.from_user.first_name[:10]} {st_type} {('vOl '+str(volume)) if volume else ''} by @{Config.BOT_USERNAME}"
155
+ if limit >= 50: # To prevent this loop from running forever
156
+ await msg.delete()
157
+ await m.reply_text("Failed to kang\nMay be you have made more than 50 sticker packs with me try deleting some")
158
+ return
159
+ sticker_set = await get_sticker_set_by_name(c,packname)
160
+ if not sticker_set:
161
+ sticker_set = await create_sticker_set(
162
+ c,
163
+ m.from_user.id,
164
+ kangpack,
165
+ packname,
166
+ [sticker],
167
+ is_anim,
168
+ is_vid
169
+ )
170
+ elif sticker_set.set.count >= kang_lim:
171
+ packnum += 1
172
+ limit += 1
173
+ volume += 1
174
+ continue
175
+ else:
176
+ try:
177
+ await add_sticker_to_set(c,sticker_set,sticker)
178
+ except StickerEmojiInvalid:
179
+ return await msg.edit("[ERROR]: INVALID_EMOJI_IN_ARGUMENT")
180
+ limit += 1
181
+ packname_found = True
182
+ kb = IKM(
183
+ [
184
+ [
185
+ IKB("➕ Add Pack ➕",url=f"t.me/addstickers/{packname}")
186
+ ]
187
+ ]
188
+ )
189
+ await msg.edit_text(
190
+ f"Kanged the sticker\nPack name: {kangpack}\nEmoji: {sticker_emoji}",
191
+ reply_markup=kb
192
+ )
193
+ except (PeerIdInvalid, UserIsBlocked):
194
+ keyboard = IKM(
195
+ [[IKB("Start me first", url=f"t.me/{Config.BOT_USERNAME}")]]
196
+ )
197
+ await msg.edit_text(
198
+ "You Need To Start A Private Chat With Me.",
199
+ reply_markup=keyboard,
200
+ )
201
+ except StickerPngNopng:
202
+ await m.reply_text(
203
+ "Stickers must be png files but the provided image was not a png"
204
+ )
205
+ except StickerPngDimensions:
206
+ await m.reply_text("The sticker png dimensions are invalid.")
207
+
208
+ @Gojo.on_message(command("mmf"))
209
+ async def memify_it(c: Gojo, m: Message):
210
+ if not m.reply_to_message:
211
+ await m.reply_text("Invalid type.")
212
+ return
213
+ rep_to = m.reply_to_message
214
+ if not (rep_to.sticker or rep_to.photo or "image" in rep_to.document.mime_type.split("/")):
215
+ await m.reply_text("I only support memifying of normal sticker and photos for now")
216
+ return
217
+ if rep_to.sticker.is_animated or rep_to.sticker.is_video:
218
+ await m.reply_text("I only support memifying of normal sticker and photos for now")
219
+ return
220
+ kb = IKM(
221
+ [
222
+ [
223
+ IKB("Join for memes",url="https://t.me/memesofdank")
224
+ ]
225
+ ]
226
+ )
227
+ meme = m.text.split(None,1)[1].split(";")
228
+ material = [i.strip() for i in meme]
229
+ if rep_to.sticker:
230
+ name = "@memesofdank.png"
231
+ else:
232
+ name = "@memesofdank.webp"
233
+ path = rep_to.download(name)
234
+ cheems,domge = await draw_meme(path,material)
235
+ xNx = await m.reply_photo(cheems,reply_markup=kb)
236
+ await xNx.reply_sticker(domge,reply_markup=kb)
237
+ try:
238
+ os.remove(cheems)
239
+ os.remove(domge)
240
+ except Exception as e:
241
+ LOGGER.error(e)
242
+ LOGGER.error(format_exc())
243
+ return
244
+
245
+ @Gojo.on_message(command(["getsticker","getst"]))
246
+ async def get_sticker_from_file(c: Gojo, m: Message):
247
+ Caption = f"Converted by:\n@{Config.BOT_USERNAME}"
248
+ if not m.reply_to_message:
249
+ await m.reply_text("Reply to a sticker or file")
250
+ return
251
+ repl = m.reply_to_message
252
+ if not (repl.sticker or repl.photo or repl.document.mime_type.split("/")[0]=="image"):
253
+ await m.reply_text("I only support conversion of plain stickers and images for now")
254
+ return
255
+ if repl.sticker.is_video or repl.sticker.is_animated:
256
+ await m.reply_text("I only support conversion of plain stickers for now")
257
+ return
258
+ if repl.sticker:
259
+ up = await repl.download(f"{repl.sticker.file_unique_id}.png")
260
+ await m.reply_photo(up,caption=Caption)
261
+ os.remove(up)
262
+ return
263
+ elif repl.photo:
264
+ up = await repl.download(f"{repl.photo.file_unique_id}.webp")
265
+ await m.reply_sticker(up,caption=Caption)
266
+ os.remove(up)
267
+ return
268
+
269
+
270
+ __PLUGIN__ = "sticker"
271
+ __alt_name__ = [
272
+ "sticker",
273
+ "kang"
274
+ ]
275
+ __HELP__ = """
276
+ **User Commands:**
277
+ • /kang (/steal) <emoji>: Reply to a sticker or any supported media
278
+ • /stickerinfo (/stinfo) : Reply to any sticker to get it's info
279
+ • /getsticker (/getst) : Get sticker as photo or vice versa.
280
+ • /stickerid (/stid) : Reply to any sticker to get it's id
281
+ • /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`
282
+ ■ For e.g.
283
+ ○ /mmf Hello freinds : this will add text to the top
284
+ ○ /mmf Hello ; freinds : this will add Hello to the top and freinds at the bottom
285
+ ○ /mmf ; Hello friends : this will add text at the bottom
286
+
287
+ **Note**
288
+ mmf and getsticker only support photo and normal stickers for now.
289
+
290
+ """
Powers/plugins/utils.py CHANGED
@@ -1,4 +1,3 @@
1
- import asyncio
2
  import re
3
  from io import BytesIO
4
  from os import remove
@@ -19,6 +18,7 @@ from Powers.utils.custom_filters import command
19
  from Powers.utils.extract_user import extract_user
20
  from Powers.utils.http_helper import *
21
  from Powers.utils.parser import mention_html
 
22
 
23
 
24
  @Gojo.on_message(command("wiki"))
@@ -117,10 +117,18 @@ async def get_lyrics(_, m: Message):
117
  try:
118
  await em.edit_text(f"**{query.capitalize()} by {artist}**\n`{reply}`")
119
  except MessageTooLong:
 
 
 
 
 
 
 
120
  with BytesIO(str.encode(await remove_markdown_and_html(reply))) as f:
121
  f.name = "lyrics.txt"
122
  await m.reply_document(
123
  document=f,
 
124
  )
125
  await em.delete()
126
  return
@@ -146,10 +154,10 @@ async def id_info(c: Gojo, m: Message):
146
  if m.reply_to_message and m.reply_to_message.forward_from:
147
  user1 = m.reply_to_message.from_user
148
  user2 = m.reply_to_message.forward_from
149
- orig_sender = ((await mention_html(user2.first_name, user2.id)),)
150
- orig_id = (f"<code>{user2.id}</code>",)
151
- fwd_sender = ((await mention_html(user1.first_name, user1.id)),)
152
- fwd_id = (f"<code>{user1.id}</code>",)
153
  await m.reply_text(
154
  text=f"""Original Sender - {orig_sender} (<code>{orig_id}</code>)
155
  Forwarder - {fwd_sender} (<code>{fwd_id}</code>)""",
@@ -176,9 +184,14 @@ async def id_info(c: Gojo, m: Message):
176
  text+=f"Forwarded from user ID <code>{m.forward_from.id}</code>."
177
  elif m.forward_from_chat:
178
  text+=f"Forwarded from user ID <code>{m.forward_from_chat.id}</code>."
179
- await m.reply_text()
 
 
180
  else:
181
- await m.reply_text(text=f"This Group's ID is <code>{m.chat.id}</code>\nYour ID <code>{m.from_user.id}</code>")
 
 
 
182
  return
183
 
184
 
@@ -209,14 +222,17 @@ async def github(_, m: Message):
209
  f"Usage: <code>{Config.PREFIX_HANDLER}github username</code>",
210
  )
211
  return
212
- username = username.split("/")[-1]
213
  URL = f"https://api.github.com/users/{username}"
214
  try:
215
- r = await get(URL, timeout=5)
216
- except asyncio.TimeoutError:
217
  return await m.reply_text("request timeout")
218
  except Exception as e:
219
- return await m.reply_text(f"ERROR: `{e}`")
 
 
 
220
 
221
  avtar = r.get("avatar_url", None)
222
  url = r.get("html_url", None)
@@ -226,10 +242,10 @@ async def github(_, m: Message):
226
  following = r.get("following", 0)
227
  public_repos = r.get("public_repos", 0)
228
  bio = r.get("bio", None)
229
- created_at = r.get("created_at", "Not Found")
230
  location = r.get("location", None)
231
  email = r.get("email", None)
232
- updated_at = r.get("updated_at", "Not Found")
233
  blog = r.get("blog", None)
234
  twitter = r.get("twitter_username", None)
235
 
@@ -254,10 +270,12 @@ async def github(_, m: Message):
254
  REPLY += f"\n<b>⚜️ Twitter:</b> <a href='https://twitter.com/{twitter}'>{twitter}</a>"
255
  if location:
256
  REPLY += f"\n<b>🚀 Location:</b> <code>{location}</code>"
257
- REPLY += f"\n<b>💫 Created at:</b> <code>{created_at}</code>"
258
- REPLY += f"\n<b>⌚️ Updated at:</b> <code>{updated_at}</code>"
 
 
259
  if bio:
260
- REPLY += f"\n\n<b>🎯 Bio:</b> <code>{bio}</code>"
261
 
262
  if avtar:
263
  return await m.reply_photo(photo=f"{avtar}", caption=REPLY)
@@ -266,14 +284,14 @@ async def github(_, m: Message):
266
 
267
 
268
  pattern = re.compile(r"^text/|json$|yaml$|xml$|toml$|x-sh$|x-shellscript$")
269
- BASE = "https://batbin.me/"
270
 
271
 
272
- async def paste(content: str):
273
- resp = await post(f"{BASE}api/v2/paste", data=content)
274
- if not resp["success"]:
275
  return
276
- return BASE + resp["message"]
277
 
278
 
279
  @Gojo.on_message(command("paste"))
@@ -289,7 +307,7 @@ async def paste_func(_, message: Message):
289
  return await m.edit("Only text and documents are supported")
290
 
291
  if r.text:
292
- content = str(r.text)
293
  if r.document:
294
  if r.document.file_size > 40000:
295
  return await m.edit("You can only paste files smaller than 40KB.")
@@ -300,11 +318,14 @@ async def paste_func(_, message: Message):
300
  doc = await message.reply_to_message.download()
301
 
302
  async with aiofiles.open(doc, mode="r") as f:
303
- content = await f.read()
 
304
 
305
  remove(doc)
306
-
307
- link = await paste(content)
 
 
308
  kb = [[InlineKeyboardButton(text="Paste Link ", url=link)]]
309
  await m.delete()
310
  try:
 
 
1
  import re
2
  from io import BytesIO
3
  from os import remove
 
18
  from Powers.utils.extract_user import extract_user
19
  from Powers.utils.http_helper import *
20
  from Powers.utils.parser import mention_html
21
+ from Powers.utils.web_helpers import telegraph_up
22
 
23
 
24
  @Gojo.on_message(command("wiki"))
 
117
  try:
118
  await em.edit_text(f"**{query.capitalize()} by {artist}**\n`{reply}`")
119
  except MessageTooLong:
120
+ header = f"{query.capitalize()} by {artist}"
121
+ page_url = await telegraph_up(name=header,content=reply)
122
+ kb = InlineKeyboardMarkup([
123
+ [
124
+ InlineKeyboardButton("Telegraph link", url=page_url)
125
+ ]
126
+ ])
127
  with BytesIO(str.encode(await remove_markdown_and_html(reply))) as f:
128
  f.name = "lyrics.txt"
129
  await m.reply_document(
130
  document=f,
131
+ reply_markup=kb
132
  )
133
  await em.delete()
134
  return
 
154
  if m.reply_to_message and m.reply_to_message.forward_from:
155
  user1 = m.reply_to_message.from_user
156
  user2 = m.reply_to_message.forward_from
157
+ orig_sender = await mention_html(user2.first_name, user2.id)
158
+ orig_id = f"<code>{user2.id}</code>"
159
+ fwd_sender = await mention_html(user1.first_name, user1.id)
160
+ fwd_id = f"<code>{user1.id}</code>"
161
  await m.reply_text(
162
  text=f"""Original Sender - {orig_sender} (<code>{orig_id}</code>)
163
  Forwarder - {fwd_sender} (<code>{fwd_id}</code>)""",
 
184
  text+=f"Forwarded from user ID <code>{m.forward_from.id}</code>."
185
  elif m.forward_from_chat:
186
  text+=f"Forwarded from user ID <code>{m.forward_from_chat.id}</code>."
187
+ if len(m.text.split()) > 1 and user_id:
188
+ text += f"\nGiven user's ID <code>{user_id}</code>"
189
+ await m.reply_text(text)
190
  else:
191
+ text=f"Chat ID <code>{m.chat.id}</code>\nYour ID <code>{m.from_user.id}</code>"
192
+ if len(m.text.split()) > 1 and user_id:
193
+ text += f"\nGiven user's ID <code>{user_id}</code>"
194
+ await m.reply_text(text)
195
  return
196
 
197
 
 
222
  f"Usage: <code>{Config.PREFIX_HANDLER}github username</code>",
223
  )
224
  return
225
+ username = username.split("/")[-1].strip("@")
226
  URL = f"https://api.github.com/users/{username}"
227
  try:
228
+ r = get(URL, timeout=5)
229
+ except requests.exceptions.ConnectTimeout:
230
  return await m.reply_text("request timeout")
231
  except Exception as e:
232
+ return await m.reply_text(f"ERROR:\n`{e}`")
233
+ if r.status_code != 200:
234
+ await m.reply_text(f"{username} this user is not available on github\nMake sure you have given correct username")
235
+ return
236
 
237
  avtar = r.get("avatar_url", None)
238
  url = r.get("html_url", None)
 
242
  following = r.get("following", 0)
243
  public_repos = r.get("public_repos", 0)
244
  bio = r.get("bio", None)
245
+ created_at = r.get("created_at", "NA").replace("T", " ").replace("Z","")
246
  location = r.get("location", None)
247
  email = r.get("email", None)
248
+ updated_at = r.get("updated_at", "NA").replace("T", " ").replace("Z","")
249
  blog = r.get("blog", None)
250
  twitter = r.get("twitter_username", None)
251
 
 
270
  REPLY += f"\n<b>⚜️ Twitter:</b> <a href='https://twitter.com/{twitter}'>{twitter}</a>"
271
  if location:
272
  REPLY += f"\n<b>🚀 Location:</b> <code>{location}</code>"
273
+ if created_at != "NA":
274
+ REPLY += f"\n<b>💫 Created at:</b> <code>{created_at}</code>"
275
+ if updated_at != "NA":
276
+ REPLY += f"\n<b>⌚️ Updated at:</b> <code>{updated_at}</code>"
277
  if bio:
278
+ REPLY += f"\n\n<b>🎯 Bio:</b> {bio}"
279
 
280
  if avtar:
281
  return await m.reply_photo(photo=f"{avtar}", caption=REPLY)
 
284
 
285
 
286
  pattern = re.compile(r"^text/|json$|yaml$|xml$|toml$|x-sh$|x-shellscript$")
287
+ BASE = "https://nekobin.com/"
288
 
289
 
290
+ def paste(content: str):
291
+ resp = post(f"{BASE}api/documents", data=content)
292
+ if resp.status_code != 200:
293
  return
294
+ return BASE + resp["result"]['key']
295
 
296
 
297
  @Gojo.on_message(command("paste"))
 
307
  return await m.edit("Only text and documents are supported")
308
 
309
  if r.text:
310
+ content = {'content':f'{r.text}'}
311
  if r.document:
312
  if r.document.file_size > 40000:
313
  return await m.edit("You can only paste files smaller than 40KB.")
 
318
  doc = await message.reply_to_message.download()
319
 
320
  async with aiofiles.open(doc, mode="r") as f:
321
+ fdata = await f.read()
322
+ content = {'content':fdata}
323
 
324
  remove(doc)
325
+ link = paste(content)
326
+ if not link:
327
+ await m.reply_text("Failed to post!")
328
+ return
329
  kb = [[InlineKeyboardButton(text="Paste Link ", url=link)]]
330
  await m.delete()
331
  try:
Powers/plugins/web_con.py ADDED
@@ -0,0 +1,239 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+
3
+ from pyrogram import filters
4
+ from pyrogram.types import CallbackQuery
5
+ from pyrogram.types import InlineKeyboardButton as IKB
6
+ from pyrogram.types import InlineKeyboardMarkup as IKM
7
+ from pyrogram.types import Message
8
+
9
+ from Powers import (LOGGER, RMBG, Audd, genius_lyrics, is_audd,
10
+ is_genius_lyrics, is_rmbg)
11
+ from Powers.bot_class import Gojo
12
+ from Powers.utils.custom_filters import command
13
+ from Powers.utils.http_helper import post
14
+ from Powers.utils.web_helpers import *
15
+
16
+
17
+ @Gojo.on_message(command(["telegraph","tgh","tgm"]))
18
+ async def telegraph_upload(c:Gojo,m:Message):
19
+ if not m.reply_to_message:
20
+ await m.reply_text("Reply to media/text to upload it to telegraph")
21
+ return
22
+ file = m.reply_to_message
23
+ if file.text:
24
+ if len(m.command) == 1:
25
+ name = file.from_user.first_name + file.text.split()[1]
26
+ elif len(m.command) > 1:
27
+ name = " ".join(m.command[1:5])
28
+ try:
29
+ upload = telegraph_up(file,name)
30
+ except Exception as e:
31
+ await m.reply_text(f"Got an error\n{e}")
32
+ return
33
+ if upload:
34
+ kb = IKM([[IKB("Here is link to file",url=upload)]])
35
+ await m.reply_text("Here is your uploaded file",disable_web_page_preview=True,reply_markup=kb)
36
+ return
37
+ elif not upload:
38
+ await m.reply_text("Failed to upload the text to telegraph")
39
+ return
40
+ size = await get_file_size(m.reply_to_message)
41
+ form = size.split(None,1)
42
+ if (form[-1] == "mb" and int(form[0]) > 5) or form[-1] == "gb":
43
+ await m.reply_text("File size too big to upload\nLimit: 5mbs")
44
+ return
45
+ try:
46
+ upload = telegraph_up(file)
47
+ except Exception as e:
48
+ await m.reply_text(f"Got an error\n{e}")
49
+ return
50
+ if upload:
51
+ kb = IKM([[IKB("Here is link to the file",url=upload)]])
52
+ await m.reply_text(f"Here is your file link\n`{upload}`",reply_markup=kb)
53
+ return
54
+ elif not upload:
55
+ await m.reply_text("Failed to upload the file to telegraph")
56
+ return
57
+
58
+ @Gojo.on_command(command["songname","insong","songinfo","whichsong","rsong","reversesong"])
59
+ async def get_song_info(c: Gojo, m: Message):
60
+ if not is_audd:
61
+ await m.reply_text("Audd api is missing add it to use this command")
62
+ return
63
+ reply = m.reply_to_message
64
+ if not reply:
65
+ await m.reply_text("Reply to a video or audio file")
66
+ return
67
+ elif not (reply.video or reply.audio or reply.video_note or (reply.document.mime_type.split("/")[0] in ["video","audio"])):
68
+ await m.reply_text("Reply to a video or audio file")
69
+ return
70
+ URL = "https://api.audd.io/"
71
+ sizee = (await get_file_size(reply)).split()
72
+ if (int(sizee[0]) <= 15 and sizee[1] == "mb") or sizee[1] == "kb":
73
+ fpath = await reply.download()
74
+ files = {
75
+ "file" : open(fpath,"rb")
76
+ }
77
+ BASE_AUDD = {
78
+ "api_token":Audd,
79
+ "return": "spotify"
80
+ }
81
+ result = post(URL,data=BASE_AUDD, files=files)
82
+ elif int(sizee[0]) > 15 or int(sizee[0]) <= 30 and sizee[1] == "mb":
83
+ BASE_AUDD = {
84
+ "api_token":Audd,
85
+ "url": f'{reply.link}',
86
+ "return": "spotify"
87
+ }
88
+ result = post(URL,data=BASE_AUDD)
89
+ else:
90
+ await m.reply_text("File size too big\nI can only fetch file of size upto 30 mbs for now")
91
+ return
92
+ os.remove(fpath)
93
+ if result.status_code != 200:
94
+ await m.reply_text(f"{result.status_code}:{result.text}")
95
+ return
96
+ data = result["result"]
97
+ Artist = data["artist"]
98
+ Title = data["title"]
99
+ Release_date = data["release_date"]
100
+ web_slink = data["song_link"]
101
+ SPOTIFY = data["spotify"]
102
+ spotify_url = SPOTIFY["external_urls"]
103
+ album_url = SPOTIFY["album"]["external_urls"]
104
+ Album = SPOTIFY["album"]["name"]
105
+ photo = SPOTIFY["images"][0]["url"]
106
+ artist_url = SPOTIFY["artists"]["external_urls"]
107
+ cap = f"""
108
+ Song name: {Title}
109
+ Artist: {Artist}
110
+ Album: {Album}
111
+ Release data: {Release_date}
112
+ """
113
+ kb = [
114
+ [
115
+ IKB("🗂 Album", url=album_url),
116
+ IKB("🎨 Artist",url=artist_url)
117
+ ],
118
+ [
119
+ IKB("🎵 Spotify song link",url=spotify_url),
120
+ IKB("♾ More links", url=web_slink)
121
+ ]
122
+ ]
123
+ if is_genius_lyrics:
124
+ g_k = [IKB("📝 Lyrics",f"lyrics_{Artist}:{Title}")]
125
+ kb.append(g_k)
126
+
127
+ await m.reply_photo(photo,caption=cap,reply_markup=IKM(kb))
128
+
129
+
130
+ @Gojo.on_callback_query(filters.regex("^lyrics_"))
131
+ async def lyrics_for_song(c: Gojo, q: CallbackQuery):
132
+ data = q.data.split("_")[1].split(":")
133
+ song = data[1]
134
+ artist = data[0]
135
+ song = genius_lyrics.search_song(song,artist)
136
+ if not song.lyrics:
137
+ await q.answer("‼️ No lyrics found ‼️",True)
138
+ return
139
+ header = f"{song.capitalize()} by {artist}"
140
+ if song.lyrics:
141
+ await q.answer("Fetching lyrics")
142
+ reply = song.lyrics.split("\n",1)[1]
143
+ if len(reply) >= 4096:
144
+ link = telegraph_up(name=header,content=reply)
145
+ cap = "Lyrics was too long\nUploaded it to telegraph"
146
+ new_kb = [
147
+ [
148
+ IKB("Telegraph",url=link)
149
+ ],
150
+ [
151
+ IKB("Close","f_close")
152
+ ]
153
+ ]
154
+ else:
155
+ cap = f"{header}\n{reply}"
156
+ new_kb = [
157
+ [
158
+ IKB("Close","f_close")
159
+ ]
160
+ ]
161
+ await q.message.reply_to_message.reply_text(cap,reply_markup=new_kb)
162
+ await q.message.delete()
163
+ return
164
+
165
+ @Gojo.on_message(command["removebackground","removebg","rmbg"])
166
+ async def remove_background(c: Gojo, m: Message):
167
+ if not is_rmbg:
168
+ await m.reply_text("Add rmbg api to use this command")
169
+ return
170
+
171
+ reply = m.reply_to_message
172
+ if not reply:
173
+ await m.reply_text("Reply to image to remove it's background")
174
+ return
175
+ elif not (reply.photo or reply.document.mime_type.split("/")[0] == "image" or reply.sticker and (reply.sticker.is_animated or reply.sticker.is_video)):
176
+ await m.reply_text("Reply to image to remove it's background")
177
+ return
178
+ URL = "https://api.remove.bg/v1.0/removebg"
179
+ file = await reply.download("Gojo_Satoru.png")
180
+ to_path = file.replace("\\","/").rsplit("/",1)[0]
181
+ finfo = {'image_file':open(file,'rb')}
182
+ Data = {'size':'auto'}
183
+ Headers = {'X-Api-Key':RMBG}
184
+ result = post(URL,files=finfo,data=Data,headers=Headers)
185
+ os.remove(file)
186
+ if result.status_code != 200:
187
+ await m.reply_text(f"{result.status_code}:{result.text}")
188
+ return
189
+ to_path = f'{to_path}/no-bg.png'
190
+ with open(to_path,'wb') as out:
191
+ out.write(result.content)
192
+ await m.reply_photo(to_path)
193
+ os.remove(to_path)
194
+ return
195
+
196
+ @Gojo.on_message(command(["song","yta"]))
197
+ async def song_down_up(c: Gojo, m: Message):
198
+ splited = m.text.split(None,1)[1].strip()
199
+ if splited.startswith("https://youtube.com"):
200
+ is_direct = True
201
+ query = splited
202
+ else:
203
+ is_direct = False
204
+ query = splited
205
+ try:
206
+ await youtube_downloader(c,m,query,is_direct,"a")
207
+ return
208
+ except Exception as e:
209
+ await m.reply_text(f"Got an error\n{e}")
210
+ return
211
+
212
+ @Gojo.on_message(command(["vsong","ytv"]))
213
+ async def video_down_up(c: Gojo, m: Message):
214
+ splited = m.text.split(None,1)[1].strip()
215
+ if splited.startswith("https://youtube.com"):
216
+ is_direct = True
217
+ query = splited
218
+ else:
219
+ is_direct = False
220
+ query = splited
221
+ try:
222
+ await youtube_downloader(c,m,query,is_direct,"v")
223
+ return
224
+ except Exception as e:
225
+ await m.reply_text(f"Got an error\n{e}")
226
+ return
227
+
228
+ __PLUGIN__ = "web support"
229
+
230
+ __HELP__ = """
231
+ **Available commands**
232
+ • /telegraph (/tgh, /tgm) <page name> : Reply to media which you want to upload to telegraph.
233
+ • /rmbg (/removebg, /removebackground) : Reply to image file or sticker of which you want to remove background
234
+ • /whichsong (/songname, /songinfo, /insong, /rsong, /reversesong) : Reply to file to get the song playing in it.
235
+ • /song (/yta) <songname or youtube link>
236
+ • /vsong (/ytv) <songname or youtube link>
237
+
238
+ **Bot will not download any song or video having duration greater than 5 minutes (to reduce the load on bot's server)**
239
+ """
Powers/utils/http_helper.py CHANGED
@@ -1,36 +1,34 @@
1
  from asyncio import gather
2
 
3
  # from Powers.bot_class import aiohttpsession as session
4
- import aiohttp
5
-
6
- async def get(url: str, *args, **kwargs):
7
- async with aiohttp.ClientSession() as session:
8
- async with session.get(url, *args, **kwargs) as resp:
9
- try:
10
- data = await resp.json()
11
- except Exception:
12
- data = await resp.text()
13
- return data
14
-
15
-
16
- async def head(url: str, *args, **kwargs):
17
- async with aiohttp.ClientSession() as session:
18
- async with session.head(url, *args, **kwargs) as resp:
19
- try:
20
- data = await resp.json()
21
- except Exception:
22
- data = await resp.text()
23
- return data
24
-
25
-
26
- async def post(url: str, *args, **kwargs):
27
- async with aiohttp.ClientSession() as session:
28
- async with session.post(url, *args, **kwargs) as resp:
29
- try:
30
- data = await resp.json()
31
- except Exception:
32
- data = await resp.text()
33
- return data
34
 
35
 
36
  async def multiget(url: str, times: int, *args, **kwargs):
@@ -45,9 +43,9 @@ async def multipost(url: str, times: int, *args, **kwargs):
45
  return await gather(*[post(url, *args, **kwargs) for _ in range(times)])
46
 
47
 
48
- async def resp_get(url: str, *args, **kwargs):
49
- return await session.get(url, *args, **kwargs)
50
 
51
 
52
- async def resp_post(url: str, *args, **kwargs):
53
- return await session.post(url, *args, **kwargs)
 
1
  from asyncio import gather
2
 
3
  # from Powers.bot_class import aiohttpsession as session
4
+ import requests
5
+
6
+
7
+ def get(url: str, *args, **kwargs):
8
+ resp = requests.get(url, *args, **kwargs)
9
+ try:
10
+ data = resp.json()
11
+ except Exception:
12
+ data = resp.text()
13
+ return data
14
+
15
+
16
+ def head(url: str, *args, **kwargs):
17
+ resp = requests.head(url, *args, **kwargs)
18
+ try:
19
+ data = resp.json()
20
+ except Exception:
21
+ data = resp.text()
22
+ return data
23
+
24
+
25
+ def post(url: str, *args, **kwargs):
26
+ resp = requests.post(url, *args, **kwargs)
27
+ try:
28
+ data = resp.json()
29
+ except Exception:
30
+ data = resp.text()
31
+ return data
 
 
32
 
33
 
34
  async def multiget(url: str, times: int, *args, **kwargs):
 
43
  return await gather(*[post(url, *args, **kwargs) for _ in range(times)])
44
 
45
 
46
+ def resp_get(url: str, *args, **kwargs):
47
+ return requests.get(url, *args, **kwargs)
48
 
49
 
50
+ def resp_post(url: str, *args, **kwargs):
51
+ return requests.post(url, *args, **kwargs)
Powers/utils/start_utils.py CHANGED
@@ -216,12 +216,17 @@ async def get_private_rules(_, m: Message, help_option: str):
216
  quote=True,
217
  )
218
  return ""
 
 
 
 
219
  await m.reply_text(
220
  f"""The rules for <b>{escape(chat_title)} are</b>:\n
221
- {rules}
222
  """,
223
  quote=True,
224
  disable_web_page_preview=True,
 
225
  )
226
  return ""
227
 
 
216
  quote=True,
217
  )
218
  return ""
219
+ teks, button = await parse_button(rules)
220
+ button = await build_keyboard(button)
221
+ button = ikb(button) if button else None
222
+ textt = teks
223
  await m.reply_text(
224
  f"""The rules for <b>{escape(chat_title)} are</b>:\n
225
+ {textt}
226
  """,
227
  quote=True,
228
  disable_web_page_preview=True,
229
+ reply_markup=button
230
  )
231
  return ""
232
 
Powers/utils/sticker_help.py ADDED
@@ -0,0 +1,242 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import asyncio
2
+ import math
3
+ import os
4
+ import shlex
5
+ import textwrap
6
+ from typing import List, Tuple
7
+
8
+ from PIL import Image, ImageDraw, ImageFont
9
+ from pyrogram import Client, errors, raw
10
+ from pyrogram.file_id import FileId
11
+
12
+
13
+ async def get_sticker_set_by_name(
14
+ client: Client, name: str
15
+ ) -> raw.base.messages.StickerSet:
16
+ try:
17
+ return await client.invoke(
18
+ raw.functions.messages.GetStickerSet(
19
+ stickerset=raw.types.InputStickerSetShortName(short_name=name),
20
+ hash=0,
21
+ )
22
+ )
23
+ except errors.exceptions.not_acceptable_406.StickersetInvalid:
24
+ return None
25
+
26
+
27
+
28
+ async def create_sticker_set(
29
+ client: Client,
30
+ owner: int,
31
+ title: str,
32
+ short_name: str,
33
+ stickers: List[raw.base.InputStickerSetItem],
34
+ animated:bool=False,
35
+ video:bool=False
36
+ ) -> raw.base.messages.StickerSet:
37
+ return await client.invoke(
38
+ raw.functions.stickers.CreateStickerSet(
39
+ user_id=await client.resolve_peer(owner),
40
+ title=title,
41
+ short_name=short_name,
42
+ stickers=stickers,
43
+ animated=animated,
44
+ videos=video
45
+ )
46
+ )
47
+
48
+
49
+ async def add_sticker_to_set(
50
+ client: Client,
51
+ stickerset: raw.base.messages.StickerSet,
52
+ sticker: raw.base.InputStickerSetItem,
53
+ ) -> raw.base.messages.StickerSet:
54
+ return await client.invoke(
55
+ raw.functions.stickers.AddStickerToSet(
56
+ stickerset=raw.types.InputStickerSetShortName(
57
+ short_name=stickerset.set.short_name
58
+ ),
59
+ sticker=sticker,
60
+ )
61
+ )
62
+
63
+
64
+ async def create_sticker(
65
+ sticker: raw.base.InputDocument, emoji: str
66
+ ) -> raw.base.InputStickerSetItem:
67
+ return raw.types.InputStickerSetItem(document=sticker, emoji=emoji)
68
+
69
+
70
+
71
+ STICKER_DIMENSIONS = (512, 512)
72
+
73
+
74
+ async def resize_file_to_sticker_size(file_path: str,length:int=512,width:int=512) -> str:
75
+ im = Image.open(file_path)
76
+ file_path = file_path.replace("\\","/").rsplit("/",1)[0]
77
+ if (im.width, im.height) < STICKER_DIMENSIONS:
78
+ size1 = im.width
79
+ size2 = im.height
80
+ if im.width > im.height:
81
+ scale = length / size1
82
+ size1new = length
83
+ size2new = size2 * scale
84
+ else:
85
+ scale = width / size2
86
+ size1new = size1 * scale
87
+ size2new = width
88
+ size1new = math.floor(size1new)
89
+ size2new = math.floor(size2new)
90
+ sizenew = (size1new, size2new)
91
+ im = im.resize(sizenew)
92
+ else:
93
+ im.thumbnail(STICKER_DIMENSIONS)
94
+ try:
95
+ os.remove(file_path)
96
+ file_path = f"{file_path}/resized.png"
97
+ return file_path
98
+ finally:
99
+ im.save(file_path)
100
+
101
+
102
+ async def upload_document(
103
+ client: Client, file_path: str, chat_id: int
104
+ ) -> raw.base.InputDocument:
105
+ media = await client.invoke(
106
+ raw.functions.messages.UploadMedia(
107
+ peer=await client.resolve_peer(chat_id),
108
+ media=raw.types.InputMediaUploadedDocument(
109
+ mime_type=client.guess_mime_type(file_path) or "application/zip",
110
+ file=await client.save_file(file_path),
111
+ attributes=[
112
+ raw.types.DocumentAttributeFilename(
113
+ file_name=os.path.basename(file_path)
114
+ )
115
+ ],
116
+ ),
117
+ )
118
+ )
119
+ return raw.types.InputDocument(
120
+ id=media.document.id,
121
+ access_hash=media.document.access_hash,
122
+ file_reference=media.document.file_reference,
123
+ )
124
+
125
+
126
+ async def get_document_from_file_id(
127
+ file_id: str,
128
+ ) -> raw.base.InputDocument:
129
+ decoded = FileId.decode(file_id)
130
+ return raw.types.InputDocument(
131
+ id=decoded.media_id,
132
+ access_hash=decoded.access_hash,
133
+ file_reference=decoded.file_reference,
134
+ )
135
+
136
+ async def draw_meme(image_path, text):
137
+ """Hellbot se churaya hai hue hue hue..."""
138
+ img = Image.open(image_path)
139
+ UwU = image_path.rsplit("/")[0]
140
+ os.remove(image_path)
141
+ i_width, i_height = img.size
142
+ m_font = ImageFont.truetype(
143
+ "./extras/comic.ttf", int((70 / 640) * i_width)
144
+ )
145
+ if ";" in text:
146
+ upper_text, lower_text = text.split(";")
147
+ else:
148
+ upper_text = text
149
+ lower_text = ""
150
+ draw = ImageDraw.Draw(img)
151
+ current_h, pad = 10, 5
152
+ if upper_text:
153
+ for u_text in textwrap.wrap(upper_text, width=15):
154
+ u_width, u_height = draw.textsize(u_text, font=m_font)
155
+ draw.text(
156
+ xy=(((i_width - u_width) / 2) - 1, int((current_h / 640) * i_width)),
157
+ text=u_text,
158
+ font=m_font,
159
+ fill=(0, 0, 0),
160
+ )
161
+ draw.text(
162
+ xy=(((i_width - u_width) / 2) + 1, int((current_h / 640) * i_width)),
163
+ text=u_text,
164
+ font=m_font,
165
+ fill=(0, 0, 0),
166
+ )
167
+ draw.text(
168
+ xy=((i_width - u_width) / 2, int(((current_h / 640) * i_width)) - 1),
169
+ text=u_text,
170
+ font=m_font,
171
+ fill=(0, 0, 0),
172
+ )
173
+ draw.text(
174
+ xy=(((i_width - u_width) / 2), int(((current_h / 640) * i_width)) + 1),
175
+ text=u_text,
176
+ font=m_font,
177
+ fill=(0, 0, 0),
178
+ )
179
+ draw.text(
180
+ xy=((i_width - u_width) / 2, int((current_h / 640) * i_width)),
181
+ text=u_text,
182
+ font=m_font,
183
+ fill=(255, 255, 255),
184
+ )
185
+ current_h += u_height + pad
186
+ if lower_text:
187
+ for l_text in textwrap.wrap(lower_text, width=15):
188
+ u_width, u_height = draw.textsize(l_text, font=m_font)
189
+ draw.text(
190
+ xy=(
191
+ ((i_width - u_width) / 2) - 1,
192
+ i_height - u_height - int((20 / 640) * i_width),
193
+ ),
194
+ text=l_text,
195
+ font=m_font,
196
+ fill=(0, 0, 0),
197
+ )
198
+ draw.text(
199
+ xy=(
200
+ ((i_width - u_width) / 2) + 1,
201
+ i_height - u_height - int((20 / 640) * i_width),
202
+ ),
203
+ text=l_text,
204
+ font=m_font,
205
+ fill=(0, 0, 0),
206
+ )
207
+ draw.text(
208
+ xy=(
209
+ (i_width - u_width) / 2,
210
+ (i_height - u_height - int((20 / 640) * i_width)) - 1,
211
+ ),
212
+ text=l_text,
213
+ font=m_font,
214
+ fill=(0, 0, 0),
215
+ )
216
+ draw.text(
217
+ xy=(
218
+ (i_width - u_width) / 2,
219
+ (i_height - u_height - int((20 / 640) * i_width)) + 1,
220
+ ),
221
+ text=l_text,
222
+ font=m_font,
223
+ fill=(0, 0, 0),
224
+ )
225
+ draw.text(
226
+ xy=(
227
+ (i_width - u_width) / 2,
228
+ i_height - u_height - int((20 / 640) * i_width),
229
+ ),
230
+ text=l_text,
231
+ font=m_font,
232
+ fill=(255, 255, 255),
233
+ )
234
+ current_h += u_height + pad
235
+
236
+ hue = f"{UwU}/@memesofdank_memer_hu_vai.png"
237
+ stick_path = await resize_file_to_sticker_size(hue)
238
+ mee = hue = f"{stick_path.rsplit('/',1)[0]}/@memesofdank_memer_hu_vai.webp"
239
+ os.remove(stick_path)
240
+ img.save(hue)
241
+ img.save(mee)
242
+ return hue, mee
Powers/utils/string.py CHANGED
@@ -6,6 +6,7 @@ from typing import List
6
  from pyrogram.enums import ChatType
7
  from pyrogram.types import InlineKeyboardButton, Message
8
 
 
9
  from Powers.utils.parser import escape_markdown
10
 
11
  BTN_URL_REGEX = compile_re(r"(\[([^\[]+?)\]\(buttonurl:(?:/{0,2})(.+?)(:same)?\))")
@@ -19,7 +20,7 @@ async def extract_time(m: Message, time_val: str):
19
  if not time_num.isdigit():
20
  await m.reply("Unspecified amount of time.")
21
  return ""
22
- initial_time = datetime.now()
23
  if unit == "m":
24
  bantime = initial_time + timedelta(minutes=int(time_num))
25
  elif unit == "h":
 
6
  from pyrogram.enums import ChatType
7
  from pyrogram.types import InlineKeyboardButton, Message
8
 
9
+ from Powers import TIME_ZONE
10
  from Powers.utils.parser import escape_markdown
11
 
12
  BTN_URL_REGEX = compile_re(r"(\[([^\[]+?)\]\(buttonurl:(?:/{0,2})(.+?)(:same)?\))")
 
20
  if not time_num.isdigit():
21
  await m.reply("Unspecified amount of time.")
22
  return ""
23
+ initial_time = datetime.now(TIME_ZONE)
24
  if unit == "m":
25
  bantime = initial_time + timedelta(minutes=int(time_num))
26
  elif unit == "h":
Powers/utils/web_helpers.py ADDED
@@ -0,0 +1,256 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import os
3
+ from urllib import parse
4
+
5
+ import yt_dlp
6
+ from pyrogram.types import InlineKeyboardButton as IKB
7
+ from pyrogram.types import InlineKeyboardMarkup as IKM
8
+ from pyrogram.types import Message
9
+ from telegraph import upload_file
10
+
11
+ from Powers import telegraph
12
+ from Powers.bot_class import Gojo
13
+ from Powers.utils.http_helper import *
14
+
15
+
16
+ async def get_file_size(file: Message):
17
+ if file.photo:
18
+ size = file.photo.file_size/1024
19
+ elif file.document:
20
+ size = file.document.file_size/1024
21
+ elif file.video:
22
+ size = file.video.file_size/1024
23
+
24
+ if size <= 1024:
25
+ return f"{round(size,3)} kb"
26
+ elif size > 1024:
27
+ size = size/1024
28
+ if size <= 1024:
29
+ return f"{round(size,3)} mb"
30
+ elif size > 1024:
31
+ size = size/1024
32
+ return f"{round(size,3)} gb"
33
+
34
+ async def telegraph_up(file:Message=None,name=None,content=None):
35
+ if not name:
36
+ name = "Captain_Ezio_Gojo_Bots"
37
+ if content:
38
+ page = telegraph.create_page(name,html_content=content)
39
+ if page:
40
+ return page['url']
41
+ else:
42
+ return
43
+ if file.text:
44
+ to_upload = file.text.html
45
+ page = telegraph.create_page(name,html_content=to_upload)
46
+ if page:
47
+ return page['url']
48
+ else:
49
+ return
50
+ doc = await file.download()
51
+ media_url = upload_file(doc)
52
+ tg_url = f"https://telegra.ph/{media_url[0]}"
53
+ os.remove(doc)
54
+ if tg_url:
55
+ return tg_url
56
+ else:
57
+ return
58
+
59
+ class GOJO_YTS:
60
+ """
61
+ A class to fetch link of from youtube using the name provided
62
+ Creadit: Hellbot
63
+ """
64
+ def __init__(self, search_terms: str, max_results=None):
65
+ self.search_terms = search_terms
66
+ self.max_results = max_results
67
+ self.videos = self._search()
68
+
69
+ def _search(self):
70
+ encoded_search = parse.quote_plus(self.search_terms)
71
+ BASE_URL = "https://youtube.com"
72
+ url = f"{BASE_URL}/results?search_query={encoded_search}"
73
+ response = get(url).text
74
+ while "ytInitialData" not in response:
75
+ response = get(url).text
76
+ results = self._parse_html(response)
77
+ if self.max_results is not None and len(results) > self.max_results:
78
+ return results[: self.max_results]
79
+ return results
80
+
81
+ def _parse_html(self, response):
82
+ results = []
83
+ start = response.index("ytInitialData") + len("ytInitialData") + 3
84
+ end = response.index("};", start) + 1
85
+ json_str = response[start:end]
86
+ data = json.loads(json_str)
87
+
88
+ videos = data["contents"]["twoColumnSearchResultsRenderer"]["primaryContents"][
89
+ "sectionListRenderer"
90
+ ]["contents"][0]["itemSectionRenderer"]["contents"]
91
+
92
+ for video in videos:
93
+ res = {}
94
+ if "videoRenderer" in video.keys():
95
+ video_data = video.get("videoRenderer", {})
96
+ res["id"] = video_data.get("videoId", None)
97
+ res["thumbnails"] = [
98
+ thumb.get("url", None)
99
+ for thumb in video_data.get("thumbnail", {}).get("thumbnails", [{}])
100
+ ]
101
+ res["title"] = (
102
+ video_data.get("title", {}).get("runs", [[{}]])[0].get("text", None)
103
+ )
104
+ res["long_desc"] = (
105
+ video_data.get("descriptionSnippet", {})
106
+ .get("runs", [{}])[0]
107
+ .get("text", None)
108
+ )
109
+ res["channel"] = (
110
+ video_data.get("longBylineText", {})
111
+ .get("runs", [[{}]])[0]
112
+ .get("text", None)
113
+ )
114
+ res["duration"] = video_data.get("lengthText", {}).get("simpleText", 0)
115
+ res["views"] = video_data.get("viewCountText", {}).get("simpleText", 0)
116
+ res["publish_time"] = video_data.get("publishedTimeText", {}).get(
117
+ "simpleText", 0
118
+ )
119
+ res["url_suffix"] = (
120
+ video_data.get("navigationEndpoint", {})
121
+ .get("commandMetadata", {})
122
+ .get("webCommandMetadata", {})
123
+ .get("url", None)
124
+ )
125
+ results.append(res)
126
+ return results
127
+
128
+ def to_dict(self, clear_cache=True):
129
+ result = self.videos
130
+ if clear_cache:
131
+ self.videos = ""
132
+ return result
133
+
134
+ def to_json(self, clear_cache=True):
135
+ result = json.dumps({"videos": self.videos})
136
+ if clear_cache:
137
+ self.videos = ""
138
+ return result
139
+
140
+
141
+ # Gets yt result of given query.
142
+ async def song_search(query, max_results=1):
143
+ try:
144
+ results = json.loads(GOJO_YTS(query, max_results=max_results).to_json())
145
+ except KeyError:
146
+ return
147
+ yt_dict = {}
148
+ if not (i['duration'] > 300):
149
+ nums = 1
150
+ for i in results["videos"]:
151
+ dict_form = {
152
+ "link": f"https://www.youtube.com{i['url_suffix']}",
153
+ "title": i['title'],
154
+ "views": i['views'],
155
+ "channel": i['channel'],
156
+ "duration": i['duration'],
157
+ "thumbnail": i['thumbnails'][0]
158
+ }
159
+ yt_dict.update({nums: dict_form})
160
+ nums += 1
161
+ else:
162
+ pass
163
+ return yt_dict
164
+
165
+ song_opts = {
166
+ "format": "bestaudio",
167
+ "addmetadata": True,
168
+ "key": "FFmpegMetadata",
169
+ "writethumbnail": True,
170
+ "prefer_ffmpeg": True,
171
+ "geo_bypass": True,
172
+ "nocheckcertificate": True,
173
+ "postprocessors": [
174
+ {
175
+ "key": "FFmpegExtractAudio",
176
+ "preferredcodec": "mp3",
177
+ "preferredquality": "480",
178
+ }
179
+ ],
180
+ "outtmpl": "%(id)s.mp3",
181
+ "quiet": True,
182
+ "logtostderr": False,
183
+ }
184
+
185
+
186
+ video_opts = {
187
+ "format": "best",
188
+ "addmetadata": True,
189
+ "key": "FFmpegMetadata",
190
+ "prefer_ffmpeg": True,
191
+ "geo_bypass": True,
192
+ "nocheckcertificate": True,
193
+ "postprocessors": [
194
+ {
195
+ "key": "FFmpegVideoConvertor",
196
+ "preferedformat": "mp4",
197
+ }
198
+ ],
199
+ "outtmpl": "%(id)s.mp4",
200
+ "logtostderr": False,
201
+ "quiet": True,
202
+ }
203
+
204
+
205
+
206
+ async def youtube_downloader(c:Gojo,m:Message,query:str,is_direct:bool,type_:str):
207
+ if type_ == "a":
208
+ opts = song_opts
209
+ video = False
210
+ song = True
211
+ elif type_ == "v":
212
+ opts = video_opts
213
+ video = True
214
+ song = False
215
+ ydl = yt_dlp.YoutubeDL(opts)
216
+ if is_direct:
217
+ query = query
218
+ else:
219
+ dicti = await song_search(query, 1)
220
+ if not dicti:
221
+ await m.reply_text("File with duration less than or equals to 5 minutes is allowed only")
222
+ return
223
+ query = dicti['link']
224
+ FILE = ydl.extract_info(query,download=False)
225
+ if FILE['duration'] > 300:
226
+ await m.reply_text("File with duration less than or equals to 5 minutes is allowed only")
227
+ return
228
+ f_name = FILE['title']
229
+ uploader = FILE['uploader']
230
+ up_url = FILE['uploader_url']
231
+ views = FILE['view_count']
232
+ url = f"https://www.youtube.com/watch?v={FILE['id']}"
233
+ f_path = ydl.prepare_filename(FILE)
234
+ ydl.download([query])
235
+ cap = f"""
236
+ ✘ Name: `{f_name}`
237
+ ✘ Views: `{views}`
238
+ """
239
+ kb = IKM(
240
+ [
241
+ [
242
+ IKB(f"✘ {uploader.capitalize()} ✘",url=f"{up_url}"),
243
+ IKB(f"✘ Youtube url ✘", url=f"{url}")
244
+ ]
245
+ ]
246
+ )
247
+ if video:
248
+ m.reply_video(f_path,caption=cap,reply_markup=kb)
249
+ os.remove(f_path)
250
+ return
251
+ elif song:
252
+ m.reply_audio(f_path,caption=cap,reply_markup=kb)
253
+ os.remove(f_path)
254
+ return
255
+
256
+
Powers/vars.py CHANGED
@@ -38,14 +38,18 @@ class Config:
38
  ).split(" ")
39
  ]
40
  GENIUS_API_TOKEN = config("GENIUS_API")
 
 
41
  DB_URI = config("DB_URI", default="")
42
  DB_NAME = config("DB_NAME", default="")
 
43
  NO_LOAD = config("NO_LOAD", default="").split()
44
  PREFIX_HANDLER = config("PREFIX_HANDLER", default="/").split()
45
  SUPPORT_GROUP = config("SUPPORT_GROUP", default="gojo_bots_network")
46
  SUPPORT_CHANNEL = config("SUPPORT_CHANNEL", default="gojo_bots_network")
47
  VERSION = config("VERSION", default="v2.0")
48
  WORKERS = int(config("WORKERS", default=16))
 
49
  BOT_USERNAME = ""
50
  BOT_ID = ""
51
  BOT_NAME = ""
@@ -69,8 +73,12 @@ class Development:
69
  DB_NAME = "" # Your DB name
70
  NO_LOAD = []
71
  GENIUS_API_TOKEN = ""
 
 
72
  PREFIX_HANDLER = ["!", "/"]
73
  SUPPORT_GROUP = "SUPPORT_GROUP"
74
  SUPPORT_CHANNEL = "SUPPORT_CHANNEL"
75
  VERSION = "VERSION"
 
 
76
  WORKERS = 8
 
38
  ).split(" ")
39
  ]
40
  GENIUS_API_TOKEN = config("GENIUS_API")
41
+ AuDD_API = config("AuDD_API")
42
+ RMBG_API = config("RMBG_API")
43
  DB_URI = config("DB_URI", default="")
44
  DB_NAME = config("DB_NAME", default="")
45
+ BDB_URI = config("BDB_URI")
46
  NO_LOAD = config("NO_LOAD", default="").split()
47
  PREFIX_HANDLER = config("PREFIX_HANDLER", default="/").split()
48
  SUPPORT_GROUP = config("SUPPORT_GROUP", default="gojo_bots_network")
49
  SUPPORT_CHANNEL = config("SUPPORT_CHANNEL", default="gojo_bots_network")
50
  VERSION = config("VERSION", default="v2.0")
51
  WORKERS = int(config("WORKERS", default=16))
52
+ TIME_ZONE = config("TIME_ZONE",default='Asia/Kolkata')
53
  BOT_USERNAME = ""
54
  BOT_ID = ""
55
  BOT_NAME = ""
 
73
  DB_NAME = "" # Your DB name
74
  NO_LOAD = []
75
  GENIUS_API_TOKEN = ""
76
+ AuDD_API = ""
77
+ RMBG_API = ""
78
  PREFIX_HANDLER = ["!", "/"]
79
  SUPPORT_GROUP = "SUPPORT_GROUP"
80
  SUPPORT_CHANNEL = "SUPPORT_CHANNEL"
81
  VERSION = "VERSION"
82
+ TIME_ZONE = 'Asia/Kolkata'
83
+ BDB_URI = ""
84
  WORKERS = 8
README.md CHANGED
@@ -267,19 +267,23 @@ To add your very own plugin just use the format given below and go through the [
267
 
268
  </p>--->
269
 
270
- * [PSYREX](https://github.com/iamPSYREX) `for logos`
 
 
271
 
272
  * [Dan](https://github.com/delivrance) for [pyrogram](https://github.com/pyrogram/pyrogram) `library`
273
 
274
- * [Alita_Robot](https://github.com/divideprojects/Alita_Robot)
 
 
 
275
  ---------
276
 
277
  # Powered by [ɢօʝօ ɮօȶֆ](https://github.com/Gojo-Bots)
278
 
279
 
280
  <p align='left'>
281
- <a href="https://github.com/Gojo-Bots"><img src="./extras/Untitled(1).webp" width="500"
282
- height="500 alt="Gojo Bots"></a></br></br>
283
 
284
  </p>
285
 
 
267
 
268
  </p>--->
269
 
270
+ Some special thanks to the person/repo who/which helped and motivated me for creating this project
271
+
272
+ * [PSYREX](https://github.com/iamPSYREX) for logos and motivatting me and giving me new ideas.
273
 
274
  * [Dan](https://github.com/delivrance) for [pyrogram](https://github.com/pyrogram/pyrogram) `library`
275
 
276
+ * [Anand](https://github.com/HellBoy-OP) for helping me to enhance bot's security and look and also helping me out with various stuffs and bugs and also for motivating me to create this project.
277
+
278
+ * [Alita_Robot](https://github.com/divideprojects/Alita_Robot) for base code.
279
+
280
  ---------
281
 
282
  # Powered by [ɢօʝօ ɮօȶֆ](https://github.com/Gojo-Bots)
283
 
284
 
285
  <p align='left'>
286
+ <a href="https://github.com/Gojo-Bots"><img src="https://artfiles.alphacoders.com/160/160160.jpeg" alt="Gojo Bots"></a></br></br>
 
287
 
288
  </p>
289
 
app.json CHANGED
@@ -87,6 +87,26 @@
87
  "required": false,
88
  "value": ""
89
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  "WORKERS": {
91
  "description": "Number of workers to run the bot.",
92
  "required": false,
 
87
  "required": false,
88
  "value": ""
89
  },
90
+ "AuDD_API" : {
91
+ "description": "Your Audd api to get info of song by music file",
92
+ "required": false,
93
+ "value": ""
94
+ },
95
+ "BDB_URI": {
96
+ "description": "Your mongodb uri different from previous one to store more info",
97
+ "required": true,
98
+ "value": ""
99
+ },
100
+ "TIME_ZONE": {
101
+ "description": "Your time zone",
102
+ "required": false,
103
+ "value": "Asia/Kolkata"
104
+ },
105
+ "RMBG_API" : {
106
+ "description": "Your removebackground api to remove the background",
107
+ "required": false,
108
+ "value": ""
109
+ },
110
  "WORKERS": {
111
  "description": "Number of workers to run the bot.",
112
  "required": false,
extras/Untitled(1).webp DELETED
Binary file (25.2 kB)
 
extras/comic.ttf ADDED
Binary file (133 kB). View file
 
extras/photo_2022-08-19_13-55-00.jpg DELETED
Binary file (292 kB)
 
requirements.txt CHANGED
@@ -1,6 +1,6 @@
1
  aiofiles==23.1.0; python_full_version >= "3.7"
2
- aiohttp==3.7.4; python_version >= "3.6" and python_version < "4.0"
3
  anyio==3.6.2; python_full_version >= "3.6.2" and python_version >= "3.6"
 
4
  asyncio==3.4.3
5
  beautifulsoup4==4.12.1; python_full_version >= "3.6"
6
  cachetools==5.2.0; python_version >= "3.7" and python_version < "4.0"
@@ -19,6 +19,7 @@ pyroaddon==1.0.6
19
  pyrogram==2.0.103; python_version >= "3.8"
20
  pysocks==1.7.1; python_version >= "3.7" and python_full_version < "3.0.0" and python_version < "4.0" or python_version >= "3.7" and python_version < "4.0" and python_full_version >= "3.4.0"
21
  python-dateutil==2.8.2; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.3.0")
 
22
  pyyaml==6.0; python_version >= "3.6"
23
  regex==2023.3.23; python_version >= "3.6"
24
  requests==2.28.2
@@ -27,6 +28,7 @@ search-engine-parser==0.6.8
27
  six==1.16.0; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.3.0"
28
  sniffio==1.3.0; python_full_version >= "3.6.2" and python_version >= "3.7"
29
  soupsieve==2.4; python_version >= "3.6" and python_full_version >= "3.6.0"
 
30
  tgcrypto==1.2.5; python_version >= "3.6" and python_version < "4.0"
31
  tswift==0.7.0
32
  typing-extensions==4.5.0; python_full_version >= "3.6.2" and python_version >= "3.7" and python_version < "3.8"
 
1
  aiofiles==23.1.0; python_full_version >= "3.7"
 
2
  anyio==3.6.2; python_full_version >= "3.6.2" and python_version >= "3.6"
3
+ apscheduler==3.10.1
4
  asyncio==3.4.3
5
  beautifulsoup4==4.12.1; python_full_version >= "3.6"
6
  cachetools==5.2.0; python_version >= "3.7" and python_version < "4.0"
 
19
  pyrogram==2.0.103; python_version >= "3.8"
20
  pysocks==1.7.1; python_version >= "3.7" and python_full_version < "3.0.0" and python_version < "4.0" or python_version >= "3.7" and python_version < "4.0" and python_full_version >= "3.4.0"
21
  python-dateutil==2.8.2; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.3.0")
22
+ pytz==2022.7.1
23
  pyyaml==6.0; python_version >= "3.6"
24
  regex==2023.3.23; python_version >= "3.6"
25
  requests==2.28.2
 
28
  six==1.16.0; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.3.0"
29
  sniffio==1.3.0; python_full_version >= "3.6.2" and python_version >= "3.7"
30
  soupsieve==2.4; python_version >= "3.6" and python_full_version >= "3.6.0"
31
+ telegraph==2.2.0
32
  tgcrypto==1.2.5; python_version >= "3.6" and python_version < "4.0"
33
  tswift==0.7.0
34
  typing-extensions==4.5.0; python_full_version >= "3.6.2" and python_version >= "3.7" and python_version < "3.8"