コード例 #1
0
USERS = {}

__tmp__ = SAVED_SETTINGS.find_one({'_id': 'AFK'})

if __tmp__:
    IS_AFK = __tmp__['on']
    REASON = __tmp__['data']
    TIME = __tmp__['time'] if 'time' in __tmp__ else 0

del __tmp__

for _user in AFK_COLLECTION.find():
    USERS.update(
        {_user['_id']: [_user['pcount'], _user['gcount'], _user['men']]})

IS_AFK_FILTER = Filters.create(lambda _, __: bool(IS_AFK))


@userge.on_cmd(
    "afk",
    about={
        'header':
        "Set to AFK mode",
        'description':
        "Sets your status as AFK. Responds to anyone who tags/PM's.\n"
        "you telling you are AFK. Switches off AFK when you type back anything.",
        'usage':
        "{tr}afk or {tr}afk [reason]"
    })
async def active_afk(message: Message) -> None:
    global REASON, IS_AFK, TIME
コード例 #2
0
ファイル: filters.py プロジェクト: xten81/Userge
# Copyright (C) 2020 by UsergeTeam@Github, < https://github.com/UsergeTeam >.
#
# This file is part of < https://github.com/UsergeTeam/Userge > project,
# and is released under the "GNU v3.0 License Agreement".
# Please see < https://github.com/uaudith/Userge/blob/master/LICENSE >
#
# All rights reserved.

from userge import userge, Message, Filters, get_collection

FILTERS_COLLECTION = get_collection("filters")

FILTERS_DATA = {}
FILTERS_CHATS = Filters.create(lambda _, query: query.chat.id in FILTERS_DATA)


def _filter_updater(chat_id: int, name: str, content: str) -> None:
    if chat_id in FILTERS_DATA:
        FILTERS_DATA[chat_id].update({name: content})
    else:
        FILTERS_DATA[chat_id] = {name: content}


def _filter_deleter(chat_id: int, name: str) -> None:
    if chat_id in FILTERS_DATA and name in FILTERS_DATA[chat_id]:
        FILTERS_DATA[chat_id].pop(name)
        if not FILTERS_DATA[chat_id]:
            FILTERS_DATA.pop(chat_id)


for flt in FILTERS_COLLECTION.find():
コード例 #3
0
ファイル: welcome.py プロジェクト: souvik30/userge
""" auto welcome and left messages """

# Copyright (C) 2020 by UsergeTeam@Github, < https://github.com/UsergeTeam >.
#
# This file is part of < https://github.com/UsergeTeam/Userge > project,
# and is released under the "GNU v3.0 License Agreement".
# Please see < https://github.com/uaudith/Userge/blob/master/LICENSE >
#
# All rights reserved.

from userge import userge, Filters, Message, Config, get_collection

WELCOME_COLLECTION = get_collection("welcome")
LEFT_COLLECTION = get_collection("left")
WELCOME_CHATS = Filters.chat([])
LEFT_CHATS = Filters.chat([])
CHANNEL = userge.getCLogger(__name__)


async def _init() -> None:
    async for i in WELCOME_COLLECTION.find({'on': True}):
        if 'mid' not in i:
            continue
        WELCOME_CHATS.add(i.get('_id'))
    async for i in LEFT_COLLECTION.find({'on': True}):
        if 'mid' not in i:
            continue
        LEFT_CHATS.add(i.get('_id'))


@userge.on_cmd("setwelcome", about={
コード例 #4
0
ファイル: afk.py プロジェクト: souvik30/userge
#
# All rights reserved.

import time
import asyncio
from random import choice, randint

from userge import userge, Message, Filters, Config, get_collection
from userge.utils import time_formatter

CHANNEL = userge.getCLogger(__name__)
SAVED_SETTINGS = get_collection("CONFIGS")
AFK_COLLECTION = get_collection("AFK")

IS_AFK = False
IS_AFK_FILTER = Filters.create(lambda _, __: bool(IS_AFK))
REASON = ''
TIME = 0.0
USERS = {}


async def _init() -> None:
    global IS_AFK, REASON, TIME  # pylint: disable=global-statement
    data = await SAVED_SETTINGS.find_one({'_id': 'AFK'})
    if data:
        IS_AFK = data['on']
        REASON = data['data']
        TIME = data['time'] if 'time' in data else 0
    async for _user in AFK_COLLECTION.find():
        USERS.update(
            {_user['_id']: [_user['pcount'], _user['gcount'], _user['men']]})
コード例 #5
0
ファイル: pmpermit.py プロジェクト: onlinejudge95/UsergeX
#
# All rights reserved.

import asyncio
from typing import Dict

from userge import userge, Filters, Message, Config, get_collection
from userge.utils import SafeDict

CHANNEL = userge.getCLogger(__name__)
SAVED_SETTINGS = get_collection("CONFIGS")
ALLOWED_COLLECTION = get_collection("PM_PERMIT")

allowAllPms = True
pmCounter: Dict[int, int] = {}
allowAllFilter = Filters.create(lambda _, query: bool(allowAllPms))
noPmMessage = ("Hello {fname} this is an automated message\n"
               "Please wait untill you get approved to direct message "
               "And please dont spam untill then ")


async def _init() -> None:
    global allowAllPms, noPmMessage
    async for chat in ALLOWED_COLLECTION.find({"status": 'allowed'}):
        Config.ALLOWED_CHATS.add(chat.get("_id"))
    _pm = await SAVED_SETTINGS.find_one({'_id': 'PM GUARD STATUS'})
    if _pm:
        allowAllPms = bool(_pm.get('data'))
    _pmMsg = await SAVED_SETTINGS.find_one({'_id': 'CUSTOM NOPM MESSAGE'})
    if _pmMsg:
        noPmMessage = _pmMsg.get('data')
コード例 #6
0
USERS = {}

__tmp__ = SAVED_SETTINGS.find_one({'_id': 'AFK'})

if __tmp__:
    IS_AFK = __tmp__['on']
    REASON = __tmp__['data']
    TIME = __tmp__['time'] if 'time' in __tmp__ else 0

del __tmp__

for _user in AFK_COLLECTION.find():
    USERS.update(
        {_user['_id']: [_user['pcount'], _user['gcount'], _user['men']]})

IS_AFK_FILTER = Filters.create(lambda _, query: bool(IS_AFK))


@userge.on_cmd("afk",
               about="""\
__Set to AFK mode__

    Sets your status as AFK. Responds to anyone who tags/PM's
    you telling you are AFK. Switches off AFK when you type back anything.

**Usage:**

    `.afk` or `.afk [reason]`""")
async def active_afk(message: Message):
    global REASON, IS_AFK, TIME
コード例 #7
0
ファイル: pmpermit.py プロジェクト: Hyper-hi/Add
# Please see < https://github.com/uaudith/Userge/blob/master/LICENSE >
#
# All rights reserved.

import asyncio
from typing import Dict

from userge import userge, Filters, Message, Config, get_collection
from userge.utils import SafeDict

CHANNEL = userge.getCLogger(__name__)
SAVED_SETTINGS = get_collection("CONFIGS")
ALLOWED_COLLECTION = get_collection("PM_PERMIT")

pmCounter: Dict[int, int] = {}
allowAllFilter = Filters.create(lambda _, __: Config.ALLOW_ALL_PMS)
noPmMessage = ("Hello {fname} this is an automated message\n"
               "Please wait untill you get approved to direct message "
               "And please dont spam untill then ")
blocked_message = "**You were automatically blocked**"


async def _init() -> None:
    global noPmMessage, blocked_message  # pylint: disable=global-statement
    async for chat in ALLOWED_COLLECTION.find({"status": 'allowed'}):
        Config.ALLOWED_CHATS.add(chat.get("_id"))
    _pm = await SAVED_SETTINGS.find_one({'_id': 'PM GUARD STATUS'})
    if _pm:
        Config.ALLOW_ALL_PMS = bool(_pm.get('data'))
    _pmMsg = await SAVED_SETTINGS.find_one({'_id': 'CUSTOM NOPM MESSAGE'})
    if _pmMsg: