/nearby, subscriptions check, geocoding #2
@ -1,5 +1,5 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from app import app, isAnAdmin
|
from app import app
|
||||||
from pyrogram import filters
|
from pyrogram import filters
|
||||||
from pyrogram.enums.parse_mode import ParseMode
|
from pyrogram.enums.parse_mode import ParseMode
|
||||||
from pyrogram.types import Message
|
from pyrogram.types import Message
|
||||||
@ -9,13 +9,12 @@ from classes.holo_user import HoloUser, UserNotFoundError
|
|||||||
from modules.utils import logWrite, locale, should_quote
|
from modules.utils import logWrite, locale, should_quote
|
||||||
from dateutil.relativedelta import relativedelta
|
from dateutil.relativedelta import relativedelta
|
||||||
from modules.database import col_applications
|
from modules.database import col_applications
|
||||||
|
from modules import custom_filters
|
||||||
|
|
||||||
# Applications command =========================================================================================================
|
# Applications command =========================================================================================================
|
||||||
@app.on_message(~ filters.scheduled & filters.command(["application"], prefixes=["/"]))
|
@app.on_message(~ filters.scheduled & custom_filters.admin & filters.command(["application"], prefixes=["/"]))
|
||||||
async def cmd_application(app: Client, msg: Message):
|
async def cmd_application(app: Client, msg: Message):
|
||||||
|
|
||||||
if await isAnAdmin(msg.from_user.id) is True:
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
from os import sep, makedirs, remove
|
from os import sep, makedirs, remove
|
||||||
from uuid import uuid1
|
from uuid import uuid1
|
||||||
from app import app, isAnAdmin
|
from app import app
|
||||||
from pyrogram import filters
|
from pyrogram import filters
|
||||||
from pyrogram.types import Message
|
from pyrogram.types import Message
|
||||||
from pyrogram.client import Client
|
from pyrogram.client import Client
|
||||||
@ -8,12 +8,12 @@ from pyrogram.enums.chat_action import ChatAction
|
|||||||
from modules.logging import logWrite
|
from modules.logging import logWrite
|
||||||
from modules.utils import should_quote, jsonSave
|
from modules.utils import should_quote, jsonSave
|
||||||
from modules.database import col_applications
|
from modules.database import col_applications
|
||||||
|
from modules import custom_filters
|
||||||
|
|
||||||
# Applications command =========================================================================================================
|
# Applications command =========================================================================================================
|
||||||
@app.on_message(~ filters.scheduled & filters.command(["applications"], prefixes=["/"]))
|
@app.on_message(~ filters.scheduled & custom_filters.admin & filters.command(["applications"], prefixes=["/"]))
|
||||||
async def cmd_applications(app: Client, msg: Message):
|
async def cmd_applications(app: Client, msg: Message):
|
||||||
|
|
||||||
if await isAnAdmin(msg.from_user.id) is True:
|
|
||||||
logWrite(f"Admin {msg.from_user.id} requested export of a database")
|
logWrite(f"Admin {msg.from_user.id} requested export of a database")
|
||||||
await app.send_chat_action(msg.chat.id, ChatAction.UPLOAD_DOCUMENT)
|
await app.send_chat_action(msg.chat.id, ChatAction.UPLOAD_DOCUMENT)
|
||||||
filename = uuid1()
|
filename = uuid1()
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
from app import app, isAnAdmin
|
from app import app
|
||||||
from pyrogram import filters
|
from pyrogram import filters
|
||||||
from pyrogram.types import Message
|
from pyrogram.types import Message
|
||||||
from pyrogram.client import Client
|
from pyrogram.client import Client
|
||||||
from modules.utils import locale, should_quote, find_user
|
from modules.utils import locale, should_quote, find_user
|
||||||
from classes.holo_user import HoloUser, LabelTooLongError
|
from classes.holo_user import HoloUser, LabelTooLongError
|
||||||
|
from modules import custom_filters
|
||||||
|
|
||||||
@app.on_message(~ filters.scheduled & filters.private & filters.command(["label"], prefixes=["/"]))
|
@app.on_message(~ filters.scheduled & custom_filters.admin & filters.private & filters.command(["label"], prefixes=["/"]))
|
||||||
async def cmd_label(app: Client, msg: Message):
|
async def cmd_label(app: Client, msg: Message):
|
||||||
|
|
||||||
if await isAnAdmin(msg.from_user.id) is True:
|
|
||||||
|
|
||||||
if len(msg.command) < 3:
|
if len(msg.command) < 3:
|
||||||
await msg.reply_text("Invalid syntax:\n`/label USER LABEL`")
|
await msg.reply_text("Invalid syntax:\n`/label USER LABEL`")
|
||||||
return
|
return
|
||||||
|
@ -1,16 +1,15 @@
|
|||||||
from app import app, isAnAdmin
|
from app import app
|
||||||
from pyrogram import filters
|
from pyrogram import filters
|
||||||
from pyrogram.types import Message
|
from pyrogram.types import Message
|
||||||
from pyrogram.client import Client
|
from pyrogram.client import Client
|
||||||
from classes.holo_user import HoloUser
|
from classes.holo_user import HoloUser
|
||||||
from modules.utils import logWrite, locale, should_quote
|
from modules.utils import logWrite, locale, should_quote
|
||||||
|
from modules import custom_filters
|
||||||
|
|
||||||
# Message command ==============================================================================================================
|
# Message command ==============================================================================================================
|
||||||
@app.on_message(~ filters.scheduled & filters.command(["message"], prefixes=["/"]))
|
@app.on_message(~ filters.scheduled & custom_filters.admin & filters.command(["message"], prefixes=["/"]))
|
||||||
async def cmd_message(app: Client, msg: Message):
|
async def cmd_message(app: Client, msg: Message):
|
||||||
|
|
||||||
if await isAnAdmin(msg.from_user.id) is True:
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from app import app, isAnAdmin
|
from app import app
|
||||||
from os import getpid
|
from os import getpid
|
||||||
from sys import exit
|
from sys import exit
|
||||||
from pyrogram import filters
|
from pyrogram import filters
|
||||||
@ -6,14 +6,14 @@ from pyrogram.types import Message
|
|||||||
from pyrogram.client import Client
|
from pyrogram.client import Client
|
||||||
from modules.utils import locale, logWrite, should_quote
|
from modules.utils import locale, logWrite, should_quote
|
||||||
from modules.scheduled import scheduler
|
from modules.scheduled import scheduler
|
||||||
|
from modules import custom_filters
|
||||||
|
|
||||||
pid = getpid()
|
pid = getpid()
|
||||||
|
|
||||||
# Shutdown command =============================================================================================================
|
# Shutdown command =============================================================================================================
|
||||||
@app.on_message(~ filters.scheduled & filters.private & filters.command(["kill", "die", "reboot"], prefixes=["/"]))
|
@app.on_message(~ filters.scheduled & custom_filters.admin & filters.private & filters.command(["kill", "die", "reboot"], prefixes=["/"]))
|
||||||
async def cmd_kill(app: Client, msg: Message):
|
async def cmd_kill(app: Client, msg: Message):
|
||||||
|
|
||||||
if await isAnAdmin(msg.from_user.id) is True:
|
|
||||||
logWrite(f"Shutting down bot with pid {pid}")
|
logWrite(f"Shutting down bot with pid {pid}")
|
||||||
await msg.reply_text(locale("shutdown", "message", locale=msg.from_user).format(pid), quote=should_quote(msg))
|
await msg.reply_text(locale("shutdown", "message", locale=msg.from_user).format(pid), quote=should_quote(msg))
|
||||||
scheduler.shutdown()
|
scheduler.shutdown()
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
from app import app, isAnAdmin
|
from app import app
|
||||||
from pyrogram import filters
|
from pyrogram import filters
|
||||||
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, Message
|
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, Message
|
||||||
from pyrogram.client import Client
|
from pyrogram.client import Client
|
||||||
from classes.holo_user import HoloUser
|
from classes.holo_user import HoloUser
|
||||||
|
from modules import custom_filters
|
||||||
from modules.utils import locale, should_quote
|
from modules.utils import locale, should_quote
|
||||||
from modules.database import col_applications
|
from modules.database import col_applications
|
||||||
|
|
||||||
# Sponsorship command ==========================================================================================================
|
# Sponsorship command ==========================================================================================================
|
||||||
@app.on_message(~ filters.scheduled & filters.command(["sponsorship"], prefixes=["/"]))
|
@app.on_message(~ filters.scheduled & (custom_filters.allowed | custom_filters.admin) & filters.command(["sponsorship"], prefixes=["/"]))
|
||||||
async def cmd_sponsorship(app: Client, msg: Message):
|
async def cmd_sponsorship(app: Client, msg: Message):
|
||||||
if (await isAnAdmin(msg) is True) or (col_applications.find_one({"user": msg.from_user.id}) is not None):
|
|
||||||
if HoloUser(msg.from_user).application_state()[0] == "fill":
|
if HoloUser(msg.from_user).application_state()[0] == "fill":
|
||||||
await msg.reply_text(locale("finish_application", "message"), quote=should_quote(msg))
|
await msg.reply_text(locale("finish_application", "message"), quote=should_quote(msg))
|
||||||
return
|
return
|
||||||
await msg.reply_text(locale("sponsorship_apply", "message"), reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(text=str(locale("sponsor_apply", "button")), callback_data=f"sponsor_apply_{msg.from_user.id}")]]), quote=should_quote(msg))
|
await msg.reply_text(locale("sponsorship_apply", "message"), reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(text=str(locale("sponsor_apply", "button")), callback_data=f"sponsor_apply_{msg.from_user.id}")]]), quote=should_quote(msg))
|
||||||
else:
|
# else:
|
||||||
await msg.reply_text(locale("sponsorship_application_empty", "message"))
|
# await msg.reply_text(locale("sponsorship_application_empty", "message"))
|
||||||
# ==============================================================================================================================
|
# ==============================================================================================================================
|
@ -1,18 +1,18 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from app import app, isAnAdmin
|
from app import app
|
||||||
from pyrogram import filters
|
from pyrogram import filters
|
||||||
from pyrogram.types import Message
|
from pyrogram.types import Message
|
||||||
from pyrogram.client import Client
|
from pyrogram.client import Client
|
||||||
from modules.utils import configGet, locale
|
from modules.utils import configGet, locale
|
||||||
from modules.database import col_warnings
|
from modules.database import col_warnings
|
||||||
|
from modules import custom_filters
|
||||||
|
|
||||||
# Warn command =================================================================================================================
|
# Warn command =================================================================================================================
|
||||||
@app.on_message(~ filters.scheduled & filters.command(["warn"], prefixes=["/"]))
|
@app.on_message(~ filters.scheduled & custom_filters.admin & filters.command(["warn"], prefixes=["/"]))
|
||||||
async def cmd_warn(app: Client, msg: Message):
|
async def cmd_warn(app: Client, msg: Message):
|
||||||
|
|
||||||
if msg.chat.id == configGet("destination_group"):
|
if msg.chat.id == configGet("destination_group"):
|
||||||
if msg.reply_to_message_id != None:
|
if msg.reply_to_message_id != None:
|
||||||
if await isAnAdmin(msg.from_user.id) is True:
|
|
||||||
message = " ".join(msg.command[1:]) if len(msg.command) > 1 else ""
|
message = " ".join(msg.command[1:]) if len(msg.command) > 1 else ""
|
||||||
col_warnings.insert_one({"user": msg.reply_to_message.from_user.id, "admin": msg.from_user.id, "date": datetime.now(), "reason": message})
|
col_warnings.insert_one({"user": msg.reply_to_message.from_user.id, "admin": msg.from_user.id, "date": datetime.now(), "reason": message})
|
||||||
if message == "":
|
if message == "":
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
from app import app, isAnAdmin
|
from app import app
|
||||||
from pyrogram import filters
|
from pyrogram import filters
|
||||||
from pyrogram.types import Message
|
from pyrogram.types import Message
|
||||||
from pyrogram.client import Client
|
from pyrogram.client import Client
|
||||||
from pyrogram.enums.chat_members_filter import ChatMembersFilter
|
from pyrogram.enums.chat_members_filter import ChatMembersFilter
|
||||||
from modules.utils import configGet, locale, should_quote
|
from modules.utils import configGet, locale, should_quote
|
||||||
from modules.database import col_users, col_warnings
|
from modules.database import col_users, col_warnings
|
||||||
|
from modules import custom_filters
|
||||||
|
|
||||||
# Warnings command =============================================================================================================
|
# Warnings command =============================================================================================================
|
||||||
@app.on_message(~ filters.scheduled & filters.command(["warnings"], prefixes=["/"]))
|
@app.on_message(~ filters.scheduled & custom_filters.admin & filters.command(["warnings"], prefixes=["/"]))
|
||||||
async def cmd_warnings(app: Client, msg: Message):
|
async def cmd_warnings(app: Client, msg: Message):
|
||||||
|
|
||||||
if await isAnAdmin(msg.from_user.id) is True:
|
|
||||||
|
|
||||||
if len(msg.command) <= 1:
|
if len(msg.command) <= 1:
|
||||||
await msg.reply_text(locale("syntax_warnings", "message", locale=msg.from_user), quote=should_quote(msg))
|
await msg.reply_text(locale("syntax_warnings", "message", locale=msg.from_user), quote=should_quote(msg))
|
||||||
return
|
return
|
||||||
|
12
modules/custom_filters.py
Normal file
12
modules/custom_filters.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
from app import isAnAdmin
|
||||||
|
from modules.database import col_applications
|
||||||
|
from pyrogram import filters
|
||||||
|
|
||||||
|
async def admin_func(_, __, msg):
|
||||||
|
return await isAnAdmin(msg)
|
||||||
|
|
||||||
|
async def allowed_func(_, __, msg):
|
||||||
|
return True if (col_applications.find_one({"user": msg.from_user.id}) is not None) else False
|
||||||
|
|
||||||
|
admin = filters.create(admin_func)
|
||||||
|
allowed = filters.create(allowed_func)
|
@ -1,21 +1,20 @@
|
|||||||
from dateutil.relativedelta import relativedelta
|
from dateutil.relativedelta import relativedelta
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from app import app, isAnAdmin
|
from app import app
|
||||||
from pyrogram import filters
|
from pyrogram import filters
|
||||||
from pyrogram.types import Message
|
from pyrogram.types import Message
|
||||||
from pyrogram.client import Client
|
from pyrogram.client import Client
|
||||||
from modules.utils import locale, logWrite
|
from modules.utils import locale, logWrite
|
||||||
from modules.database import col_applications
|
from modules.database import col_applications
|
||||||
from classes.holo_user import HoloUser
|
from classes.holo_user import HoloUser
|
||||||
|
from modules import custom_filters
|
||||||
|
|
||||||
# Contact getting ==============================================================================================================
|
# Contact getting ==============================================================================================================
|
||||||
@app.on_message(~ filters.scheduled & filters.contact & filters.private)
|
@app.on_message(~ filters.scheduled & (custom_filters.allowed | custom_filters.admin) & filters.contact & filters.private)
|
||||||
async def get_contact(app: Client, msg: Message):
|
async def get_contact(app: Client, msg: Message):
|
||||||
|
|
||||||
holo_user = HoloUser(msg.from_user)
|
holo_user = HoloUser(msg.from_user)
|
||||||
|
|
||||||
if holo_user.application_approved() or (await isAnAdmin(holo_user.id) is True):
|
|
||||||
|
|
||||||
if msg.contact.user_id != None:
|
if msg.contact.user_id != None:
|
||||||
|
|
||||||
application = col_applications.find_one({"user": msg.contact.user_id})
|
application = col_applications.find_one({"user": msg.contact.user_id})
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from os import path, sep
|
from os import path, sep
|
||||||
from app import app, isAnAdmin
|
from app import app, isAnAdmin
|
||||||
from pyrogram.types import InlineQueryResultArticle, InputTextMessageContent
|
from pyrogram.types import InlineQueryResultArticle, InputTextMessageContent, InlineQuery
|
||||||
|
from pyrogram.client import Client
|
||||||
from pyrogram.enums.chat_type import ChatType
|
from pyrogram.enums.chat_type import ChatType
|
||||||
from pyrogram.enums.chat_members_filter import ChatMembersFilter
|
from pyrogram.enums.chat_members_filter import ChatMembersFilter
|
||||||
from dateutil.relativedelta import relativedelta
|
from dateutil.relativedelta import relativedelta
|
||||||
@ -10,7 +11,7 @@ from modules.utils import configGet, locale
|
|||||||
from modules.database import col_applications
|
from modules.database import col_applications
|
||||||
|
|
||||||
@app.on_inline_query()
|
@app.on_inline_query()
|
||||||
async def inline_answer(client, inline_query):
|
async def inline_answer(client: Client, inline_query: InlineQuery):
|
||||||
|
|
||||||
if inline_query.chat_type in [ChatType.CHANNEL]:
|
if inline_query.chat_type in [ChatType.CHANNEL]:
|
||||||
await inline_query.answer(
|
await inline_query.answer(
|
||||||
|
Reference in New Issue
Block a user