Captain Ezio commited on
Commit
b714805
·
1 Parent(s): 85a9168
Powers/plugins/afk.py DELETED
@@ -1,167 +0,0 @@
1
- from datetime import datetime
2
- from random import choice
3
-
4
- from pyrogram import filters
5
- from pyrogram.enums import ParseMode as PM
6
- from pyrogram.types import Message
7
-
8
- from Powers import LOGGER, PREFIX_HANDLER
9
- from Powers.bot_class import Gojo
10
- from Powers.database.afk_db import AFK
11
- from Powers.plugins import till_date
12
- from Powers.utils.cmd_senders import send_cmd
13
- from Powers.utils.custom_filters import command
14
- from Powers.utils.msg_types import Types, get_afk_type
15
- from Powers.vars import Config
16
-
17
- # from traceback import format_exc
18
-
19
- res = [
20
- "{first} is resting for a while...",
21
- "{first} living his real life, go and live yours.",
22
- "{first} is quite busy now-a-days.",
23
- "I am looking for {first} too...tell me if you see him/her around",
24
- "{first} ran away from the chat...",
25
- "{first} is busy in his/her work ||simping||",
26
- "{first} is busy saving the world",
27
- "{first} is now tired fighting all the curses"
28
- ]
29
-
30
- back = [
31
- "{first} is finally back to life",
32
- "{first} welcome back",
33
- "{first} the spy is back watch what you talk about"
34
- ]
35
-
36
- @Gojo.on_message(command(["afk","brb"]) & ~filters.private)
37
- async def going_afk(c: Gojo, m: Message):
38
- user = m.from_user.id
39
- chat = m.chat.id
40
- afk = AFK()
41
- text, data_type, content = await get_afk_type(m)
42
-
43
- time = str(datetime.now()).rsplit(".",1)[0]
44
-
45
- if len(m.command) == 1:
46
- text = choice(res)
47
-
48
- elif len(m.command) > 1:
49
- text = m.text.markdown.split(None,1)[1]
50
-
51
- if not data_type:
52
- data_type = Types.TEXT
53
-
54
- afk.insert_afk(chat,user,str(time),text,data_type,content)
55
-
56
- await m.reply_text(f"{m.from_user.mention} is now AFK")
57
-
58
- return
59
-
60
- async def get_hours(hour:str):
61
- tim = hour.strip().split(":")
62
- txt = ""
63
- if int(tim[0]):
64
- txt += tim[0] + " hours "
65
- if int(tim[1]):
66
- txt += tim[1] + " minutes "
67
- if int(round(float(tim[2]))):
68
- txt += str(round(float(tim[2]))) + " seconds"
69
-
70
- return txt
71
-
72
-
73
- @Gojo.on_message(filters.group,group=-18)
74
- async def afk_checker(c: Gojo, m: Message):
75
- if not m.from_user:
76
- return
77
-
78
- afk = AFK()
79
- back_ = choice(back)
80
- user = m.from_user.id
81
- chat = m.chat.id
82
- repl = m.reply_to_message
83
-
84
- if repl and repl.from_user:
85
- rep_user = repl.from_user.id
86
- else:
87
- rep_user = False
88
-
89
- is_afk = afk.check_afk(chat,user)
90
- is_rep_afk = False
91
- if rep_user:
92
- is_rep_afk = afk.check_afk(chat,rep_user)
93
-
94
- if is_rep_afk and rep_user != user:
95
- con = afk.get_afk(chat,rep_user)
96
- time = till_date(con["time"])
97
- media = con["media"]
98
- media_type = con["media_type"]
99
- tim_ = datetime.now() - time
100
- tim_ = str(tim_).split(",")
101
- tim = await get_hours(tim_[-1])
102
- if len(tim_) == 1:
103
- tims = tim
104
- elif len(tim_) == 2:
105
- tims = tim_[0] + " " + tim
106
- reason = f"{repl.from_user.first_name} is afk since {tims}\n"
107
- if con['reason'] not in res:
108
- reason += f"\nDue to: {con['reason'].format(first=repl.from_user.first_name)}"
109
- else:
110
- reason += f"\n{con['reason'].format(first=repl.from_user.first_name)}"
111
- txt = reason
112
-
113
- if media_type == Types.TEXT:
114
- await (await send_cmd(c,media_type))(
115
- chat,
116
- txt,
117
- parse_mode=PM.MARKDOWN,
118
- reply_to_message_id=m.id,
119
- )
120
- else:
121
- await (await send_cmd(c,media_type))(
122
- chat,
123
- media,
124
- txt,
125
- parse_mode=PM.MARKDOWN,
126
- reply_to_message_id=repl.id
127
- )
128
-
129
- if is_afk:
130
- txt = False
131
- try:
132
- txt = m.command[0]
133
- except Exception:
134
- pass
135
-
136
- if txt and txt in ["afk","brb"]:
137
- return
138
- else:
139
- con = afk.get_afk(chat,user)
140
- time = till_date(con["time"])
141
- tim_ = datetime.now() - time
142
- tim_ = str(tim_).split(",")
143
- tim = await get_hours(tim_[-1])
144
- if len(tim_) == 1:
145
- tims = tim
146
- elif len(tim_) == 2:
147
- tims = tim_[0] + " " + tim
148
- txt = back_.format(first=m.from_user.mention) + f"\n\nAfk for: {tims}"
149
- await m.reply_text(txt)
150
- afk.delete_afk(chat,user)
151
- return
152
-
153
- __PLUGIN__ = "afk"
154
-
155
- _DISABLE_CMDS_ = ["afk","brb"]
156
-
157
- __alt_name__ = ["brb"]
158
-
159
- __HELP__ = """
160
- **AFK**
161
- • /afk (/brb) [reason | reply to a message]
162
-
163
- `reply to a message` can be any media or text
164
- """
165
-
166
-
167
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Powers/plugins/captcha.py DELETED
@@ -1,234 +0,0 @@
1
- from random import shuffle
2
- from traceback import format_exc
3
-
4
- import pyrogram # don't remove
5
- from pyrogram import filters
6
- from pyrogram.enums import ChatMemberStatus as CMS
7
- from pyrogram.types import CallbackQuery, ChatMemberUpdated, ChatPermissions
8
- from pyrogram.types import InlineKeyboardButton as ikb
9
- from pyrogram.types import InlineKeyboardMarkup as ikm
10
- from pyrogram.types import Message
11
-
12
- from Powers import LOGGER
13
- from Powers.bot_class import Gojo
14
- from Powers.database.captcha_db import CAPTCHA, CAPTCHA_DATA
15
- from Powers.supports import get_support_staff
16
- from Powers.utils.captcha_helper import (genrator, get_image_captcha,
17
- get_qr_captcha)
18
- from Powers.utils.custom_filters import admin_filter, command
19
-
20
- SUPPORT_STAFF = get_support_staff()
21
-
22
- @Gojo.on_message(command("captcha") & admin_filter & ~filters.private)
23
- async def start_captcha(c: Gojo, m: Message):
24
- captcha = CAPTCHA()
25
- split = m.command
26
- if len(split) == 1:
27
- is_cap = captcha.is_captcha(m.chat.id)
28
- if is_cap:
29
- txt = "Captcha verification is currently **on** for this chat"
30
- else:
31
- txt = "Captcha verification is currently **off** for this chat"
32
- await m.reply_text(txt)
33
- return
34
- else:
35
- on_off = split[1].lower()
36
- if on_off in ["on","yes","enable"]:
37
- captcha.insert_captcha(m.chat.id)
38
- await m.reply_text("Captcha verification is now **on** for this chat")
39
- return
40
- elif on_off in ["off","no","disable"]:
41
- captcha.remove_captcha(m.chat.id)
42
- await m.reply_text("Captcha verification is now **off** for this chat")
43
- return
44
- else:
45
- await m.reply_text("**USAGE**\n/captcha [on | yes | enable | off | no | disable]")
46
- return
47
-
48
- @Gojo.on_message(command("captchamode") & admin_filter & ~filters.private)
49
- async def set_captcha_mode(c: Gojo, m: Message):
50
- split = m.command
51
- captcha = CAPTCHA()
52
- if len(split) == 1:
53
- curr = captcha.get_captcha(m.chat.id)
54
- if curr:
55
- capatcha_type = curr["captcha_type"]
56
- await m.reply_text(f"Current captcha verification methode is {capatcha_type}\nAvailable methodes:\n■ qr\n■ image")
57
- return
58
- else:
59
- await m.reply_text("Captcha verification is off for the current chat")
60
- return
61
- else:
62
- type_ = split[1].lower()
63
- if type_ == "qr":
64
- captcha.update_type(m.chat.id, "qr")
65
- await m.reply_text("Captcha verification is now changed to qr code")
66
- return
67
- elif type_ == "image":
68
- captcha.update_type(m.chat.id,"image")
69
- await m.reply_text("Captcha verication is now changed to image")
70
- return
71
- else:
72
- await m.reply_text("**USAGE**\n/captchamode [qr | image]")
73
- return
74
-
75
- @Gojo.on_chat_member_updated(filters.group,18)
76
- async def joinss(c: Gojo, u: ChatMemberUpdated):
77
- chat = u.chat.id
78
-
79
- if (
80
- u.new_chat_member
81
- ):
82
- pass
83
- else:
84
- return
85
-
86
- user = u.new_chat_member.user.id
87
- userr = u.new_chat_member.user
88
-
89
- is_qr = CAPTCHA().is_captcha(chat)
90
- if not is_qr:
91
- return
92
-
93
- captcha = CAPTCHA()
94
- cap_data = CAPTCHA_DATA()
95
-
96
- if user in SUPPORT_STAFF:
97
- return
98
-
99
- captcha_type = captcha.get_captcha(chat)
100
-
101
- is_already = cap_data.is_already_data(chat, user)
102
-
103
- mess = False
104
- try:
105
- if is_already:
106
- mess = await c.get_messages(chat,int(is_already))
107
- except Exception:
108
- cap_data.del_message_id(chat,is_already)
109
- mess = False
110
- is_already = False
111
-
112
- if is_already and not mess:
113
- cap_data.del_message_id(chat,is_already)
114
- return
115
-
116
- try:
117
- await c.restrict_chat_member(chat,user,ChatPermissions())
118
- except Exception as e:
119
- LOGGER.error(e)
120
- LOGGER.error(format_exc())
121
- return
122
-
123
- if not is_already:
124
- if captcha_type == "qr":
125
- pic = await get_qr_captcha(chat, user)
126
- cap = f"Please {userr.mention} scan this qr code with your phone to verify that you are human"
127
- ms = await c.send_photo(chat,pic,caption=cap)
128
- cap_data.store_message_id(chat,user,ms.id)
129
- return
130
- elif captcha_type == "image":
131
- img, code = await get_image_captcha(chat, user)
132
- cap = f"Please {userr.mention} please choose the correct code from the one given bellow\nYou have three tries if you get all three wrong u will be kicked from the chat.\nTries left: 3"
133
- cap_data.load_cap_data(chat, user, code)
134
- rand = [code]
135
- while len(rand) != 5:
136
- hehe = genrator()
137
- rand.append(hehe)
138
-
139
- shuffle(rand)
140
-
141
- ini = f"captcha_{chat}_{user}_"
142
-
143
- kb = ikm(
144
- [
145
- [
146
- ikb(rand[0],ini+rand[0])
147
- ],
148
- [
149
- ikb(rand[1],ini+rand[1])
150
- ],
151
- [
152
- ikb(rand[2],ini+rand[2])
153
- ],
154
- [
155
- ikb(rand[3],ini+rand[3])
156
- ],
157
- [
158
- ikb(rand[4],ini+rand[4])
159
- ]
160
- ]
161
- )
162
- await c.send_photo(chat,img,caption=cap,reply_markup=kb)
163
- return
164
- elif is_already and mess:
165
- kb = ikm(
166
- [
167
- [
168
- ikb("Click here to verify",url=mess.link)
169
- ]
170
- ]
171
- )
172
- await c.send_message(f"{userr.mention} your verification is already pending",reply_markup=kb)
173
- return
174
- else:
175
- await c.unban_chat_member(chat,user)
176
- return
177
-
178
- @Gojo.on_callback_query(filters.regex("^captcha_"))
179
- async def captcha_codes_check(c: Gojo, q: CallbackQuery):
180
- split = q.data.split("_")
181
- chat = int(split[1])
182
- user = int(split[2])
183
- code = split[3]
184
-
185
- if q.from_user.id != user:
186
- await q.answer("Not for you BAKA!")
187
- return
188
-
189
- c_data = CAPTCHA_DATA()
190
- code_ = c_data.get_cap_data(chat,user)
191
-
192
-
193
- if code_ == code:
194
- cap = "You guessed the captcha right...Now you can talk in the chat with no restrictions"
195
- c_data.remove_cap_data(chat,user)
196
- await q.answer(cap,True)
197
- try:
198
- await q.message.chat.unban_member(user)
199
- except Exception as e:
200
- await q.message.reply_text(f"Unable to unmute {q.from_user.mention} this user")
201
- await q.message.reply_text(e)
202
- return
203
- await c.send_message(chat,f"{q.from_user.mention} now you are free to talk")
204
- await q.message.delete()
205
- return
206
- else:
207
- caps = q.message.caption.split(":")
208
- tries = int(caps[1].strip()) - 1
209
- caps.pop(-1)
210
- caps.append(f" {tries}")
211
- new_cap = ":".join(caps)
212
- await q.answer(f"Wrong\nTries left: {tries}", True)
213
- if not tries:
214
- new_cap = f"You have zero tries left now. I am going to kick you know coz you failed to solve captcha...see yaa {q.from_user.mention}"
215
- try:
216
- await q.message.chat.ban_member(user)
217
- except Exception as e:
218
- await q.message.reply_text("Failed to kick member")
219
- return
220
- await q.message.delete()
221
- await q.message.reply_text(new_cap)
222
- await c.unban_chat_member(chat,user)
223
-
224
- else:
225
- await q.edit_message_caption(new_cap,reply_markup=q.message.reply_markup)
226
- return
227
-
228
-
229
- __PLUGIN__ = "captcha"
230
-
231
- __HELP__ = """
232
- • /captcha [on|yes|enable|off|no|disable] : To enable or disable captcha verification
233
- • /captchamode [qr|image] : To change captcha mode
234
- """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Powers/plugins/start.py CHANGED
@@ -13,13 +13,13 @@ from pyrogram.types import (CallbackQuery, InlineKeyboardButton,
13
  from Powers import (HELP_COMMANDS, LOGGER, PYROGRAM_VERSION, PYTHON_VERSION,
14
  UPTIME, VERSION)
15
  from Powers.bot_class import Gojo
16
- from Powers.database.captcha_db import CAPTCHA_DATA
17
  from Powers.utils.custom_filters import command
18
  from Powers.utils.extras import StartPic
19
  from Powers.utils.kbhelpers import ikb
20
  from Powers.utils.start_utils import (gen_cmds_kb, gen_start_kb, get_help_msg,
21
  get_private_note, get_private_rules)
22
- from Powers.utils.string import encode_decode
23
  from Powers.vars import Config
24
 
25
 
 
13
  from Powers import (HELP_COMMANDS, LOGGER, PYROGRAM_VERSION, PYTHON_VERSION,
14
  UPTIME, VERSION)
15
  from Powers.bot_class import Gojo
16
+ # from Powers.database.captcha_db import CAPTCHA_DATA
17
  from Powers.utils.custom_filters import command
18
  from Powers.utils.extras import StartPic
19
  from Powers.utils.kbhelpers import ikb
20
  from Powers.utils.start_utils import (gen_cmds_kb, gen_start_kb, get_help_msg,
21
  get_private_note, get_private_rules)
22
+ # from Powers.utils.string import encode_decode
23
  from Powers.vars import Config
24
 
25
 
Version/version 2.2.0.md DELETED
@@ -1,21 +0,0 @@
1
- # V 2.1.1
2
- ### Changes made:
3
- - Added `AFK` support.
4
- - Added `Captcha verification` for new joined members.
5
- - Added support for `join request` in the chat.
6
- - Now `lock types` will be stored in database.
7
- - Improved **youtube support** to provide best quality.
8
- - Now you can kang `video sticker` by replying to **videos** and **animations**.
9
- - Added few commands for **devs**.
10
- - Improved stability and few minor improvements.
11
- - Few bug fixes.
12
- - Bug known: 0
13
- - Deployed and tested locally
14
-
15
- ## Report issues [here](https://github.com/Gojo-Bots/Gojo_Satoru/issues/new/choose) if find any.
16
-
17
- ## Give ideas [here](https://github.com/Gojo-Bots/Gojo_Satoru/discussions/new?category=ideas) for next update.
18
-
19
- ## Trying our best to give the best
20
-
21
- ## Regards 🧑‍💻: [Captain D. Ezio](https://github.com/iamgojoof6eyes)