Captain Ezio commited on
Commit
a3d4486
·
2 Parent(s): 99cea5b da5475e

New Version `2.1.1`

Browse files

Merge pull request #119 from Gojo-Bots/beta

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