コード例 #1
0
"""Invite the user(s) to the current chat
Syntax: .invite <User(s)>"""

from telethon import functions

from jarvis.utils import j_cmd, edit_or_reply, sudo_cmd


@jarvis.on(j_cmd(pattern="invite ?(.*)"))
@jarvis.on(sudo_cmd(pattern="invite ?(.*)", allow_sudo=True))
async def _(event):
    if event.fwd_from:
        return
    to_add_users = event.pattern_match.group(1)
    if event.is_private:
        await edit_or_reply(
            event, "`.invite` users to a chat, not to a Private Message")
    else:
        logger.info(to_add_users)
        if not event.is_channel and event.is_group:
            # https://lonamiwebs.github.io/Telethon/methods/messages/add_chat_user.html
            for user_id in to_add_users.split(" "):
                try:
                    await jarvis(
                        functions.messages.AddChatUserRequest(
                            chat_id=event.chat_id,
                            user_id=user_id,
                            fwd_limit=1000000))
                except Exception as e:
                    await edit_or_reply(event, str(e))
                    return
コード例 #2
0
# credits: SNAPDRAGON (@s_n_a_p_s)
import asyncio
import time

from jarvis.utils import j_cmd


@jarvis.on(
    j_cmd(
        pattern=
        "webupload ?(.+?|) (?:--)(anonfiles|transfer|filebin|anonymousfiles|megaupload|bayfiles)"
    ))
async def _(event):
    if event.fwd_from:
        return
    await event.edit("Processing ...")
    PROCESS_RUN_TIME = 100
    input_str = event.pattern_match.group(1)
    selected_transfer = event.pattern_match.group(2)
    if input_str:
        file_name = input_str
    else:
        reply = await event.get_reply_message()
        file_name = await jarvis.download_media(reply.media,
                                                Var.TEMP_DOWNLOAD_DIRECTORY)
    event.message.id
    CMD_WEB = {
        "anonfiles": 'curl -F "file=@{}" https://anonfiles.com/api/upload',
        "transfer":
        'curl --upload-file "{}" https://transfer.sh/{os.path.basename(file_name)}',
        "filebin":
コード例 #3
0
ファイル: mask.py プロジェクト: sushil-great/JarvisUserbot
from telethon import events
from telethon.errors.rpcerrorlist import YouBlockedUserError

from jarvis.utils import j_cmd, edit_or_reply, sudo_cmd


@jarvis.on(j_cmd("mask ?(.*)", outgoing=True))
@jarvis.on(sudo_cmd("mask ?(.*)", allow_sudo=True))
async def _(event):
    if event.fwd_from:
        return
    if not event.reply_to_msg_id:
        await edit_or_reply(event, "```Reply to any user message.```")
        return
    reply_message = await event.get_reply_message()
    if not reply_message.media:
        await edit_or_reply(event, "```reply to text message```")
        return
    chat = "@hazmat_suit_bot"
    reply_message.sender
    if reply_message.sender.bot:
        await edit_or_reply(event, "```Reply to actual users message.```")
        return
    await edit_or_reply(event, "```Processing```")
    async with bot.conversation(chat) as conv:
        try:
            response = conv.wait_event(
                events.NewMessage(incoming=True, from_users=905164246))
            await jarvis.send_message(chat, reply_message)
            response = await response
        except YouBlockedUserError:
コード例 #4
0
"""Get Detailed info about any message
Syntax: .json"""
import io

from jarvis.utils import j_cmd, edit_or_reply, sudo_cmd


@jarvis.on(j_cmd("json", outgoing=True))
@jarvis.on(sudo_cmd("json", allow_sudo=True))
async def _(event):
    if event.fwd_from:
        return
    the_real_message = None
    reply_to_id = None
    if event.reply_to_msg_id:
        previous_message = await event.get_reply_message()
        the_real_message = previous_message.stringify()
        reply_to_id = event.reply_to_msg_id
    else:
        the_real_message = event.stringify()
        reply_to_id = event.message.id
    if len(the_real_message) > Config.MAX_MESSAGE_SIZE_LIMIT:
        with io.BytesIO(str.encode(the_real_message)) as out_file:
            out_file.name = "json.text"
            await jarvis.send_file(
                event.chat_id,
                out_file,
                force_document=True,
                allow_cache=False,
                reply_to=reply_to_id,
            )
コード例 #5
0
    name = event.raw_text
    snips = sql.get_chat_blacklist(event.chat_id)
    for snip in snips:
        pattern = r"( |^|[^\w])" + re.escape(snip) + r"( |$|[^\w])"
        if re.search(pattern, name, flags=re.IGNORECASE):
            try:
                await event.delete()
            except Exception:
                await edit_or_reply(
                    event, "I do not have DELETE permission in this chat"
                )
                sql.rm_from_blacklist(event.chat_id, snip.lower())
            break


@jarvis.on(j_cmd("addblacklist ((.|\n)*)", outgoing=True))
@jarvis.on(sudo_cmd("addblacklist ((.|\n)*)", allow_sudo=True))
async def on_add_black_list(event):
    text = event.pattern_match.group(1)
    to_blacklist = list(
        set(trigger.strip() for trigger in text.split("\n") if trigger.strip())
    )
    for trigger in to_blacklist:
        sql.add_to_blacklist(event.chat_id, trigger.lower())
    await edit_or_reply(
        event,
        "Added {} triggers to the blacklist in the current chat".format(
            len(to_blacklist)
        ),
    )
コード例 #6
0
"""Take screenshot of any website
Syntax: .screenlong <Website URL>"""

import io
import traceback
from datetime import datetime

from selenium import webdriver

from jarvis.utils import j_cmd, eor, sudo_cmd


@jarvis.on(j_cmd("screenlong (.*)", outgoing=True))
@jarvis.on(sudo_cmd("screenlong (.*)", allow_sudo=True))
async def _(event):
    if event.fwd_from:
        return
    if Config.GOOGLE_CHROME_BIN is None:
        await eor(event, "need to install Google Chrome. Module Stopping.")
        return
    jevent = await eor(event, "Processing ...")
    start = datetime.now()
    try:
        chrome_options = webdriver.ChromeOptions()
        chrome_options.add_argument("--ignore-certificate-errors")
        chrome_options.add_argument("--test-type")
        chrome_options.add_argument("--headless")
        # https://stackoverflow.com/a/53073789/4723940
        chrome_options.add_argument("--no-sandbox")
        chrome_options.add_argument("--disable-dev-shm-usage")
        chrome_options.binary_location = Config.GOOGLE_CHROME_BIN
コード例 #7
0
ファイル: img.py プロジェクト: sushil-great/JarvisUserbot
"""Download & Upload Images on Telegram\n
Syntax: `.img <Name>` or `.img (replied message)`
\n Upgraded and Google Image Error Fixed
"""

import os
import shutil
from re import findall

from jarvis.google_imgs import googleimagesdownload
from jarvis.utils import j_cmd, edit_or_reply, sudo_cmd


@jarvis.on(j_cmd(pattern="img ?(.*)", outgoing=True))
@jarvis.on(sudo_cmd(pattern="img ?(.*)", allow_sudo=True))
async def img_sampler(event):
    await edit_or_reply(event, "`Processing...`")
    reply = await event.get_reply_message()
    if event.pattern_match.group(1):
        query = event.pattern_match.group(1)
    elif reply:
        query = reply.message
    else:
        await edit_or_reply(
            event, "`um, mind mentioning what I actually need to search for ;_;`"
        )
        return

    lim = findall(r"lim=\d+", query)
    # lim = event.pattern_match.group(1)
    try:
コード例 #8
0
ファイル: voice.py プロジェクト: sushil-great/JarvisUserbot
""" Google Text to Speech
Available Commands:
.tts LanguageCode as reply to a message
.tts LangaugeCode | text to speak"""
import asyncio
import os
import subprocess
from datetime import datetime

from gtts import gTTS

from jarvis import CMD_HELP
from jarvis.utils import j_cmd


@jarvis.on(j_cmd(pattern="voice (.*)"))
@jarvis.on(j_cmd(pattern="voice (.*)", allow_sudo=True))
async def _(event):
    if event.fwd_from:
        return
    input_str = event.pattern_match.group(1)
    start = datetime.now()
    if event.reply_to_msg_id:
        previous_message = await event.get_reply_message()
        text = previous_message.message
        lan = input_str
    elif "|" in input_str:
        lan, text = input_str.split("|")
    else:
        await event.reply("Invalid Syntax. Module stopping.")
        return
コード例 #9
0
    file_id = file_id[1:]
    return file_id


async def get_file_name(content):
    file_name = ""
    c_append = False
    for c in str(content):
        if c == '"':
            c_append = True
        if c == ";":
            c_append = False
        if c_append:
            file_name = file_name + c
    file_name = file_name.replace('"', "")
    print("File Name: " + str(file_name))
    return file_name


@jarvis.on(j_cmd(pattern=r"gdl", outgoing=True))
@jarvis.on(sudo_cmd(pattern=r"gdl", allow_sudo=True))
async def g_download(event):
    if event.fwd_from:
        return
    drive_link = event.text[4:]
    print("Drive Link: " + drive_link)
    file_id = await get_id(drive_link)
    await edit_or_reply(event, "Downloading Requested File from G-Drive...")
    file_name = await download_file_from_google_drive(file_id)
    await event.edit("File Downloaded.\nName: `" + str(file_name) + "`")
コード例 #10
0
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2
from telethon.tl.types import ChannelParticipantsAdmins

from jarvis.utils import j_cmd


@jarvis.on(j_cmd(pattern=r"tagall", outgoing=True))
@jarvis.on(j_cmd(pattern=r"tagall", allow_sudo=True))
async def _(event):
    if event.fwd_from:
        return
    mentions = "Tagging All Of You Guys !!! ❤️❤️❤️"
    chat = await event.get_input_chat()
    async for x in bot.iter_participants(chat, 100):
        mentions += f" \n [{x.first_name}](tg://user?id={x.id})"
    await event.reply(mentions)
    await event.delete()


@jarvis.on(j_cmd(pattern=r"admin", outgoing=True))
@jarvis.on(j_cmd(pattern=r"admin", allow_sudo=True))
async def _(event):
    if event.fwd_from:
        return
    mentions = "Admins : "
    chat = await event.get_input_chat()
    async for x in bot.iter_participants(chat,
                                         filter=ChannelParticipantsAdmins):
        mentions += f" \n [{x.first_name}](tg://user?id={x.id})"
コード例 #11
0
ファイル: weebify.py プロジェクト: sushil-great/JarvisUserbot
    "口",
    "尸",
    "㔿",
    "尺",
    "丂",
    "丅",
    "凵",
    "リ",
    "山",
    "乂",
    "丫",
    "乙",
]


@jarvis.on(j_cmd(pattern="weeb ?(.*)"))
async def weebify(event):

    args = event.pattern_match.group(1)
    if not args:
        get = await event.get_reply_message()
        args = get.text
    if not args:
        await event.edit("`What I am Supposed to Weebify U Dumb`")
        return
    string = "  ".join(args).lower()
    for normiecharacter in string:
        if normiecharacter in normiefont:
            weebycharacter = weebyfont[normiefont.index(normiecharacter)]
            string = string.replace(normiecharacter, weebycharacter)
    await event.edit(string)
コード例 #12
0
# you may not use this file except in compliance with the License.
#

import io
import os
import os.path
import time
from os.path import exists, isdir

from jarvis import CMD_HELP
from jarvis.utils import j_cmd, eor, humanbytes, sudo_cmd

MAX_MESSAGE_SIZE_LIMIT = 4095


@jarvis.on(j_cmd(outgoing=True, pattern=r"ls ?(.*)"))
@jarvis.on(sudo_cmd(allow_sudo=True, pattern=r"ls ?(.*)"))
async def lst(event):
    if event.fwd_from:
        return
    jeve = event.pattern_match.group(1)
    if jeve:
        path = jeve
    else:
        path = os.getcwd()
    if not exists(path):
        await eor(
            event,
            f"There is no such directory or file with the name `{jeve}` check again!",
        )
        return
コード例 #13
0
ファイル: misc.py プロジェクト: sushil-great/JarvisUserbot
from random import randint
from time import sleep

from telethon.tl.types import (
    ChannelParticipantAdmin,
    ChannelParticipantCreator,
    ChannelParticipantsAdmins,
    ChannelParticipantsBots,
)
from telethon.utils import pack_bot_file_id

from jarvis.utils import j_cmd, edit_or_reply, eor, sudo_cmd


@jarvis.on(j_cmd(outgoing=True, pattern="random"))
@jarvis.on(sudo_cmd(allow_sudo=True, pattern="random"))
async def randomise(items):
    """ For .random command, get a random item from the list of items. """
    if not items.text[0].isalpha() and items.text[0] not in ("/", "#", "@", "!"):
        itemo = (items.text[8:]).split()
        index = randint(1, len(itemo) - 1)
        await edit_or_reply(
            items,
            "**Query: **\n`"
            + items.text[8:]
            + "`\n**Output: **\n`"
            + itemo[index]
            + "`",
        )
コード例 #14
0
ファイル: reverse.py プロジェクト: sushil-great/JarvisUserbot
import re
import urllib

import requests
from bs4 import BeautifulSoup
from PIL import Image

from jarvis import CMD_HELP
from jarvis.utils import j_cmd, eor, errors_handler, sudo_cmd

opener = urllib.request.build_opener()
useragent = "Mozilla/5.0 (Linux; Android 9; SM-G960F Build/PPR1.180610.011; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/74.0.3729.157 Mobile Safari/537.36"
opener.addheaders = [("User-agent", useragent)]


@jarvis.on(j_cmd(pattern=r"reverse(?: |$)(\d*)", outgoing=True))
@jarvis.on(sudo_cmd(pattern=r"reverse(?: |$)(\d*)", allow_sudo=True))
@errors_handler
async def _(img):
    if os.path.isfile("okgoogle.png"):
        os.remove("okgoogle.png")
    message = await img.get_reply_message()
    if message and message.media:
        photo = io.BytesIO()
        await jarvis.download_media(message, photo)
    else:
        await eor(img, "`Reply to photo or sticker nigger.`")
        return
    if photo:
        jevent = await eor(img, "`Processing...`")
        try:
コード例 #15
0
from jarvis import CMD_HELP
from jarvis.jconfig import Config
from jarvis.utils import j_cmd

logging.basicConfig(
    format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
    level=logging.WARN)

NO_PM_LOG_USERS = []

BOTLOG = True
BOTLOG_CHATID = Config.PRIVATE_GROUP_BOT_API_ID


@jarvis.on(j_cmd(outgoing=True, pattern=r"save(?: |$)([\s\S]*)"))
async def log(log_text):
    """ For .log command, forwards a message or the command argument to the bot logs group """
    if BOTLOG:
        if log_text.reply_to_msg_id:
            reply_msg = await log_text.get_reply_message()
            await reply_msg.forward_to(BOTLOG_CHATID)
        elif log_text.pattern_match.group(1):
            user = f"#LOG / Chat ID: {log_text.chat_id}\n\n"
            textx = user + log_text.pattern_match.group(1)
            await jarvis.send_message(BOTLOG_CHATID, textx)
        else:
            await log_text.edit("`What am I supposed to log?`")
            return
        await log_text.edit("`Logged Successfully`")
    else:
コード例 #16
0
ファイル: pokedex.py プロジェクト: sushil-great/JarvisUserbot
# Made By @DragSama with help of @TheRealPhoenix
# Uses PokeApi.co
"""pokedex for pokemon info .berry for berry info .move for move info"""

import requests

from jarvis.utils import j_cmd, eor, sudo_cmd


@jarvis.on(j_cmd(pattern="pokedex ?(.*)", outgoing=True))
@jarvis.on(sudo_cmd(pattern="pokedex ?(.*)", allow_sudo=True))
async def pokedex(event):
    string = event.pattern_match.group(1)
    url = "http://pokeapi.co/api/v2/pokemon/{}/".format(string)
    response = requests.get(url)
    if response.status_code == 200:
        data = response.json()
        msg = ""
        name = data.get("name")
        (data.get("abilities")[0].get("ability"))
        height = data.get("height")
        pokeid = data.get("id")
        (data.get("held_items"))
        sprites = data.get("sprites")
        sprites_front = sprites.get("front_default")
        weight = data.get("weight")
        types = data.get("types")[0].get("type")
        typesa = types.get("name")
        msg += "\n**Name** = {}".format(name)
        typecount = data.get("types")
        msg += "\n**ID** = {}".format(pokeid)
コード例 #17
0
import asyncio

from jarvis.utils import j_cmd


# @command(pattern="^.cmds", outgoing=True)
@jarvis.on(j_cmd(pattern=r"cmds"))
async def install(event):
    if event.fwd_from:
        return
    cmd = "ls jarvis/plugins"
    process = await asyncio.create_subprocess_shell(
        cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE)
    stdout, stderr = await process.communicate()
    o = stdout.decode()
    _o = o.split("\n")
    o = "\n".join(_o)
    OUTPUT = f"**List of Plugins:**\n{o}\n\n**HELP:** __If you want to know the commands for a plugin, do:-__ \n `.help <plugin name>` **without the < > brackets.**\n__All plugins might not work directly. Visit__ @jarvisot __for assistance.__"
    await event.edit(OUTPUT)
コード例 #18
0
"""Quickly make a decision
Syntax: .decide"""
import requests

from jarvis.utils import j_cmd, sudo_cmd


@jarvis.on(j_cmd("decide", outgoing=True))
@jarvis.on(sudo_cmd("decide", allow_sudo=True))
async def _(event):
    if event.fwd_from:
        return
    message_id = event.message.id
    if event.reply_to_msg_id:
        message_id = event.reply_to_msg_id
    r = requests.get("https://yesno.wtf/api").json()
    await jarvis.send_message(event.chat_id,
                              r["answer"],
                              reply_to=message_id,
                              file=r["image"])
    await event.delete()
コード例 #19
0
    pack = COLLECTION_STRING[rnd]

    pc = requests.get("http://getwallpapers.com/collection/" + pack).text
    f = re.compile("/\w+/full.+.jpg")
    f = f.findall(pc)
    fy = "http://getwallpapers.com" + random.choice(f)
    print(fy)
    if not os.path.exists("f.ttf"):
        urllib.request.urlretrieve(
            "https://github.com/rebel6969/mym/raw/master/Rebel-robot-Regular.ttf",
            "f.ttf",
        )
    urllib.request.urlretrieve(fy, "donottouch.jpg")


@jarvis.on(j_cmd(pattern="avengersdp ?(.*)"))
@jarvis.on(sudo_cmd(pattern="avengersdp ?(.*)", allow_sudo=True))
async def main(event):
    if event.fwd_from:
        return
    await edit_or_reply(
        event,
        "**Starting Avengers Profile Pic...\n\nDone ! Check Your DP By @JarvisOt**",
    )
    while True:
        await animepp()
        file = await event.client.upload_file("donottouch.jpg")
        await event.client(functions.photos.UploadProfilePhotoRequest(file))
        os.system("rm -rf donottouch.jpg")
        await asyncio.sleep(1000)  # Edit this to your required needs
コード例 #20
0
ファイル: app.py プロジェクト: sushil-great/JarvisUserbot
"""Fetch App Details from Playstore.
.app <app_name> to fetch app details.
.appr <app_name>  to fetch app details with Xpl0iter request link."""

import bs4
import requests

from jarvis.utils import j_cmd, sudo_cmd


@jarvis.on(j_cmd(pattern="app (.*)"))
@jarvis.on(sudo_cmd(pattern="app (.*)", allow_sudo=True))
async def apk(e):
    if event.fwd_from:
        return
    try:
        app_name = e.pattern_match.group(1)
        remove_space = app_name.split(" ")
        final_name = "+".join(remove_space)
        page = requests.get("https://play.google.com/store/search?q=" +
                            final_name + "&c=apps")
        str(page.status_code)
        soup = bs4.BeautifulSoup(page.content, "lxml", from_encoding="utf-8")
        results = soup.findAll("div", "ZmHEEd")
        app_name = (results[0].findNext("div", "Vpfmgd").findNext(
            "div", "WsMG1c nnK0zc").text)
        app_dev = results[0].findNext("div",
                                      "Vpfmgd").findNext("div", "KoLSrc").text
        app_dev_link = ("https://play.google.com" + results[0].findNext(
            "div", "Vpfmgd").findNext("a", "mnKHRc")["href"])
        app_rating = (results[0].findNext("div", "Vpfmgd").findNext(
コード例 #21
0
    "\U0001F780-\U0001F7FF"  # Geometric Shapes Extended
    "\U0001F800-\U0001F8FF"  # Supplemental Arrows-C
    "\U0001F900-\U0001F9FF"  # Supplemental Symbols and Pictographs
    "\U0001FA00-\U0001FA6F"  # Chess Symbols
    "\U0001FA70-\U0001FAFF"  # Symbols and Pictographs Extended-A
    "\U00002702-\U000027B0"  # Dingbats
    "]+")


def deEmojify(inputString: str) -> str:
    """Remove emojis and other non-safe characters from string"""
    return re.sub(EMOJI_PATTERN, "", inputString)


# @register(outgoing=True, pattern="^.waifu(?: |$)(.*)", allow_sudo=True))
@jarvis.on(j_cmd(pattern=r"waifu(?: |$)(.*)"))
@jarvis.on(sudo_cmd(pattern=r"waifu(?: |$)(.*)", allow_sudo=True))
async def waifu(animu):
    if waifu.fwd_from:
        return
    # """Creates random anime sticker!"""

    text = animu.pattern_match.group(1)
    if not text:
        if animu.is_reply:
            text = (await animu.get_reply_message()).message
        else:
            await edit_or_reply(
                animu,
                "`You haven't written any article, Waifu is going away.`")
            return
コード例 #22
0
ファイル: memify.py プロジェクト: sushil-great/JarvisUserbot
import asyncio
import os
import textwrap

from hachoir.metadata import extractMetadata
from hachoir.parser import createParser
from PIL import Image, ImageDraw, ImageFont
from telethon.tl.types import DocumentAttributeFilename

from jarvis import TEMP_DOWNLOAD_DIRECTORY
from jarvis.utils import j_cmd, eor, sudo_cmd

THUMB_IMAGE_PATH = "./jarvis.png"


@jarvis.on(j_cmd(outgoing=True, pattern=r"mmf(?: |$)(.*)"))
@jarvis.on(sudo_cmd(allow_sudo=True, pattern=r"mmf(?: |$)(.*)"))
async def mim(event):
    if not event.reply_to_msg_id:
        await eor(
            event,
            "`Syntax: reply to an image with .mmf` 'text on top' ; 'text on bottom' ",
        )
        return

    reply_message = await event.get_reply_message()
    if not reply_message.media:
        await eor(event, "```reply to a image/sticker/gif```")
        return
    await eor(event, "`Downloading Media..`")
    if reply_message.photo:
コード例 #23
0
            "api_url": "http://api.antiddos.systems",
            "username_colors": [
                "#fb6169",
                "#faa357",
                "#b48bf2",
                "#85de85",
                "#62d4e3",
                "#65bdf3",
                "#ff5694",
            ],
            "default_username_color": "#b48bf2",
        }
    )
    client = jarvis

    @jarvis.on(j_cmd(pattern="chat(.*)"))
    async def quotecmd(message):  # noqa: C901
        """Quote a message.
        Usage: .quote [template]
        If template is missing, possible templates are fetched."""
        await message.delete()
        args = message.raw_text.split(" ")[1:]
        if args == []:
            args = ["default"]
        reply = await message.get_reply_message()

        if not reply:
            return await message.respond(strings["no_reply"])

        if not args:
            return await message.respond(strings["no_template"])
コード例 #24
0
"""use command .ducduckgo"""

from jarvis.utils import j_cmd, edit_or_reply, sudo_cmd


@jarvis.on(j_cmd("ducduckgo (.*)", outgoing=True))
@jarvis.on(sudo_cmd("ducduckgo (.*)", allow_sudo=True))
async def _(event):
    if event.fwd_from:
        return
    input_str = event.pattern_match.group(1)
    sample_url = "https://duckduckgo.com/?q={}".format(
        input_str.replace(" ", "+"))
    if sample_url:
        link = sample_url.rstrip()
        await edit_or_reply(
            event,
            "Let me 🦆 DuckDuckGo that for you:\n🔎 [{}]({})".format(
                input_str, link),
        )
    else:
        await edit_or_reply(event,
                            "something is wrong. please try again later.")
コード例 #25
0
                "#AfkLogger My Boss is Busy",
            )
        except Exception as e:  # pylint:disable=C0103,W0703
            await jarvis.send_message(  # pylint:disable=E0602
                event.chat_id,
                "Please set `PLUGIN_CHANNEL` " +
                "for the proper functioning of afk functionality " +
                "in @JarvisSupportOT\n\n `{}`".format(str(e)),
                reply_to=event.message.id,
                silent=True,
            )
        USER_AFK = {}  # pylint:disable=E0602
        afk_time = None  # pylint:disable=E0602


@jarvis.on(j_cmd(pattern=r"afk ?(.*)"))
@jarvis.on(sudo_cmd(pattern=r"afk ?(.*)", allow_sudo=True))
async def _(event):
    if event.fwd_from:
        return
    global USER_AFK  # pylint:disable=E0602
    global afk_time  # pylint:disable=E0602
    global last_afk_message  # pylint:disable=E0602
    global reason
    USER_AFK = {}
    afk_time = None
    last_afk_message = {}
    reason = event.pattern_match.group(1)
    if not USER_AFK:  # pylint:disable=E0602
        last_seen_status = await jarvis(  # pylint:disable=E0602
            functions.account.GetPrivacyRequest(
コード例 #26
0
ファイル: colors.py プロジェクト: sushil-great/JarvisUserbot
"""Color Plugin for @Jarvis
Syntax: .color <color_code>"""
import os

from PIL import Image, ImageColor

from jarvis.utils import j_cmd, edit_or_reply, sudo_cmd


@jarvis.on(j_cmd(pattern="color (.*)", outgoing=True))
@jarvis.on(sudo_cmd(pattern="color (.*)", allow_sudo=True))
async def _(event):
    if event.fwd_from:
        return
    input_str = event.pattern_match.group(1)
    message_id = event.message.id
    if event.reply_to_msg_id:
        message_id = event.reply_to_msg_id
    if input_str.startswith("#"):
        try:
            usercolor = ImageColor.getrgb(input_str)
        except Exception as e:
            await edit_or_reply(event, str(e))
            return False
        else:
            im = Image.new(mode="RGB", size=(1280, 720), color=usercolor)
            im.save("jarvis.png", "PNG")
            input_str = input_str.replace("#", "#COLOR_")
            await jarvis.send_file(
                event.chat_id,
                "jarvis.png",
コード例 #27
0
ファイル: filters.py プロジェクト: sushil-great/JarvisUserbot
                        snip.media_file_reference,
                    )
                else:
                    media = None
                event.message.id
                if event.reply_to_msg_id:
                    event.reply_to_msg_id
                await event.reply(snip.reply, file=media)
                if event.chat_id not in last_triggered_filters:
                    last_triggered_filters[event.chat_id] = []
                last_triggered_filters[event.chat_id].append(name)
                await asyncio.sleep(DELETE_TIMEOUT)
                last_triggered_filters[event.chat_id].remove(name)


@jarvis.on(j_cmd(pattern="savefilter (.*)", outgoing=True))
@jarvis.on(sudo_cmd(pattern="savefilter (.*)", allow_sudo=True))
async def on_snip_save(event):
    name = event.pattern_match.group(1)
    msg = await event.get_reply_message()
    if msg:
        snip = {"type": TYPE_TEXT, "text": msg.message or ""}
        if msg.media:
            media = None
            if isinstance(msg.media, types.MessageMediaPhoto):
                media = utils.get_input_photo(msg.media.photo)
                snip["type"] = TYPE_PHOTO
            elif isinstance(msg.media, types.MessageMediaDocument):
                media = utils.get_input_document(msg.media.document)
                snip["type"] = TYPE_DOCUMENT
            if media:
コード例 #28
0
import asyncio
import time

from telethon.errors import FloodWaitError
from telethon.tl import functions

from jarvis.utils import j_cmd, eor, sudo_cmd

DEL_TIME_OUT = 60


@jarvis.on(j_cmd(pattern="bio"))  # pylint:disable=E0602
@jarvis.on(sudo_cmd(pattern="bio", allow_sudo=True))
async def _(event):
    if event.fwd_from:
        return
    while True:
        DMY = time.strftime("%d.%m.%Y")
        HM = time.strftime("%H:%M:%S")
        bio = f"📅 {DMY} | User Of JarvisUserbot 😎 | ⌚️ {HM}"
        logger.info(bio)
        try:
            await jarvis(
                functions.account.UpdateProfileRequest(  # pylint:disable=E0602
                    about=bio))
            await eor(event, "Autobio Enabled !!")
            await asyncio.sleep(2)
            await event.delete()
        except FloodWaitError as ex:
            logger.warning(str(e))
            await asyncio.sleep(ex.seconds)
コード例 #29
0
from telethon.errors.rpcerrorlist import YouBlockedUserError

from jarvis.utils import j_cmd, eor, sudo_cmd


@jarvis.on(j_cmd("sg ?(.*)", outgoing=True))
@jarvis.on(sudo_cmd("sg ?(.*)", allow_sudo=True))
async def lastname(steal):
    if steal.fwd_from:
        return
    if not steal.reply_to_msg_id:
        await steal.edit("Reply to any user message.")
        return
    message = await steal.get_reply_message()
    chat = "@SangMataInfo_bot"
    user_id = message.sender.id
    id = f"/search_id {user_id}"
    if message.sender.bot:
        await steal.edit("Reply to actual users message.")
        return
    lol = await eor(steal, "Processingg !!!!!")
    try:
        async with bot.conversation(chat) as conv:
            try:
                msg = await conv.send_message(id)
                r = await conv.get_response()
                response = await conv.get_response()
            except YouBlockedUserError:
                await lol.edit("Please unblock @sangmatainfo_bot and try again"
                               )
                return
コード例 #30
0
"""Emoji
Available Commands:
.supporthelp
Credits to noone
"""

import asyncio

from jarvis.utils import j_cmd


@jarvis.on(j_cmd("supporthelp"))
async def _(event):
    if event.fwd_from:
        return
    animation_interval = 0.1
    animation_ttl = range(0, 36)
    # input_str = event.pattern_match.group(1)
    # if input_str == "support":
    await event.edit("for our support group")
    animation_chars = [
        "Click here", "[Support Group](https://t.me/jarvissupportot)"
    ]

    for i in animation_ttl:

        await asyncio.sleep(animation_interval)
        await event.edit(animation_chars[i % 18])