Captain Ezio commited on
Commit
0a322f4
·
2 Parent(s): 9015bc5 99cea5b

Merge pull request #106 from Gojo-Bots/main

Browse files
.github/workflows/check_requirements.yml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Check requirements
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ check_requirements:
7
+ runs-on: ubuntu-latest
8
+
9
+ strategy:
10
+ matrix:
11
+ python-version: [">=3.9"]
12
+
13
+ steps:
14
+ - name: Checkout code
15
+ uses: actions/checkout@v3
16
+
17
+ - name: Set up Python environment
18
+ uses: actions/setup-python@v4
19
+ with:
20
+ python-version: ${{ matrix.python-version }}
21
+
22
+ - name: Install dependencies
23
+ run: pip install -r requirements.txt
24
+
25
+ - name: Check for conflicting libraries
26
+ run: pip check
.github/workflows/pre-commit-autoupdate.yml CHANGED
@@ -15,7 +15,7 @@ jobs:
15
  - name: Run pre-commit autoupdate
16
  run: pre-commit autoupdate
17
  - name: Create Pull Request
18
- uses: peter-evans/create-pull-request@v4
19
  with:
20
  token: ${{ secrets.GITHUB_TOKEN }}
21
  branch: update/pre-commit-autoupdate
 
15
  - name: Run pre-commit autoupdate
16
  run: pre-commit autoupdate
17
  - name: Create Pull Request
18
+ uses: peter-evans/create-pull-request@v5
19
  with:
20
  token: ${{ secrets.GITHUB_TOKEN }}
21
  branch: update/pre-commit-autoupdate
.gitignore CHANGED
@@ -1,6 +1,7 @@
1
  *.session
2
  *.session-journal
3
  Powers/config.py
 
4
  .vscode/
5
  postgres-data/
6
  *.env
 
1
  *.session
2
  *.session-journal
3
  Powers/config.py
4
+ Powers/vars.py
5
  .vscode/
6
  postgres-data/
7
  *.env
.pre-commit-config.yaml CHANGED
@@ -12,7 +12,7 @@ repos:
12
  - id: check-merge-conflict
13
 
14
  - repo: https://github.com/psf/black
15
- rev: 23.1.0
16
  hooks:
17
  - id: black
18
  language_version: python3
 
12
  - id: check-merge-conflict
13
 
14
  - repo: https://github.com/psf/black
15
+ rev: 23.3.0
16
  hooks:
17
  - id: black
18
  language_version: python3
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
@@ -3,7 +3,6 @@ from threading import RLock
3
  from time import gmtime, strftime, time
4
 
5
  import pyroaddon
6
- from aiohttp import ClientSession
7
  from pyrogram import Client, __version__
8
  from pyrogram.raw.all import layer
9
  from pyrogram.types import BotCommand
@@ -23,7 +22,6 @@ if MESSAGE_DUMP == -100 or not str(MESSAGE_DUMP).startswith("-100"):
23
  "Please enter a vaild Supergroup ID, A Supergroup ID starts with -100",
24
  )
25
 
26
- aiohttpsession = ClientSession()
27
 
28
 
29
  class Gojo(Client):
@@ -112,10 +110,3 @@ class Gojo(Client):
112
  Runtime: {runtime}s\n
113
  """,
114
  )
115
- LOGGER.info(
116
- "Closing client session"
117
- )
118
- await aiohttpsession.close()
119
- LOGGER.info(
120
- "Client session closed"
121
- )
 
3
  from time import gmtime, strftime, time
4
 
5
  import pyroaddon
 
6
  from pyrogram import Client, __version__
7
  from pyrogram.raw.all import layer
8
  from pyrogram.types import BotCommand
 
22
  "Please enter a vaild Supergroup ID, A Supergroup ID starts with -100",
23
  )
24
 
 
25
 
26
 
27
  class Gojo(Client):
 
110
  Runtime: {runtime}s\n
111
  """,
112
  )
 
 
 
 
 
 
 
Powers/plugins/admin.py CHANGED
@@ -27,7 +27,7 @@ from Powers.vars import Config
27
  @Gojo.on_message(command("adminlist"))
28
  async def adminlist_show(_, m: Message):
29
  global ADMIN_CACHE
30
- if m.chat.type != ChatType.CHANNEL:
31
  return await m.reply_text(
32
  text="This command is made to be used in groups only!",
33
  )
 
27
  @Gojo.on_message(command("adminlist"))
28
  async def adminlist_show(_, m: Message):
29
  global ADMIN_CACHE
30
+ if m.chat.type not in [ChatType.SUPERGROUP,ChatType.GROUP]:
31
  return await m.reply_text(
32
  text="This command is made to be used in groups only!",
33
  )
Powers/plugins/dev.py CHANGED
@@ -14,7 +14,7 @@ from pyrogram.types import Message
14
 
15
  from Powers import (BOT_TOKEN, DEV_USERS, LOG_DATETIME, LOGFILE, LOGGER,
16
  MESSAGE_DUMP, OWNER_ID, UPTIME)
17
- from Powers.bot_class import Gojo, aiohttpsession
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
@@ -319,13 +319,6 @@ async def stop_and_send_logger(c:Gojo,is_update=False):
319
  Runtime: {runtime}s\n
320
  """,
321
  )
322
- LOGGER.info(
323
- "Closing client session"
324
- )
325
- await aiohttpsession.close()
326
- LOGGER.info(
327
- "Client session closed"
328
- )
329
  return
330
 
331
  @Gojo.on_message(command(["restart", "update"], owner_cmd=True))
 
14
 
15
  from Powers import (BOT_TOKEN, DEV_USERS, LOG_DATETIME, LOGFILE, LOGGER,
16
  MESSAGE_DUMP, OWNER_ID, UPTIME)
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
 
319
  Runtime: {runtime}s\n
320
  """,
321
  )
 
 
 
 
 
 
 
322
  return
323
 
324
  @Gojo.on_message(command(["restart", "update"], owner_cmd=True))
Powers/plugins/giveaway.py CHANGED
@@ -46,10 +46,16 @@ async def start_give_one(c: Gojo, m: Message):
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() == "yes":
50
  await c.send_message(m.chat.id,"Done")
51
  while True:
52
  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)
 
 
 
53
  if yes_no.text.lower() == "yes":
54
  is_old = 0
55
  break
@@ -77,14 +83,14 @@ async def start_give_one(c: Gojo, m: Message):
77
  while True:
78
  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)
79
  if channel_id.text:
80
- if str(channel_id.text).lower() == "/cancel":
81
-
82
  await c.send_message(m.from_user.id, "Cancelled")
 
83
  try:
84
  c_id = int(channel_id.text)
85
  try:
86
  bot_stat = (await c.get_chat_member(c_id,Config.BOT_ID)).status
87
- if bot_stat == CMS.ADMINISTRATOR:
88
  break
89
  else:
90
  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")
@@ -99,7 +105,7 @@ async def start_give_one(c: Gojo, m: Message):
99
  if channel_id.forward_from_chat:
100
  try:
101
  bot_stat = (await c.get_chat_member(c_id,Config.BOT_ID)).status
102
- if bot_stat == CMS.ADMINISTRATOR:
103
  break
104
  else:
105
  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")
@@ -114,6 +120,7 @@ async def start_give_one(c: Gojo, m: Message):
114
  if chat_id.text:
115
  if str(chat_id.text).lower() == "/cancel":
116
  await c.send_message(m.from_user.id, "Cancelled")
 
117
  try:
118
  cc_id = int(chat_id.text)
119
  try:
@@ -130,6 +137,14 @@ async def start_give_one(c: Gojo, m: Message):
130
  await c.send_message(m.chat.id,f"Looks like chat doesn't exist{e}")
131
  except ValueError:
132
  await c.send_message(m.chat.id,"Chat id should be integer type")
 
 
 
 
 
 
 
 
133
 
134
  await c.send_message(m.chat.id,"Chat id received")
135
 
 
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
 
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")
 
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")
 
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:
 
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
 
Powers/utils/http_helper.py CHANGED
@@ -1,33 +1,36 @@
1
  from asyncio import gather
2
 
3
- from Powers.bot_class import aiohttpsession as session
4
-
5
 
6
  async def get(url: str, *args, **kwargs):
7
- async with session.get(url, *args, **kwargs) as resp:
8
- try:
9
- data = await resp.json()
10
- except Exception:
11
- data = await resp.text()
12
- return data
 
13
 
14
 
15
  async def head(url: str, *args, **kwargs):
16
- async with session.head(url, *args, **kwargs) as resp:
17
- try:
18
- data = await resp.json()
19
- except Exception:
20
- data = await resp.text()
21
- return data
 
22
 
23
 
24
  async def post(url: str, *args, **kwargs):
25
- async with session.post(url, *args, **kwargs) as resp:
26
- try:
27
- data = await resp.json()
28
- except Exception:
29
- data = await resp.text()
30
- return data
 
31
 
32
 
33
  async def multiget(url: str, times: int, *args, **kwargs):
 
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):
Powers/utils/msg_types.py CHANGED
@@ -98,7 +98,7 @@ async def get_filter_type(m: Message):
98
 
99
  if not m.reply_to_message and m.text and len(m.text.split()) >= 3:
100
  content = None
101
- text = m.text.split(None, 2)[2]
102
  data_type = Types.TEXT
103
 
104
  elif m.reply_to_message:
@@ -165,7 +165,7 @@ async def get_wlcm_type(m: Message):
165
 
166
  if not m.reply_to_message and m.text and len(m.text.split()) >= 2:
167
  content = None
168
- text = m.text.split(None, 1)[1]
169
  data_type = Types.TEXT
170
 
171
  elif m.reply_to_message:
 
98
 
99
  if not m.reply_to_message and m.text and len(m.text.split()) >= 3:
100
  content = None
101
+ text = m.text.markdown.split(None, 2)[2]
102
  data_type = Types.TEXT
103
 
104
  elif m.reply_to_message:
 
165
 
166
  if not m.reply_to_message and m.text and len(m.text.split()) >= 2:
167
  content = None
168
+ text = m.text.markdown.split(None, 1)[1]
169
  data_type = Types.TEXT
170
 
171
  elif m.reply_to_message:
Powers/vars.py CHANGED
@@ -63,7 +63,7 @@ class Development:
63
  OWNER_ID = 1344569458 # Your telegram user id defult to mine
64
  MESSAGE_DUMP = -100 # Your Private Group ID for logs
65
  DEV_USERS = []
66
- SUDO_USERS = []
67
  WHITELIST_USERS = []
68
  DB_URI = "" # Your mongo DB URI
69
  DB_NAME = "" # Your DB name
 
63
  OWNER_ID = 1344569458 # Your telegram user id defult to mine
64
  MESSAGE_DUMP = -100 # Your Private Group ID for logs
65
  DEV_USERS = []
66
+ SUDO_USERS = [1906306037]
67
  WHITELIST_USERS = []
68
  DB_URI = "" # Your mongo DB URI
69
  DB_NAME = "" # Your DB name
requirements.txt CHANGED
@@ -2,7 +2,7 @@ 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.11.2; python_full_version >= "3.6"
6
  cachetools==5.2.0; python_version >= "3.7" and python_version < "4.0"
7
  certifi==2022.12.7; python_version >= "3.7" and python_version < "4"
8
  charset-normalizer==2.1.0; python_version >= "3.7" and python_version < "4" and python_full_version >= "3.6.0"
@@ -16,11 +16,11 @@ 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.102; 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==2022.10.31; 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
 
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"
7
  certifi==2022.12.7; python_version >= "3.7" and python_version < "4"
8
  charset-normalizer==2.1.0; python_version >= "3.7" and python_version < "4" and python_full_version >= "3.6.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