Database changes, new translations #32
@ -18,6 +18,7 @@ class PyroClient(LibPyroClient):
|
||||
self.scheduler.add_job(
|
||||
remind, CronTrigger.from_crontab("* * * * *"), args=(self,)
|
||||
)
|
||||
self.contexts = []
|
||||
|
||||
async def start(self, **kwargs):
|
||||
await col_locations.create_index(
|
||||
|
@ -10,4 +10,9 @@ async def _owner_func(_, __: PyroClient, message: Message):
|
||||
return False if message.from_user is None else __.owner == message.from_user.id
|
||||
|
||||
|
||||
async def _context_func(_, __: PyroClient, message: Message):
|
||||
return message.from_user.id in __.contexts
|
||||
|
||||
|
||||
owner = filters.create(_owner_func)
|
||||
context = filters.create(_context_func)
|
||||
|
@ -22,7 +22,9 @@ async def search_name(app: PyroClient, message: Message) -> Union[Location, None
|
||||
)
|
||||
|
||||
while location is None:
|
||||
app.contexts.append(message.from_user.id)
|
||||
answer = await listen_message(app, message.chat.id, 300)
|
||||
app.contexts.remove(message.from_user.id)
|
||||
|
||||
if answer is None or answer.text == "/cancel":
|
||||
await message.reply_text(
|
||||
@ -72,7 +74,9 @@ async def search_name(app: PyroClient, message: Message) -> Union[Location, None
|
||||
)
|
||||
|
||||
while True:
|
||||
app.contexts.append(message.from_user.id)
|
||||
answer = await listen_message(app, message.chat.id, 300)
|
||||
app.contexts.remove(message.from_user.id)
|
||||
|
||||
if answer is None or answer.text == "/cancel":
|
||||
await message.reply_text(
|
||||
|
@ -43,7 +43,10 @@ async def search_nearby(app: PyroClient, message: Message) -> Union[Location, No
|
||||
)
|
||||
|
||||
while True:
|
||||
app.contexts.append(message.from_user.id)
|
||||
answer = await listen_message(app, message.chat.id, 300)
|
||||
app.contexts.remove(message.from_user.id)
|
||||
|
||||
location: Union[Location, None] = None
|
||||
|
||||
if answer is None or answer.text == "/cancel":
|
||||
|
@ -8,12 +8,13 @@ from pyrogram.types import Message, ReplyKeyboardRemove
|
||||
from ujson import dumps
|
||||
|
||||
from classes.pyroclient import PyroClient
|
||||
from modules import custom_filters
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@PyroClient.on_message(
|
||||
~filters.scheduled & filters.private & filters.command(["checkout"], prefixes=["/"]) # type: ignore
|
||||
~filters.scheduled & filters.private & filters.command(["checkout"], prefixes=["/"]) & ~custom_filters.context # type: ignore
|
||||
)
|
||||
async def command_checkout(app: PyroClient, message: Message):
|
||||
user = await app.find_user(message.from_user)
|
||||
@ -42,7 +43,9 @@ async def command_checkout(app: PyroClient, message: Message):
|
||||
)
|
||||
|
||||
while True:
|
||||
app.contexts.append(message.from_user.id)
|
||||
answer_delete = await listen_message(app, message.chat.id, 300)
|
||||
app.contexts.remove(message.from_user.id)
|
||||
|
||||
if answer_delete is None or answer_delete.text == "/cancel":
|
||||
await message.reply_text(
|
||||
@ -84,7 +87,9 @@ async def command_checkout(app: PyroClient, message: Message):
|
||||
)
|
||||
|
||||
while True:
|
||||
app.contexts.append(message.from_user.id)
|
||||
answer_confirm = await listen_message(app, message.chat.id, 300)
|
||||
app.contexts.remove(message.from_user.id)
|
||||
|
||||
if answer_confirm is None or answer_confirm.text == "/cancel":
|
||||
await message.reply_text(
|
||||
|
@ -2,10 +2,11 @@ from pyrogram import filters
|
||||
from pyrogram.types import Message
|
||||
|
||||
from classes.pyroclient import PyroClient
|
||||
from modules import custom_filters
|
||||
|
||||
|
||||
@PyroClient.on_message(
|
||||
~filters.scheduled & filters.private & filters.command(["help"], prefixes=["/"]) # type: ignore
|
||||
~filters.scheduled & filters.private & filters.command(["help"], prefixes=["/"]) & ~custom_filters.context # type: ignore
|
||||
)
|
||||
async def command_help(app: PyroClient, message: Message):
|
||||
user = await app.find_user(message.from_user)
|
||||
|
@ -12,18 +12,22 @@ from modules.database import col_entries
|
||||
|
||||
|
||||
@PyroClient.on_message(
|
||||
~filters.scheduled & filters.private & custom_filters.owner & filters.command(["import"], prefixes=["/"]) # type: ignore
|
||||
~filters.scheduled & filters.private & custom_filters.owner & filters.command(["import"], prefixes=["/"]) & ~custom_filters.context # type: ignore
|
||||
)
|
||||
async def command_import(app: PyroClient, message: Message):
|
||||
user = await app.find_user(message.from_user)
|
||||
|
||||
await message.reply_text(
|
||||
app._("import", "messages", locale=user.locale),
|
||||
reply_markup=ForceReply(placeholder=""),
|
||||
reply_markup=ForceReply(
|
||||
placeholder=app._("import", "force_replies", locale=user.locale)
|
||||
),
|
||||
)
|
||||
|
||||
while True:
|
||||
app.contexts.append(message.from_user.id)
|
||||
answer = await listen_message(app, message.chat.id, 300)
|
||||
app.contexts.remove(message.from_user.id)
|
||||
|
||||
if answer is None or answer.text == "/cancel":
|
||||
await message.reply_text(
|
||||
|
@ -2,10 +2,11 @@ from pyrogram import filters
|
||||
from pyrogram.types import Message
|
||||
|
||||
from classes.pyroclient import PyroClient
|
||||
from modules import custom_filters
|
||||
|
||||
|
||||
@PyroClient.on_message(
|
||||
~filters.scheduled & filters.private & filters.command(["remove_commands"], prefixes=["/"]) # type: ignore
|
||||
~filters.scheduled & filters.private & filters.command(["remove_commands"], prefixes=["/"]) & ~custom_filters.context # type: ignore
|
||||
)
|
||||
async def command_remove_commands(app: PyroClient, message: Message):
|
||||
user = await app.find_user(message.from_user)
|
||||
|
@ -6,12 +6,13 @@ from pyrogram import filters
|
||||
from pyrogram.types import ForceReply, Message, ReplyKeyboardRemove
|
||||
|
||||
from classes.pyroclient import PyroClient
|
||||
from modules import custom_filters
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@PyroClient.on_message(
|
||||
~filters.scheduled & filters.private & filters.command(["set_offset"], prefixes=["/"]) # type: ignore
|
||||
~filters.scheduled & filters.private & filters.command(["set_offset"], prefixes=["/"]) & ~custom_filters.context # type: ignore
|
||||
)
|
||||
async def command_set_offset(app: PyroClient, message: Message):
|
||||
user = await app.find_user(message.from_user)
|
||||
@ -24,7 +25,9 @@ async def command_set_offset(app: PyroClient, message: Message):
|
||||
)
|
||||
|
||||
while True:
|
||||
app.contexts.append(message.from_user.id)
|
||||
answer = await listen_message(app, message.chat.id, 300)
|
||||
app.contexts.remove(message.from_user.id)
|
||||
|
||||
if answer is None or answer.text == "/cancel":
|
||||
await message.reply_text(
|
||||
|
@ -6,12 +6,13 @@ from pyrogram import filters
|
||||
from pyrogram.types import ForceReply, Message, ReplyKeyboardRemove
|
||||
|
||||
from classes.pyroclient import PyroClient
|
||||
from modules import custom_filters
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@PyroClient.on_message(
|
||||
~filters.scheduled & filters.private & filters.command(["set_time"], prefixes=["/"]) # type: ignore
|
||||
~filters.scheduled & filters.private & filters.command(["set_time"], prefixes=["/"]) & ~custom_filters.context # type: ignore
|
||||
)
|
||||
async def command_set_time(app: PyroClient, message: Message):
|
||||
user = await app.find_user(message.from_user)
|
||||
@ -24,7 +25,9 @@ async def command_set_time(app: PyroClient, message: Message):
|
||||
)
|
||||
|
||||
while True:
|
||||
app.contexts.append(message.from_user.id)
|
||||
answer = await listen_message(app, message.chat.id, 300)
|
||||
app.contexts.remove(message.from_user.id)
|
||||
|
||||
if answer is None or answer.text == "/cancel":
|
||||
await message.reply_text(
|
||||
|
@ -8,6 +8,7 @@ from pyrogram import filters
|
||||
from pyrogram.types import Message, ReplyKeyboardRemove
|
||||
|
||||
from classes.pyroclient import PyroClient
|
||||
from modules import custom_filters
|
||||
from modules.search_name import search_name
|
||||
from modules.search_nearby import search_nearby
|
||||
|
||||
@ -15,7 +16,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@PyroClient.on_message(
|
||||
~filters.scheduled & filters.private & filters.command(["setup"] + i18n.sync.in_all_locales("start_configure", "buttons"), prefixes=["/", ""]) # type: ignore
|
||||
~filters.scheduled & filters.private & filters.command(["setup"] + i18n.sync.in_all_locales("start_configure", "buttons"), prefixes=["/", ""]) & ~custom_filters.context # type: ignore
|
||||
)
|
||||
async def command_setup(app: PyroClient, message: Message):
|
||||
user = await app.find_user(message.from_user)
|
||||
@ -34,7 +35,9 @@ async def command_setup(app: PyroClient, message: Message):
|
||||
)
|
||||
|
||||
while True:
|
||||
app.contexts.append(message.from_user.id)
|
||||
answer_type = await listen_message(app, message.chat.id, 300)
|
||||
app.contexts.remove(message.from_user.id)
|
||||
|
||||
if answer_type is None or answer_type.text == "/cancel":
|
||||
await message.reply_text(
|
||||
|
@ -4,12 +4,14 @@ from pyrogram import filters
|
||||
from pyrogram.types import Message
|
||||
|
||||
from classes.pyroclient import PyroClient
|
||||
from modules import custom_filters
|
||||
|
||||
|
||||
@PyroClient.on_message(
|
||||
~filters.scheduled
|
||||
& filters.private
|
||||
& filters.command(["shutdown", "reboot", "restart"], prefixes=["/"]) # type: ignore
|
||||
& filters.command(["shutdown", "reboot", "restart"], prefixes=["/"])
|
||||
& ~custom_filters.context # type: ignore
|
||||
)
|
||||
async def command_shutdown(app: PyroClient, msg: Message):
|
||||
if msg.from_user.id == app.owner:
|
||||
|
@ -10,10 +10,11 @@ from pyrogram.types import (
|
||||
)
|
||||
|
||||
from classes.pyroclient import PyroClient
|
||||
from modules import custom_filters
|
||||
|
||||
|
||||
@PyroClient.on_message(
|
||||
~filters.scheduled & filters.private & filters.command(["start"], prefixes=["/"]) # type: ignore
|
||||
~filters.scheduled & filters.private & filters.command(["start"], prefixes=["/"]) & ~custom_filters.context # type: ignore
|
||||
)
|
||||
async def command_start(app: PyroClient, message: Message):
|
||||
user = await app.find_user(message.from_user)
|
||||
@ -52,7 +53,9 @@ async def command_start(app: PyroClient, message: Message):
|
||||
)
|
||||
|
||||
while True:
|
||||
app.contexts.append(message.from_user.id)
|
||||
answer = await listen_message(app, message.chat.id, 300)
|
||||
app.contexts.remove(message.from_user.id)
|
||||
|
||||
if answer is None or answer.text == "/cancel":
|
||||
await message.reply_text(
|
||||
|
@ -4,10 +4,11 @@ from pyrogram import filters
|
||||
from pyrogram.types import Message
|
||||
|
||||
from classes.pyroclient import PyroClient
|
||||
from modules import custom_filters
|
||||
|
||||
|
||||
@PyroClient.on_message(
|
||||
~filters.scheduled & filters.private & filters.command(["toggle"], prefixes=["/"]) # type: ignore
|
||||
~filters.scheduled & filters.private & filters.command(["toggle"], prefixes=["/"]) & ~custom_filters.context # type: ignore
|
||||
)
|
||||
async def command_toggle(app: PyroClient, message: Message):
|
||||
user = await app.find_user(message.from_user)
|
||||
|
@ -1,17 +1,17 @@
|
||||
from datetime import datetime, timedelta, timezone
|
||||
|
||||
from pymongo.errors import OperationFailure
|
||||
from pyrogram import filters
|
||||
from pyrogram.types import Message
|
||||
from pytz import timezone as pytz_timezone
|
||||
|
||||
from classes.garbage_entry import GarbageEntry
|
||||
from classes.pyroclient import PyroClient
|
||||
from modules import custom_filters
|
||||
from modules.database import col_entries
|
||||
|
||||
|
||||
@PyroClient.on_message(
|
||||
~filters.scheduled & filters.private & filters.command(["upcoming"], prefixes=["/"]) # type: ignore
|
||||
~filters.scheduled & filters.private & filters.command(["upcoming"], prefixes=["/"]) & ~custom_filters.context # type: ignore
|
||||
)
|
||||
async def command_upcoming(app: PyroClient, message: Message):
|
||||
user = await app.find_user(message.from_user)
|
||||
|
@ -6,10 +6,11 @@ from pyrogram.types import CallbackQuery, Message
|
||||
|
||||
from classes.callbacks import CallbackLanguage
|
||||
from classes.pyroclient import PyroClient
|
||||
from modules import custom_filters
|
||||
|
||||
|
||||
@PyroClient.on_message(
|
||||
~filters.scheduled & filters.private & filters.command(["language"], prefixes=["/"]) # type: ignore
|
||||
~filters.scheduled & filters.private & filters.command(["language"], prefixes=["/"]) & ~custom_filters.context # type: ignore
|
||||
)
|
||||
async def command_language(app: PyroClient, message: Message):
|
||||
user = await app.find_user(message.from_user)
|
||||
|
Reference in New Issue
Block a user