xync-bot 0.3.3__py3-none-any.whl → 0.3.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of xync-bot might be problematic. Click here for more details.
- xync_bot/handlers/main.py +25 -47
- {xync_bot-0.3.3.dist-info → xync_bot-0.3.5.dist-info}/METADATA +1 -1
- {xync_bot-0.3.3.dist-info → xync_bot-0.3.5.dist-info}/RECORD +5 -5
- {xync_bot-0.3.3.dist-info → xync_bot-0.3.5.dist-info}/WHEEL +1 -1
- {xync_bot-0.3.3.dist-info → xync_bot-0.3.5.dist-info}/top_level.txt +0 -0
xync_bot/handlers/main.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import logging
|
|
2
|
-
from os import path
|
|
3
2
|
|
|
4
3
|
from aiogram import Router, F
|
|
5
4
|
from aiogram.enums import ContentType
|
|
@@ -13,9 +12,7 @@ from aiogram.types import (
|
|
|
13
12
|
InlineKeyboardMarkup,
|
|
14
13
|
InlineKeyboardButton,
|
|
15
14
|
CallbackQuery,
|
|
16
|
-
ChatJoinRequest,
|
|
17
15
|
WebAppInfo,
|
|
18
|
-
FSInputFile,
|
|
19
16
|
)
|
|
20
17
|
from aiogram.utils.deep_linking import create_start_link
|
|
21
18
|
from xync_bot.handlers import user_upsert
|
|
@@ -132,63 +129,44 @@ async def my_user_set_status(my_chat_member: ChatMemberUpdated):
|
|
|
132
129
|
|
|
133
130
|
@main.my_chat_member()
|
|
134
131
|
async def user_set_status(my_chat_member: ChatMemberUpdated):
|
|
132
|
+
if my_chat_member.new_chat_member.user.username == "XyncNetBot": # удалена группа где бот был добавлен админом
|
|
133
|
+
if forum := await Forum.get_or_none(id=my_chat_member.chat.id):
|
|
134
|
+
await forum.delete()
|
|
135
|
+
res = f"I {my_chat_member.new_chat_member.status} from {my_chat_member.chat.id}:{my_chat_member.chat.title}"
|
|
136
|
+
return logging.info(res)
|
|
135
137
|
logging.info({"my_chat_member": my_chat_member.model_dump(exclude_none=True)})
|
|
136
138
|
u: TgUser = my_chat_member.from_user
|
|
137
139
|
blocked = my_chat_member.new_chat_member.status in ("left", "kicked")
|
|
140
|
+
if blocked:
|
|
141
|
+
if forum := await Forum.get_or_none(id=my_chat_member.chat.id, user_id=u.id):
|
|
142
|
+
if forum.joined:
|
|
143
|
+
forum.joined = False
|
|
144
|
+
await forum.save()
|
|
138
145
|
await user_upsert(u, blocked)
|
|
139
146
|
|
|
140
147
|
|
|
141
|
-
@main.chat_member(ChatMemberUpdatedFilter(LEAVE_TRANSITION))
|
|
148
|
+
@main.chat_member(ChatMemberUpdatedFilter(LEAVE_TRANSITION)) # юзер покинул группу Ордеров
|
|
142
149
|
async def on_user_leave(member: ChatMemberUpdated):
|
|
143
150
|
logging.info({"user_leave": member.model_dump(exclude_none=True)})
|
|
144
|
-
forum
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
)
|
|
150
|
-
logging.error(resp)
|
|
151
|
-
else:
|
|
152
|
-
forum.joined = False
|
|
153
|
-
await forum.save()
|
|
154
|
-
resp = "Bye!"
|
|
151
|
+
if forum := await Forum[member.chat.id]:
|
|
152
|
+
if forum.joined:
|
|
153
|
+
forum.joined = False
|
|
154
|
+
await forum.save()
|
|
155
|
+
resp = "Bye!"
|
|
155
156
|
return await member.bot.send_message(member.new_chat_member.user.id, resp)
|
|
156
157
|
|
|
157
158
|
|
|
158
|
-
@main.
|
|
159
|
-
async def
|
|
160
|
-
logging.info({"join_request": req.model_dump(exclude_none=True)})
|
|
161
|
-
forum = await Forum[req.chat.id]
|
|
162
|
-
if forum.user_id != req.from_user.id:
|
|
163
|
-
resp = f"{req.chat.title} is chat for user#{forum.user_id}"
|
|
164
|
-
logging.error(resp)
|
|
165
|
-
forum.joined = not await req.decline()
|
|
166
|
-
else:
|
|
167
|
-
resp = "Your request approved"
|
|
168
|
-
forum.joined = await req.approve()
|
|
169
|
-
await forum.save()
|
|
170
|
-
return await req.bot.send_message(req.user_chat_id, resp)
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
@main.chat_member(ChatMemberUpdatedFilter(JOIN_TRANSITION))
|
|
174
|
-
async def on_user_join(member: ChatMemberUpdated):
|
|
159
|
+
@main.chat_member(ChatMemberUpdatedFilter(JOIN_TRANSITION)) # Юзер добавился в группу Ордеров
|
|
160
|
+
async def on_user_join(member: ChatMemberUpdated, app_url: str):
|
|
175
161
|
logging.info({"user_join": member.model_dump(exclude_none=True)})
|
|
176
|
-
forum
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
return
|
|
181
|
-
resp = f"{member.chat.title} is chat for user#{forum.user_id}"
|
|
182
|
-
logging.error(resp)
|
|
183
|
-
await member.bot.ban_chat_member(member.chat.id, member.new_chat_member.user.id)
|
|
162
|
+
if forum := await Forum.get_or_none(id=member.chat.id):
|
|
163
|
+
if not forum.joined:
|
|
164
|
+
forum.joined = True
|
|
165
|
+
await forum.save()
|
|
184
166
|
else:
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
resp = "Welcome to XyncNetwork"
|
|
189
|
-
rm = InlineKeyboardMarkup(
|
|
190
|
-
inline_keyboard=[[InlineKeyboardButton(text="Go!", web_app=WebAppInfo(url="https://test.xync.net/"))]]
|
|
191
|
-
)
|
|
167
|
+
return
|
|
168
|
+
resp = "Welcome to XyncNetwork"
|
|
169
|
+
rm = InlineKeyboardMarkup(inline_keyboard=[[InlineKeyboardButton(text="Go!", web_app=WebAppInfo(url=app_url))]])
|
|
192
170
|
return await member.bot.send_message(member.new_chat_member.user.id, resp, reply_markup=rm)
|
|
193
171
|
|
|
194
172
|
|
|
@@ -2,12 +2,12 @@ xync_bot/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
2
2
|
xync_bot/shared.py,sha256=MlKkTrsT29l7fF6-qAN9FO14cSuXuOuYxbNY5F4S2w4,137
|
|
3
3
|
xync_bot/types.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
4
|
xync_bot/handlers/__init__.py,sha256=0CwHTSgAWzKRZ7PtsaLGA8PtjWQtZqsEXKyncNbCKLA,374
|
|
5
|
-
xync_bot/handlers/main.py,sha256=
|
|
5
|
+
xync_bot/handlers/main.py,sha256=eIgorrJXzRJfsO7fx1XxVHFJDfMiJyWt7myS4qSqS8U,9521
|
|
6
6
|
xync_bot/handlers/order.py,sha256=ZKWDLyiWrXzcR-aHKLBTBCACwp-P0Vvnr22T-EuLHaM,274
|
|
7
7
|
xync_bot/handlers/photo.py,sha256=aq6ImIOoZQYTW-lEy26qjgj5TYAuk4bQjgiCv64mPJs,1203
|
|
8
8
|
xync_bot/handlers/vpn.py,sha256=qKK55UrjEZeDvu7ljWXNUFBFgXTPTIEaCT2OAmKWky4,2219
|
|
9
9
|
xync_bot/handlers/xicon.png,sha256=O57_kvzhVcCXSoGYZ61m0dW9pizY6gxR8Yj5aeCP0RQ,429283
|
|
10
|
-
xync_bot-0.3.
|
|
11
|
-
xync_bot-0.3.
|
|
12
|
-
xync_bot-0.3.
|
|
13
|
-
xync_bot-0.3.
|
|
10
|
+
xync_bot-0.3.5.dist-info/METADATA,sha256=Ixje9jeQi2Xf6sJXWbag5W2Tbz3TrsfLv5-2QIpaaEk,575
|
|
11
|
+
xync_bot-0.3.5.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
12
|
+
xync_bot-0.3.5.dist-info/top_level.txt,sha256=O2IjMc1ryAf0rwIXWohSNT5Kzcs9johgKRDz8lCC0rs,9
|
|
13
|
+
xync_bot-0.3.5.dist-info/RECORD,,
|
|
File without changes
|