This commit is contained in:
dize_dev
2023-10-29 23:01:17 +06:00
commit f43aee3e57
15 changed files with 248 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml
+10
View File
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
+7
View File
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DiscordProjectSettings">
<option name="show" value="ASK" />
<option name="description" value="" />
</component>
</project>
+6
View File
@@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>
+4
View File
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (UserVKBot)" project-jdk-type="Python SDK" />
</project>
+8
View File
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/UserVKBot.iml" filepath="$PROJECT_DIR$/.idea/UserVKBot.iml" />
</modules>
</component>
</project>
+24
View File
@@ -0,0 +1,24 @@
from vkbottle.user import UserLabeler, Message, User
TOKEN = 'vk1.a.4nNdLuOJin9tn71J-cKGu6MKCR2rNHkdRPn4lbW28CS9aL0Q-rhG3ZQi6UQnV9ClpBrNp2obRUltWREoSuwz2Km7OXGlBaP3jt9KsEeut4N3OvHWoTUuqNEtiRrgz2koSrPXLEJZ8i974KD2CgXWqmX4IsSC3kCMDK_aS1xetU3S38-Z1JFyNZu5Tl8yUGopptCjEqA9jF8CjznWv1gC2A'
bl = UserLabeler()
user = User(token=TOKEN)
async def edit_message(
message: Message,
text: str = '',
**kwargs
) -> int:
kwargs.setdefault('message_id', message.id)
kwargs.setdefault('message', text)
kwargs.setdefault('peer_id', message.peer_id)
kwargs.setdefault('keep_forward_messages', True)
kwargs.setdefault('keep_snippets', True)
kwargs.setdefault('dont_parse_links', False)
return await user.api.messages.edit(
**kwargs
)
+23
View File
@@ -0,0 +1,23 @@
from vkbottle.dispatch.rules import ABCRule
from vkbottle.user import Message
import json
class Permission(ABCRule[Message]):
def __init__(self):
self.trusted_ids = self.load_trusted_ids()
def load_trusted_ids(self):
try:
with open("./user_ids.json", "r") as json_file:
data = json.load(json_file)
return data
except FileNotFoundError:
# Если файл не существует, вернуть пустой список
return []
async def check(self, event: Message) -> bool:
return event.from_id in self.trusted_ids
+15
View File
@@ -0,0 +1,15 @@
import sys
import asyncio
from config import user
from routes import labelers
from loguru import logger
logger.add(sys.stderr, format="{time} {level} {message}", filter="my_module", level="INFO")
for custom_labeler in labelers:
user.labeler.load(custom_labeler)
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.create_task(user.run_polling())
loop.run_forever()
+3
View File
@@ -0,0 +1,3 @@
from . import game_handler, deletedmsg, info_bot
labelers = [game_handler.bl, deletedmsg.bl, info_bot.bl]
+48
View File
@@ -0,0 +1,48 @@
import datetime
from custom_rules.permission import Permission
from vkbottle.user import Message
from config import bl, user
DD_SCRIPT = (
'var i = 0;var msg_ids = [];var count = %d;'
'var items = API.messages.getHistory({"peer_id":%d,"count":"200", "offset":"0"}).items;'
'while (count > 0 && i < items.length) {if (items[i].out == 1) {if (items[i].id == %d) {'
'if (items[i].reply_message) {msg_ids.push(items[i].id);msg_ids.push(items[i].reply_message.id);'
'count = 0;};if (items[i].fwd_messages) {msg_ids.push(items[i].id);var j = 0;while (j < '
'items[i].fwd_messages.length) {msg_ids.push(items[i].fwd_messages[j].id);j = j + 1;};count = 0;};};'
'msg_ids.push(items[i].id);count = count - 1;};if ((%d - items[i].date) > 86400) {count = 0;};i = i + 1;};'
'API.messages.delete({"message_ids": msg_ids});return count;'
)
prefix = "дд"
@bl.message(
Permission(),
text=[prefix + " <count:int>"],
)
async def dd_handler(message: Message, count: int = 2):
await user.api.execute(
DD_SCRIPT % (
count,
message.peer_id,
message.from_id,
int(datetime.datetime.now().timestamp())
)
)
@bl.message(
Permission(),
text=["все", "всё"],
)
async def dd_all_handler(message: Message):
count = 1000
await user.api.execute(
DD_SCRIPT % (
count,
message.peer_id,
message.from_id,
int(datetime.datetime.now().timestamp())
)
)
+85
View File
@@ -0,0 +1,85 @@
import asyncio
from vkbottle.user import Message
from config import bl, edit_message
from custom_rules.permission import Permission
@bl.message(Permission(), text="игра")
async def game(message: Message):
loader = (
'⬜⬜⬜⬜⬜⬜⬜⬜⬛⬛⬜⬜⬜⬜⬜⬜⬜',
"""
⬜⬜⬜⬜⬜⬜⬜⬜⬛⬛⬜⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬜⬜⬛✊✊⬛⬜⬜⬜⬜⬜⬜
""",
"""
⬜⬜⬜⬜⬜⬜⬜⬜⬛⬛⬜⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬜⬜⬜⬛⬛⬜⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬜⬜⬛✊✊⬛⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬜⬜⬛✊✊⬛⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬜⬜⬛✊✊⬛⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬜⬜⬛✊✊⬛⬜⬜⬜⬜⬜⬜
""",
"""
⬜⬜⬜⬜⬜⬜⬜⬜⬛⬛⬜⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬜⬜⬜⬛⬛⬜⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬜⬜⬛✊✊⬛⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬜⬜⬛✊✊⬛⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬜⬜⬛✊✊⬛⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬜⬜⬛✊✊⬛⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬜⬜⬛✊✊⬛⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬛⬛⬛✊✊⬛⬛⬛⬜⬜⬜⬜
⬜⬜⬜⬜⬛✊✊⬛✊✊⬛✊✊⬛⬛⬛⬜
⬜⬜⬜⬜⬛✊✊⬛✊✊⬛✊✊⬛✊✊⬛
⬜⬛⬜⬜⬛✊✊⬛✊✊⬛✊✊⬛✊✊⬛
""",
"""
⬜⬜⬜⬜⬜⬜⬜⬜⬛⬛⬜⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬜⬜⬜⬛⬛⬜⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬜⬜⬛✊✊⬛⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬜⬜⬛✊✊⬛⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬜⬜⬛✊✊⬛⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬜⬜⬛✊✊⬛⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬜⬜⬛✊✊⬛⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬛⬛⬛✊✊⬛⬛⬛⬜⬜⬜⬜
⬜⬜⬜⬜⬛✊✊⬛✊✊⬛✊✊⬛⬛⬛⬜
⬜⬜⬜⬜⬛✊✊⬛✊✊⬛✊✊⬛✊✊⬛
⬜⬛⬜⬜⬛✊✊⬛✊✊⬛✊✊⬛✊✊⬛
⬛✊⬛⬜⬛✊✊✊✊✊✊✊✊✊✊✊⬛
⬛✊✊⬛⬛✊✊✊✊✊✊✊✊✊✊✊⬛
⬜⬛✊✊✊✊✊✊✊✊✊✊✊✊✊✊⬛
⬜⬜⬛✊✊✊✊✊✊✊✊✊✊✊✊✊⬛
⬜⬜⬜⬛✊✊✊✊✊✊✊✊✊✊✊✊⬛
""",
"""
⬜⬜⬜⬜⬜⬜⬜⬜⬛⬛⬜⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬜⬜⬜⬛⬛⬜⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬜⬜⬛✊✊⬛⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬜⬜⬛✊✊⬛⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬜⬜⬛✊✊⬛⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬜⬜⬛✊✊⬛⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬜⬜⬛✊✊⬛⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬛⬛⬛✊✊⬛⬛⬛⬜⬜⬜⬜
⬜⬜⬜⬜⬛✊✊⬛✊✊⬛✊✊⬛⬛⬛⬜
⬜⬜⬜⬜⬛✊✊⬛✊✊⬛✊✊⬛✊✊⬛
⬜⬛⬜⬜⬛✊✊⬛✊✊⬛✊✊⬛✊✊⬛
⬛✊⬛⬜⬛✊✊✊✊✊✊✊✊✊✊✊⬛
⬛✊✊⬛⬛✊✊✊✊✊✊✊✊✊✊✊⬛
⬜⬛✊✊✊✊✊✊✊✊✊✊✊✊✊✊⬛
⬜⬜⬛✊✊✊✊✊✊✊✊✊✊✊✊✊⬛
⬜⬜⬜⬛✊✊✊✊✊✊✊✊✊✊✊✊⬛
⬜⬜⬜⬜⬛✊✊✊✊✊✊✊✊✊✊✊⬛
⬜⬜⬜⬜⬛✊✊✊✊✊✊✊✊✊✊✊⬛
⬜⬜⬜⬜⬜⬛✊✊✊✊✊✊✊✊✊⬛⬜
⬜⬜⬜⬜⬜⬜⬛⬛⬛⬛⬛⬛⬛⬛⬛⬜⬜
""",
)
for new_text in loader:
await edit_message(
message,
new_text
)
await asyncio.sleep(1)
+11
View File
@@ -0,0 +1,11 @@
from custom_rules.permission import Permission
from vkbottle.user import Message
from config import bl, edit_message
@bl.message(Permission(), text="хелло")
async def hello(message: Message):
await edit_message(
message,
"привет"
)
View File
+1
View File
@@ -0,0 +1 @@
[368658177, 304398797]