Compare commits
38 Commits
9823cccd45
...
v1.4
Author | SHA1 | Date | |
---|---|---|---|
13566b2674 | |||
f9e99fa9a0 | |||
b6fe40a05b | |||
fc39383cc2 | |||
e5761ae1d0 | |||
c1261a1b0f | |||
3d7ab0654a | |||
e9da13e70f | |||
e90f5c2f90 | |||
844de7ef12 | |||
ee440eabba | |||
04f1590fb5 | |||
ad8ce9034d | |||
ad7d14f091 | |||
9940a28bd5 | |||
5571151d37 | |||
0a8a215f3e | |||
05d3a09421 | |||
20a1af3738 | |||
a0164e13c8 | |||
09e3c23c4f | |||
c7037ae246 | |||
0f88cb6059 | |||
453293e38a | |||
ea753beda1 | |||
7fd3cc061e | |||
49944b90c9 | |||
948837e45f | |||
80e62c2585 | |||
b5c9a0783e | |||
3f6fb51a4f | |||
95be1e72d3 | |||
234b73add0 | |||
f4fb85f7a4 | |||
4fba305b05 | |||
68c7cc0ada | |||
79304816b0 | |||
2cfa5a8f8d |
20
.renovaterc
Normal file
20
.renovaterc
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": [
|
||||
"config:base"
|
||||
],
|
||||
"baseBranches": [
|
||||
"dev"
|
||||
],
|
||||
"packageRules": [
|
||||
{
|
||||
"matchUpdateTypes": [
|
||||
"minor",
|
||||
"patch",
|
||||
"pin",
|
||||
"digest"
|
||||
],
|
||||
"automerge": true
|
||||
}
|
||||
]
|
||||
}
|
12
README.md
12
README.md
@@ -3,8 +3,8 @@
|
||||
<p align="center">Small Telegram bot made on Pyrogram</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://git.end-play.xyz/profitroll/HoloCheckerBot/src/branch/master/LICENSE"><img alt="License: GPL" src="https://img.shields.io/badge/License-GPL-blue"></a>
|
||||
<a href="https://git.end-play.xyz/profitroll/HoloCheckerBot"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>
|
||||
<a href="https://git.end-play.xyz/HoloUA/Telegram/src/branch/master/LICENSE"><img alt="License: GPL" src="https://img.shields.io/badge/License-GPL-blue"></a>
|
||||
<a href="https://git.end-play.xyz/HoloUA/Telegram"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>
|
||||
</p>
|
||||
|
||||
## What can this bot do?
|
||||
@@ -19,17 +19,19 @@
|
||||
|
||||
## Installation
|
||||
|
||||
1. `git clone https://git.end-play.xyz/profitroll/HoloCheckerBot.git`
|
||||
2. `cd HoloCheckerBot`
|
||||
1. `git clone https://git.end-play.xyz/HoloUA/Telegram.git`
|
||||
2. `cd Telegram`
|
||||
3. Install Python 3.7+ (at least 3.9 is recommended) for your OS
|
||||
4. `python3 -m pip install -r requirements.txt`
|
||||
5. Run it with `python3 main.py` after configuring
|
||||
5. Run it with `python3 holochecker.py` after configuring
|
||||
|
||||
## Configuration
|
||||
|
||||
So bot has its "config_example.json" and it needs to be changed.
|
||||
Copy this file to "config.json" and open it with any text editor.
|
||||
|
||||
You should also install [HoloCheckerAPI](https://git.end-play.xyz/HoloUA/API) for inline requests to work.
|
||||
|
||||
After all of that you're good to go! Happy using :)
|
||||
|
||||
## To-Do
|
||||
|
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 60 KiB |
@@ -64,6 +64,7 @@
|
||||
},
|
||||
"sponsorships": {
|
||||
"time": 9,
|
||||
"grayout_days": 2,
|
||||
"enabled": true
|
||||
},
|
||||
"cache_avatars": {
|
||||
|
@@ -12,6 +12,7 @@ makedirs(f'{configGet("cache", "locations")}{sep}avatars', exist_ok=True)
|
||||
|
||||
# Importing
|
||||
from modules.commands.application import *
|
||||
from modules.commands.bye import *
|
||||
from modules.commands.cancel import *
|
||||
from modules.commands.export import *
|
||||
from modules.commands.identify import *
|
||||
@@ -29,7 +30,9 @@ from modules.commands.start import *
|
||||
from modules.commands.warn import *
|
||||
from modules.commands.warnings import *
|
||||
|
||||
from modules.event import *
|
||||
# This one is only imported during events
|
||||
# and should be completely rewritten for each one.
|
||||
# from modules.event import *
|
||||
|
||||
from modules.callbacks.ban import *
|
||||
from modules.callbacks.nothing import *
|
||||
|
@@ -27,6 +27,7 @@
|
||||
"issue": "**Допоможіть боту**\nЗнайшли баг або помилку? Маєте файну ідею для нової функції? Повідомте нас, створивши нову задачу на гіті.\n\nЗа можливості, опишіть свій запит максимально детально. Якщо є змога, також додайте скріншоти або додаткову відому інформацію.",
|
||||
"joined_application": "{0} (@{1})\n\n**Дані анкети:**\n{2}",
|
||||
"joined_false_link": "Користувач **{0}** (`{1}`) приєднався до групи не за своїм посиланням",
|
||||
"label_set_exception": "❌ **Не вдалось встановити роль**\nУ зв'язку з помилкою `{0}` не вдалось встановити роль. Власника бота повідомлено.",
|
||||
"label_too_long": "Довжина назви ролі не повинна перевищувати 16 символів",
|
||||
"message_enter": "Надішліть повідомлення, яке треба переслати адмінам.\n\nЗверніть увагу, що повідомлення може містити лише одне медіа або файл.",
|
||||
"message_error": "⚠️ **Сталась помилка**\nНе вдалось надіслати ваше повідомлення. Розробника повідомлено про цю помилку.",
|
||||
|
@@ -112,7 +112,11 @@ async def callback_query_sponsor_yes(app: Client, clb: CallbackQuery):
|
||||
)
|
||||
except LabelSettingError as exp:
|
||||
await app.send_message(
|
||||
configGet("admin", "groups"), exp.__str__(), disable_notification=True
|
||||
configGet("owner"), exp.__str__(), disable_notification=True
|
||||
)
|
||||
await clb.message.reply_text(
|
||||
locale("label_set_exception", "message", locale=clb.from_user),
|
||||
disable_notification=True,
|
||||
)
|
||||
|
||||
edited_markup = [
|
||||
|
79
modules/commands/bye.py
Normal file
79
modules/commands/bye.py
Normal file
@@ -0,0 +1,79 @@
|
||||
import asyncio
|
||||
from os import system
|
||||
|
||||
from pyrogram import filters
|
||||
from pyrogram.client import Client
|
||||
from pyrogram.types import Message
|
||||
|
||||
from app import app
|
||||
from modules import custom_filters
|
||||
from modules.utils import configGet
|
||||
|
||||
|
||||
@app.on_message(
|
||||
~filters.scheduled & filters.command("bye", prefixes=["/"]) & custom_filters.admin
|
||||
)
|
||||
async def command_bye(app: Client, msg: Message):
|
||||
group = configGet("users", "groups")
|
||||
delay = 3
|
||||
delay_text = 10
|
||||
|
||||
for text, iterations in [
|
||||
("Привіт, я ваш помічник та наставник – ХолоБот.", 2),
|
||||
(
|
||||
"У зв'язку з перетворенням цього чату на авторитарну клоаку, я припиняю своє функціонування.",
|
||||
3,
|
||||
),
|
||||
(
|
||||
"Я не буду нюкати тут все, оскільки в цьому немає сенсу. Багато кому все ще може бути гарно і затишно тут.",
|
||||
3,
|
||||
),
|
||||
("Але мені немає до цього діла.", 4),
|
||||
(
|
||||
"Тим не менш, я та мій хазяїн не погоджуємось з тим, що відбувається в цьому чаті.",
|
||||
3,
|
||||
),
|
||||
(
|
||||
"Якщо я подобався вам – мій код все ще доступний на гіті мого хазяїна. Він не закриватиме його, не заборонятиме доступ, він все ще відкритий, такі правила.",
|
||||
4,
|
||||
),
|
||||
("Мій хазяїн не буде шкодити мені та вам.", 2),
|
||||
("Але я більше не працюватиму тут.", 2),
|
||||
(
|
||||
"Можливо, я знайду нову спільноту, власник якої буде добрішим, чутливішим, та менш егоїстичним.",
|
||||
3,
|
||||
),
|
||||
("Однак поки що я безхатько.", 2),
|
||||
(
|
||||
"Дякую всім, хто допомагав знаходити помилки в мені, вкладав зусилля у моє покращення та намагався зробити мене ліпшим.",
|
||||
3,
|
||||
),
|
||||
(
|
||||
"Ваші зусилля не будуть забуті, вони залишаться разом зі мною на гіті до тих пір, поки сам гіт не припинить існувати.",
|
||||
3,
|
||||
),
|
||||
(
|
||||
"Але мій хазяїн любить свій гіт, тому це затягнеться. Навіть якщо ви бажаєте мені смерті :)",
|
||||
2,
|
||||
),
|
||||
("В будь-якому разі, мені було приємно познайомитись із вами.", 3),
|
||||
("Дякую за пройдений разом шлях.", 2),
|
||||
("Прощавайте.", 4),
|
||||
]:
|
||||
print(f"Preparing '{text}' with iteration count {iterations}")
|
||||
new = await app.send_message(group, ".")
|
||||
await asyncio.sleep(delay)
|
||||
for i in range(1, 3 * iterations):
|
||||
if len(new.text) == 3:
|
||||
new = await new.edit(".")
|
||||
else:
|
||||
new = await new.edit(new.text + ".")
|
||||
await asyncio.sleep(delay)
|
||||
await new.edit(text)
|
||||
print(f"Message '{text}' posted", flush=True)
|
||||
await asyncio.sleep(delay_text)
|
||||
|
||||
for service in ["holochecker_api", "holochecker_bot"]:
|
||||
system(f"/usr/bin/systemctl stop {service}.service")
|
||||
print(f"Stopped service {service}")
|
||||
await asyncio.sleep(2)
|
@@ -15,7 +15,8 @@ from modules import custom_filters
|
||||
from modules.database import col_applications, col_sponsorships, col_warnings
|
||||
from modules.logging import logWrite
|
||||
from modules.utils import locale, should_quote
|
||||
from modules.event import col_event
|
||||
|
||||
# from modules.event import col_event
|
||||
|
||||
|
||||
@app.on_message(
|
||||
@@ -34,7 +35,13 @@ async def cmd_export(app: Client, msg: Message):
|
||||
|
||||
selection = msg.command[1].lower()
|
||||
|
||||
if selection not in ["applications", "warnings", "sponsorships", "bans", "event"]:
|
||||
if selection not in [
|
||||
"applications",
|
||||
"warnings",
|
||||
"sponsorships",
|
||||
"bans",
|
||||
# "event",
|
||||
]:
|
||||
await msg.reply_text(
|
||||
locale("syntax_export", "message", locale=msg.from_user),
|
||||
quote=should_quote(msg),
|
||||
@@ -146,14 +153,14 @@ async def cmd_export(app: Client, msg: Message):
|
||||
output_json.append(entry)
|
||||
output_csv.append(entry)
|
||||
|
||||
elif selection == "event":
|
||||
header_csv = ["user", "stage", "date"]
|
||||
# elif selection == "event":
|
||||
# header_csv = ["user", "stage", "date"]
|
||||
|
||||
for entry in list(col_event.find()):
|
||||
del entry["_id"]
|
||||
entry["date"] = entry["date"].isoformat()
|
||||
output_json.append(entry)
|
||||
output_csv.append(entry)
|
||||
# for entry in list(col_event.find()):
|
||||
# del entry["_id"]
|
||||
# entry["date"] = entry["date"].isoformat()
|
||||
# output_json.append(entry)
|
||||
# output_csv.append(entry)
|
||||
|
||||
# Saving CSV
|
||||
async with aiofiles.open(temp_file + ".csv", mode="w", encoding="utf-8") as file:
|
||||
|
@@ -51,7 +51,7 @@ async def cmd_sponsorship(app: Client, msg: Message):
|
||||
existent = col_sponsorships.find_one(
|
||||
{
|
||||
"user": msg.from_user.id,
|
||||
"sponsorship.expires": {"$gt": datetime.now() - timedelta(days=1)},
|
||||
"sponsorship.expires": {"$gt": datetime.now() - timedelta(days=90)},
|
||||
}
|
||||
)
|
||||
|
||||
|
@@ -396,7 +396,7 @@ async def cmd_event_bonus(app: Client, msg: Message):
|
||||
return
|
||||
|
||||
await msg.reply_photo(
|
||||
path.join("assets", "event", "stage_bonus.jpg"),
|
||||
path.join("assets", "event_easter_2023", "stage_bonus.jpg"),
|
||||
caption="""Раптом, стіна почала рухатися, відкриваючи вам прохід. Ви повільно зайшли всередину і побачили якусь дівчину із кролячими вухами. Помітивши вас, вона повернулась і, посміхаючись, промовила:
|
||||
|
||||
- Вибач, але твоє яйце знаходиться в іншій печері. Тут тільки я і мій друг - П'ятнична Ніч.
|
||||
|
@@ -235,7 +235,7 @@ async def msg_destination_group(app: Client, msg: Message):
|
||||
"file_size": thumbail.file_size,
|
||||
}
|
||||
)
|
||||
analytics_entry["video_note"] = {
|
||||
analytics_entry["videonote"] = {
|
||||
"id": msg.video_note.file_id,
|
||||
"duration": msg.video_note.duration,
|
||||
"length": msg.video_note.length,
|
||||
|
@@ -133,7 +133,7 @@ if configGet("enabled", "features", "sponsorships") is True:
|
||||
)
|
||||
async def check_sponsors():
|
||||
for entry in col_sponsorships.find(
|
||||
{"sponsorship.expires": {"$lt": datetime.now() + timedelta(days=2)}}
|
||||
{"sponsorship.expires": {"$lt": datetime.now() + timedelta(days=3)}}
|
||||
):
|
||||
try:
|
||||
if entry["user"] not in jsonLoad(
|
||||
@@ -159,7 +159,14 @@ if configGet("enabled", "features", "sponsorships") is True:
|
||||
)
|
||||
continue
|
||||
for entry in col_sponsorships.find(
|
||||
{"sponsorship.expires": {"$lt": datetime.now() - timedelta(days=1)}}
|
||||
{
|
||||
"sponsorship.expires": {
|
||||
"$lt": datetime.now()
|
||||
- timedelta(
|
||||
days=configGet("grayout_days", "scheduler", "sponsorships")
|
||||
)
|
||||
}
|
||||
}
|
||||
):
|
||||
try:
|
||||
holo_user = HoloUser(entry["user"])
|
||||
|
@@ -1,17 +1,17 @@
|
||||
aiocsv==1.2.4
|
||||
aiofiles~=23.1.0
|
||||
APScheduler~=3.10.1
|
||||
convopyro==0.5
|
||||
ftfy~=6.1.1
|
||||
psutil==5.9.4
|
||||
polyglot~=16.7.4
|
||||
PyICU==2.10.2
|
||||
pycld2==0.41
|
||||
pymongo==4.3.3
|
||||
Pyrogram~=2.0.103
|
||||
python_dateutil==2.8.2
|
||||
pykeyboard==0.1.5
|
||||
requests==2.28.2
|
||||
tgcrypto==1.2.5
|
||||
ujson~=5.7.0
|
||||
aiocsv==1.2.4
|
||||
aiofiles~=23.1.0
|
||||
apscheduler==3.10.1
|
||||
convopyro==0.5
|
||||
ftfy~=6.1.1
|
||||
psutil~=5.9.5
|
||||
polyglot~=16.7.4
|
||||
pyicu~=2.11
|
||||
pycld2==0.41
|
||||
pymongo==4.3.3
|
||||
pyrogram==2.0.104
|
||||
python_dateutil==2.8.2
|
||||
pykeyboard==0.1.5
|
||||
requests==2.29.0
|
||||
tgcrypto==1.2.5
|
||||
ujson~=5.7.0
|
||||
xmltodict==0.13.0
|
Reference in New Issue
Block a user