Esempio n. 1
0
async def _append_msg(variable: dict, chat: int, event: int) -> None:
    if chat in variable:
        variable[chat]['mentions'].append(event)
    else:
        notif = await client(
            functions.account.GetNotifySettingsRequest(peer=chat))
        notif = types.InputPeerNotifySettings(**vars(notif))
        await _update_notif_settings(chat)
        async for dialog in client.iter_dialogs():
            if chat == dialog.entity.id:
                title = getattr(dialog, 'title', dialog.name)
                unread_count = dialog.unread_count
                last_msg = dialog.message.id
                break
        x = 1
        messages = []
        async for message in client.iter_messages(chat, max_id=last_msg):
            if x >= unread_count:
                if not messages:
                    messages.append(message.id)
                break
            if not message.out:
                x = x + 1
                messages.append(message.id)
        variable[chat] = {
            'title': title,
            'unread_from': messages[-1],
            'mentions': [event],
            'PeerNotifySettings': notif
        }
        messages.clear()
Esempio n. 2
0
    "**This is an automated message, kindly wait until you've been approved "
    "otherwise you'll be blocked and reported for spamming.**\n\n"
    "`Messages Remaining:` **{}**"
)
esc_default = re.escape(default.format(r'\d')).replace(r'\\d', r'\d')
esc_samedefault = re.escape(samedefault.format(r'\d')).replace(r'\\d', r'\d')
esc_newdefault = re.escape(newdefault.format(r'\d')).replace(r'\\d', r'\d')

blocked = "`You've been blocked and reported for spamming.`"
blocklog = (
    "{} `has been blocked for spamming, unblock them to see their messages.`"
)
autoapprove = "`Successfully auto-approved` {}"

DEFAULT_MUTE_SETTINGS = types.InputPeerNotifySettings(
    silent=True,
    mute_until=datetime.timedelta(days=365)
)
DEFAULT_UNMUTE_SETTINGS = types.InputPeerNotifySettings(
    show_previews=True,
    silent=False
)

if redis:
    if redis.exists('approved:users'):
        approvedUsers = dill.loads(redis.get('approved:users'))


@client.onMessage(incoming=True, edited=False)
async def pm_incoming(event: NewMessage.Event) -> None:
    """Filter incoming messages for blocking."""
    if not PM_PERMIT or not redis or not event.is_private:
Esempio n. 3
0
import datetime
import os
import time
import random

from telethon.events import StopPropagation
from telethon.tl import types, functions
from typing import Tuple

from userbot import client
from userbot.plugins import plugins_data
from userbot.utils.helpers import _humanfriendly_seconds, get_chat_link
from userbot.utils.events import NewMessage

DEFAULT_MUTE_SETTINGS = types.InputPeerNotifySettings(
    silent=True, mute_until=datetime.timedelta(days=365))
AFK = plugins_data.AFK
AFK.privates = plugins_data.load_data('userbot_afk_privates')
AFK.groups = plugins_data.load_data('userbot_afk_groups')
AFK.sent = plugins_data.load_data('userbot_afk_sent')

AFKMEMEZ = [
    "You missed me, next time aim better.",
    "Me no here, Me go bye.\nLeave me message. Me reply.",
    "I'll be back in a few minutes and if I'm not...,\nwait longer.",
    "I'm not here right now, so I'm probably somewhere else.",
    "Roses are red, violets are blue.\
        \nLeave me a message, and I'll get back to you.",
    "I'll be right back,\nbut if I'm not right back,\nI'll be back later.",
    "If you haven't figured it out already,\nI'm not here.",
    "Hello, welcome to my away message, how may I ignore you today?",
Esempio n. 4
0
async def _update_stickers_notif(notif: types.PeerNotifySettings) -> None:
    await client(
        functions.account.UpdateNotifySettingsRequest(
            peer="Stickers", settings=types.InputPeerNotifySettings(**vars(notif))
        )
    )