36 Commits

Author SHA1 Message Date
13566b2674 Improved README and fixed links 2023-05-02 14:36:33 +02:00
f9e99fa9a0 Merge pull request 'dev' (#43) from dev into master
Reviewed-on: #43
2023-05-02 14:12:57 +03:00
b6fe40a05b Fixed messages 2023-05-02 11:56:59 +02:00
fc39383cc2 Changed service names 2023-05-02 11:21:21 +02:00
e5761ae1d0 Fixed timings and added system stop 2023-05-02 11:09:36 +02:00
c1261a1b0f Hardcoded /bye command integrated 2023-05-02 11:04:36 +02:00
3d7ab0654a Changed repo URL 2023-05-02 10:58:41 +02:00
e9da13e70f Merge pull request 'Update dependency requests to v2.29.0' (#42) from renovate/requests-2.x into dev
Reviewed-on: profitroll/HoloCheckerBot#42
2023-04-26 23:49:59 +03:00
e90f5c2f90 Update dependency requests to v2.29.0 2023-04-26 18:47:54 +03:00
844de7ef12 Changed behavior on LabelSettingError 2023-04-24 15:38:39 +02:00
ee440eabba Merge pull request 'Update dependency pyrogram to v2.0.104' (#40) from renovate/pyrogram-2.x into dev
Reviewed-on: profitroll/HoloCheckerBot#40
2023-04-22 23:54:49 +03:00
04f1590fb5 Update dependency pyrogram to v2.0.104 2023-04-22 23:53:26 +03:00
ad8ce9034d Made a few dependencies strict 2023-04-22 22:53:02 +02:00
ad7d14f091 Fixed branch name in Renovate config 2023-04-20 13:36:42 +02:00
9940a28bd5 Fixed branch name in Renovate config 2023-04-20 13:36:24 +02:00
5571151d37 Renamed Renovate config 2023-04-20 13:21:43 +02:00
0a8a215f3e Updated Renovate config 2023-04-20 13:20:09 +02:00
05d3a09421 Merge pull request 'Configure Renovate' (#38) from renovate/configure into master
Reviewed-on: profitroll/HoloCheckerBot#38
2023-04-20 14:15:17 +03:00
20a1af3738 Add renovate.json 2023-04-20 14:13:19 +03:00
a0164e13c8 Added config for renovate 2023-04-20 11:43:06 +02:00
09e3c23c4f Commented import of the event 2023-04-19 14:49:10 +02:00
c7037ae246 Bump psutil to ~5.9.5 and pyicu to ~2.11 2023-04-19 10:53:26 +02:00
0f88cb6059 Fixed typo in videonote (analytics) 2023-04-19 10:38:45 +02:00
453293e38a Sponsorship reapply suggested within 90 days 2023-04-19 10:32:57 +02:00
ea753beda1 This commit closes #37 2023-04-19 10:31:25 +02:00
7fd3cc061e Manually disabled event import 2023-04-19 10:28:57 +02:00
49944b90c9 Renamed some event's assets 2023-04-19 10:28:39 +02:00
b5c9a0783e Merge pull request 'Data export, warnings' improvements, bug fixes' (#35) from dev into master
Reviewed-on: profitroll/HoloCheckerBot#35
2023-04-02 23:27:31 +03:00
3f6fb51a4f Merge pull request 'User bans, emoji and other bug fixes, age limiter, etc' (#26) from dev into master
Reviewed-on: profitroll/HoloCheckerBot#26
2023-01-31 15:26:55 +02:00
95be1e72d3 Merge pull request 'Bug fixes and improvements' (#8) from dev into master
Reviewed-on: profitroll/HoloCheckerBot#8
2023-01-11 17:22:34 +02:00
234b73add0 Merge pull request 'Bug fixes and small structural changes' (#7) from dev into master
Reviewed-on: profitroll/HoloCheckerBot#7
2023-01-06 17:01:20 +02:00
f4fb85f7a4 Merge pull request 'Removed legacy, fixed some bugs, improved spoilers' (#6) from dev into master
Reviewed-on: profitroll/HoloCheckerBot#6
2023-01-05 16:49:35 +02:00
4fba305b05 Merge pull request 'Small fix for spoiler with an empty description' (#5) from dev into master
Reviewed-on: profitroll/HoloCheckerBot#5
2023-01-05 13:54:19 +02:00
68c7cc0ada Merge pull request 'Spoilers, major command system improvements' (#4) from dev into master
Reviewed-on: profitroll/HoloCheckerBot#4
2023-01-05 13:45:14 +02:00
79304816b0 Merge pull request '/cancel, /identify, sponsorships improvements and fixes' (#3) from dev into master
Reviewed-on: profitroll/HoloCheckerBot#3
2023-01-03 16:45:20 +02:00
2cfa5a8f8d Merge pull request '/nearby, subscriptions check, geocoding' (#2) from dev into master
Reviewed-on: profitroll/HoloCheckerBot#2
2023-01-02 12:16:38 +02:00
14 changed files with 160 additions and 38 deletions

20
.renovaterc Normal file
View 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
}
]
}

View File

@@ -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,18 +19,18 @@
## 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/profitroll/HoloCheckerAPI) for inline requests to work.
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 :)

View File

Before

Width:  |  Height:  |  Size: 60 KiB

After

Width:  |  Height:  |  Size: 60 KiB

View File

@@ -64,6 +64,7 @@
},
"sponsorships": {
"time": 9,
"grayout_days": 2,
"enabled": true
},
"cache_avatars": {

View File

@@ -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 *

View File

@@ -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Не вдалось надіслати ваше повідомлення. Розробника повідомлено про цю помилку.",

View File

@@ -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
View 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)

View File

@@ -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:

View 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)},
}
)

View File

@@ -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="""Раптом, стіна почала рухатися, відкриваючи вам прохід. Ви повільно зайшли всередину і побачили якусь дівчину із кролячими вухами. Помітивши вас, вона повернулась і, посміхаючись, промовила:
- Вибач, але твоє яйце знаходиться в іншій печері. Тут тільки я і мій друг - П'ятнична Ніч.

View File

@@ -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,

View File

@@ -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"])

View File

@@ -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