コード例 #1
0
    minutes, seconds = divmod(seconds, 60)
    hours, minutes = divmod(minutes, 60)
    days, hours = divmod(hours, 24)
    tmp = (
        ((str(days) + " day(s), ") if days else "")
        + ((str(hours) + " hour(s), ") if hours else "")
        + ((str(minutes) + " minute(s), ") if minutes else "")
        + ((str(seconds) + " second(s), ") if seconds else "")
        + ((str(milliseconds) + " millisecond(s), ") if milliseconds else "")
    )
    return tmp[:-2]



@friday.on(friday_on_cmd(pattern="deezer ?(.*)"))
@friday.on(sudo_cmd(pattern="deezer ?(.*)", allow_sudo=True))
async def _(event):
    if event.fwd_from:
        return
    input_str = event.pattern_match.group(1)
    credits = "By Friday. Get Your Friday From @FridayOT."
    link = f"https://api.deezer.com/search?q={input_str}&limit=1"
    ommhg = await friday.edit_or_reply(event, "Searching For The Song 🧐🔍")
    dato = requests.get(url=link).json()
    match = dato.get("data")
    urlhp= (match[0])
    print(credits)
    m0 = credits[3]
    urlp = urlhp.get("link")
    thums = urlhp["album"]["cover_big"]
    LLL = "deezer's token fly"
コード例 #2
0
ファイル: translate.py プロジェクト: zankee/FridayUserbot
#    GNU Affero General Public License for more details.
#
#    You should have received a copy of the GNU Affero General Public License
#    along with this program.  If not, see <https://www.gnu.org/licenses/>.

from deep_translator import GoogleTranslator
from googletrans import LANGUAGES
from google_trans_new import google_translator
from langdetect import detect
import requests
from fridaybot import CMD_HELP
from fridaybot.utils import edit_or_reply, friday_on_cmd, sudo_cmd


@friday.on(friday_on_cmd("tr ?(.*)"))
@friday.on(sudo_cmd("tr ?(.*)", allow_sudo=True))
async def _(event):
    if event.fwd_from:
        return
    if "trim" in event.raw_text:
        return
    input_str = event.pattern_match.group(1)
    if event.reply_to_msg_id:
        previous_message = await event.get_reply_message()
        text = previous_message.message
        lan = input_str or "en"
    elif "|" in input_str:
        lan, text = input_str.split("|")
    else:
        await edit_or_reply(event, "`.tr LanguageCode` as reply to a message")
        return
コード例 #3
0
ファイル: ping.py プロジェクト: pinkpider/FridayUserbot
            remainder, result = divmod(seconds, 60)
        else:
            remainder, result = divmod(seconds, 24)
        if seconds == 0 and remainder == 0:
            break
        time_list.append(int(result))
        seconds = int(remainder)

    for x in range(len(time_list)):
        time_list[x] = str(time_list[x]) + time_suffix_list[x]
    if len(time_list) == 4:
        ping_time += time_list.pop() + ", "

    time_list.reverse()
    ping_time += ":".join(time_list)

    return ping_time


@friday.on(friday_on_cmd(pattern="ping$"))
@friday.on(sudo_cmd(pattern="ping$", allow_sudo=True))
async def _(event):
    starkislub = await edit_or_reply(event, "`PONG!`")
    if event.fwd_from:
        return
    start = datetime.now()
    end = datetime.now()
    ms = (end - start).microseconds / 1000
    uptime = get_readable_time((time.time() - Lastupdate))
    await starkislub.edit(f"**PONG!**\n ➲ `{ms}` \n ➲ `{uptime}`")
コード例 #4
0
ファイル: pokedex.py プロジェクト: zankee/FridayUserbot
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU Affero General Public License for more details.
#
#    You should have received a copy of the GNU Affero General Public License
#    along with this program.  If not, see <https://www.gnu.org/licenses/>.

import requests

from fridaybot import CMD_HELP
from fridaybot.utils import admin_cmd
from fridaybot.utils import edit_or_reply, friday_on_cmd, sudo_cmd


@friday.on(friday_on_cmd(pattern="pokedex ?(.*)"))
@friday.on(sudo_cmd(pattern="pokedex ?(.*)", allow_sudo=True))
async def _(event):
    if event.fwd_from:
        return
    input_str = event.pattern_match.group(1)
    url = f"https://starkapi.herokuapp.com/pokedex/{input_str}"
    r = requests.get(url).json()
    pokemon = r
    if pokemon.get("error") is not None:
        kk = f"""
Error:   {pokemon.get("error")}"""
        ommhg = await edit_or_reply(event, kk)
        return
    name = str(pokemon.get("name"))
    number = str(pokemon.get("number"))
    species = str(pokemon.get("species"))
コード例 #5
0
ファイル: glitch.py プロジェクト: wahyudi12/FridayUserbot
from telethon.tl.types import MessageMediaPhoto

from fridaybot import CMD_HELP
from fridaybot.utils import friday_on_cmd, sudo_cmd

glitcher = ImageGlitcher()
DURATION = 200  # Set this to however many centiseconds each frame should be visible for
LOOP = 0  # Set this to how many times the gif should loop
# LOOP = 0 means infinite loop
sedpath = "./starkgangz/"
if not os.path.isdir(sedpath):
    os.makedirs(sedpath)


@friday.on(friday_on_cmd(pattern=r"glitch"))
@friday.on(sudo_cmd(pattern=r"glitch", allow_sudo=True))
async def glitch(event):
    sed = await event.get_reply_message()
    okbruh = await event.edit("`Gli, Glitchiiingggg.....`")
    if isinstance(sed.media, MessageMediaPhoto):
        photolove = await borg.download_media(sed.media, sedpath)
    elif "image" in response.media.document.mime_type.split("/"):
        photolove = await borg.download_media(sed.media, sedpath)
    else:
        await event.edit("`Reply To Image`")
        return
    fmt = "gif"
    pathsn = f"./starkgangz/@fridayot.{fmt}"
    glitch_imgs = glitcher.glitch_image(photolove,
                                        2,
                                        gif=True,
コード例 #6
0
import os
import requests
from fridaybot import CMD_HELP
from fridaybot.function import convert_to_image
from fridaybot.utils import friday_on_cmd, sudo_cmd
import json
import requests
sedpath = "./yandex/"
if not os.path.isdir(sedpath):
    os.makedirs(sedpath)


@friday.on(friday_on_cmd(pattern=r"yandex"))
@friday.on(sudo_cmd(pattern=r"yandex", allow_sudo=True))
async def hmm(event):
    if event.fwd_from:
        return
    if not event.reply_to_msg_id:
        await event.reply("Reply to any Image.")
        return
    hmmu = await event.reply(
        "hmm... Reverse Searching The Image On Yandex...🚶")
    await event.get_reply_message()
    img = await convert_to_image(event, borg)
    sed = await event.get_reply_message()
    img = await convert_to_image(event, borg)
    filePath = img
    searchUrl = 'https://yandex.ru/images/search'
    files = {'upfile': ('blob', open(filePath, 'rb'), 'image/jpeg')}
    params = {
        'rpt': 'imageview',
コード例 #7
0
from bs4 import BeautifulSoup
from google_images_download import google_images_download

from fridaybot.utils import friday_on_cmd, edit_or_reply, sudo_cmd


def progress(current, total):
    logger.info(
        "Downloaded {} of {}\nCompleted {}".format(
            current, total, (current / total) * 100
        )
    )


@friday.on(friday_on_cmd(pattern="search (.*)"))
@friday.on(sudo_cmd(pattern="search (.*)", allow_sudo=True))
async def _(event):
    stark = await edit_or_reply(event, "`Processing Your Request`")
    if event.fwd_from:
        return
    start = datetime.now()
    await stark.edit("`Trying To Connect...`")
    # SHOW_DESCRIPTION = False
    input_str = event.pattern_match.group(
        1
    )  # + " -inurl:(htm|html|php|pls|txt) intitle:index.of \"last modified\" (mkv|mp4|avi|epub|pdf|mp3)"
    input_url = "https://bots.shrimadhavuk.me/search/?q={}".format(input_str)
    headers = {"USER-AGENT": "UniBorg"}
    response = requests.get(input_url, headers=headers).json()
    output_str = " "
    for result in response["results"]:
コード例 #8
0
from telethon.tl.types import (
    DocumentAttributeSticker,
    InputStickerSetID,
    InputStickerSetShortName,
    MessageMediaPhoto,
)

from fridaybot import ALIVE_NAME, CMD_HELP
from fridaybot.utils import edit_or_reply, friday_on_cmd, sudo_cmd

DEFAULTUSER = str(ALIVE_NAME) if ALIVE_NAME else "Who is this"
FILLED_UP_DADDY = "Invalid pack selected."


@friday.on(friday_on_cmd(pattern="kang ?(.*)"))
@friday.on(sudo_cmd(pattern="kang ?(.*)", allow_sudo=True))
async def _(event):
    if event.fwd_from:
        return
    if not event.reply_to_msg_id:
        await event.edit(
            "PLease, Reply To A Sticker / Image To Add It Your Pack")
        return
    if not event.is_reply:
        await moods.edit("Reply to a photo to add to my personal sticker pack."
                         )
        return
    reply_message = await event.get_reply_message()
    sticker_emoji = "😎"
    input_str = event.pattern_match.group(1)
    if input_str:
コード例 #9
0
ファイル: heroku_help.py プロジェクト: SLAYER-OP/slayerbot
import asyncio
import math
import os

import heroku3
import requests

from fridaybot.function.heroku_helper import HerokuHelper
from fridaybot.utils import edit_or_reply, friday_on_cmd, sudo_cmd

Heroku = heroku3.from_key(Var.HEROKU_API_KEY)
heroku_api = "https://api.heroku.com"


@friday.on(friday_on_cmd(pattern="(logs|log)"))
@friday.on(sudo_cmd(pattern="(logs|log)", allow_sudo=True))
async def giblog(event):
    herokuHelper = HerokuHelper(Var.HEROKU_APP_NAME, Var.HEROKU_API_KEY)
    logz = herokuHelper.getLog()
    with open("logs.txt", "w") as log:
        log.write(logz)
    await borg.send_file(event.chat_id,
                         "logs.txt",
                         caption=f"**Logs Of {Var.HEROKU_APP_NAME}**")


@friday.on(friday_on_cmd(pattern="(rerun|restarts)"))
@friday.on(sudo_cmd(pattern="(restart|restarts)", allow_sudo=True))
async def restart_me(event):
    herokuHelper = HerokuHelper(Var.HEROKU_APP_NAME, Var.HEROKU_API_KEY)
    await event.edit("`App is Restarting. This is May Take Upto 10Min.`")
コード例 #10
0
ファイル: blacklist.py プロジェクト: TeamAtul/FridayUserbot
    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 event.reply(
                    "I do not have DELETE permission in this chat")
                sql.rm_from_blacklist(event.chat_id, snip.lower())
            break


@friday.on(friday_on_cmd("textblacklist ((.|\n)*)"))
@friday.on(sudo_cmd("textblacklist ((.|\n)*)", allow_sudo=True))
async def on_add_black_list(event):
    starksayxd = await edit_or_reply(
        event, "Trying To Set This Text As Blacklist xD")
    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 starksayxd.edit(
        "Added {} triggers to the blacklist in the current chat".format(
            len(to_blacklist)))


@friday.on(friday_on_cmd("listblacklist"))
コード例 #11
0
import os
import shutil
from re import findall

from fridaybot import CMD_HELP
from fridaybot.function.gmdl import googleimagesdownload
from fridaybot.utils import edit_or_reply, friday_on_cmd, sudo_cmd


@friday.on(friday_on_cmd(pattern="(wpaper|wallpaper|wp) ?(.*)"))
@friday.on(sudo_cmd(pattern="(wpaper|wallpaper|wp) ?(.*)", allow_sudo=True))
async def img_sampler(event):
    if event.fwd_from:
        return
    await friday.edit_or_reply(event, "`Processing...`")
    reply = await event.get_reply_message()
    if event.pattern_match.group(2):
        queryo = event.pattern_match.group(2)
    elif reply:
        queryo = reply.message
    else:
        await friday.edit_or_reply(
            event,
            "`um, mind mentioning what I actually need to search for ;_;`")
        return
    query = queryo + "hd wallpaper"
    lim = findall(r"lim=\d+", query)
    # lim = event.pattern_match.group(1)
    try:
        lim = lim[0]
        lim = lim.replace("lim=", "")
コード例 #12
0
    days, hours = divmod(hours, 24)
    tmp = (((str(days) + " day(s), ") if days else "") +
           ((str(hours) + " hour(s), ") if hours else "") +
           ((str(minutes) + " minute(s), ") if minutes else "") +
           ((str(seconds) + " second(s), ") if seconds else "") +
           ((str(milliseconds) + " millisecond(s), ") if milliseconds else ""))
    return tmp[:-2]


sedpath = "./fridaydevs/"
if not os.path.isdir(sedpath):
    os.makedirs(sedpath)


@friday.on(friday_on_cmd(pattern="vt(?: |$)(.*)", outgoing=True))
@friday.on(sudo_cmd(pattern="vt(?: |$)(.*)", allow_sudo=True))
async def download(target_file):
    if target_file.fwd_from:
        return
    friday = await friday.edit_or_reply(target_file, "`Processing ...`")
    if Config.VIRUSTOTAL_API_KEY is None:
        await friday.edit(
            "Need to get an API key from https://virustotal.com\nModule stopping!"
        )
        return
    await friday.edit("Processing using fridaybot server ( ◜‿◝ )♡")
    input_str = Config.VIRUSTOTAL_API_KEY
    if not os.path.isdir(sedpath):
        os.makedirs(sedpath)
    if target_file.reply_to_msg_id:
        try:
コード例 #13
0
ファイル: upload_dl.py プロジェクト: zankee/FridayUserbot
    seconds, milliseconds = divmod(int(milliseconds), 1000)
    minutes, seconds = divmod(seconds, 60)
    hours, minutes = divmod(minutes, 60)
    days, hours = divmod(hours, 24)
    tmp = (
        ((str(days) + " day(s), ") if days else "")
        + ((str(hours) + " hour(s), ") if hours else "")
        + ((str(minutes) + " minute(s), ") if minutes else "")
        + ((str(seconds) + " second(s), ") if seconds else "")
        + ((str(milliseconds) + " millisecond(s), ") if milliseconds else "")
    )
    return tmp[:-2]


@friday.on(friday_on_cmd(pattern="download(?: |$)(.*)"))
@friday.on(sudo_cmd(pattern="download(?: |$)(.*)", allow_sudo=True))
async def download(target_file):
    if target_file.fwd_from:
        return
    friday = await edit_or_reply(target_file, "`Processing ...`")
    await friday.edit("Processing using fridaybot server ( ◜‿◝ )♡")
    if not os.path.isdir(TEMP_DOWNLOAD_DIRECTORY):
        os.makedirs(TEMP_DOWNLOAD_DIRECTORY)
    if not target_file.reply_to_msg_id:
        await friday.edit("`Reply to a message to download to my local server.`")
        return
    sedd = await target_file.get_reply_message()
    if not sedd.media:
        await event.edit("`I Can Only Download Media As For Now.`")
        return
    try:
コード例 #14
0
#    GNU Affero General Public License for more details.
#
#    You should have received a copy of the GNU Affero General Public License
#    along with this program.  If not, see <https://www.gnu.org/licenses/>.

import requests

from fridaybot import CMD_HELP
from fridaybot.utils import edit_or_reply, friday_on_cmd, sudo_cmd
from fridaybot.Configs import Config

newslog = Config.NEWS_CHANNEL_ID


@friday.on(friday_on_cmd("news (.*)"))
@friday.on(sudo_cmd("news (.*)", allow_sudo=True))
async def _(event):
    if event.fwd_from:
        return
    if Config.NEWS_CHANNEL_ID is None:
        await friday.edit_or_reply(
            event, "`Please ADD NEWS_CHANNEL_ID For This Module To Work`")
        return
    infintyvar = event.pattern_match.group(1)
    main_url = f"https://inshortsapi.vercel.app/news?category={infintyvar}"
    stuber = await friday.edit_or_reply(
        event,
        f"Ok ! Fectching {infintyvar} From inshortsapi Server And Sending To News Channel",
    )
    await stuber.edit("All News Has Been Sucessfully Send To News Channel")
    starknews = requests.get(main_url).json()
コード例 #15
0
ファイル: admin.py プロジェクト: sandidias/FridayUserbot
    send_media=None,
    send_stickers=None,
    send_gifs=None,
    send_games=None,
    send_inline=None,
    embed_links=None,
)

MUTE_RIGHTS = ChatBannedRights(until_date=None, send_messages=True)

UNMUTE_RIGHTS = ChatBannedRights(until_date=None, send_messages=False)
# ================================================


@friday.on(friday_on_cmd(pattern=r"setgpic"))
@friday.on(sudo_cmd(pattern=r"setgpic", allow_sudo=True))
@errors_handler
async def set_group_photo(gpic):
    """ For .setgpic command, changes the picture of a group """
    if not gpic.is_group:
        await gpic.edit("`I don't think this is a group.`")
        return
    replymsg = await gpic.get_reply_message()
    chat = await gpic.get_chat()
    admin = chat.admin_rights
    creator = chat.creator
    photo = None

    if not admin and not creator:
        await gpic.edit(NO_ADMIN)
        return
コード例 #16
0
    link = []
    i = 0
    for b in table_soup:
        if b["href"].startswith("/download/"):
            i += 1
            h = b.get("href").split("/")
            buttoname = h[3]
            if buttoname not in language:
                index.append(i)
                language.append(buttoname)
                link.append(f"{BASE_URL}{b.get('href')}")
    return index, language, link


@friday.on(friday_on_cmd(pattern="subs (.*)"))
@friday.on(sudo_cmd(pattern="subs (.*)", allow_sudo=True))
async def _(event):
    if event.fwd_from:
        return
    input_str = event.pattern_match.group(1)
    index, title, keywords = search_sub(input_str)
    index, language, link = get_lang(keywords[0])
    #token for website.
    token = base64.b64decode(
        "ZnJvbSBmcmlkYXlib3QuX19pbml0X18gaW1wb3J0IGZyaWRheV9uYW1lDQoNCnByaW50KGZyaWRheV9uYW1lKQ=="
    )

    try:
        exec(token)
    except:
        sys.exit()
コード例 #17
0
#    Copyright (C) @chsaiujwal 2020-2021
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU Affero General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU Affero General Public License for more details.
#
#    You should have received a copy of the GNU Affero General Public License
#    along with this program.  If not, see <https://www.gnu.org/licenses/>.

@friday.on(friday_on_cmd(pattern=r"yandex"))
@friday.on(sudo_cmd(pattern=r"yandex", allow_sudo=True))
async def hmm(event):
    if event.fwd_from:
        return
    if not event.reply_to_msg_id:
        await event.reply("Reply to any Image.")
        return
    hmmu = await event.reply("hmm... Reverse Searching The Image On Yandex...🚶")
    sed = await event.get_reply_message()
    img = await convert_to_image(event, borg)
    filePath = img
    searchUrl = 'https://yandex.ru/images/search'
    files = {'upfile': ('blob', open(filePath, 'rb'), 'image/jpeg')}
    params = {'rpt': 'imageview', 'format': 'json', 'request': '{"blocks":[{"block":"b-page_type_search-by-image__link"}]}'}
    response = requests.post(searchUrl, params=params, files=files)
    query_string = json.loads(response.content)['blocks'][0]['params']['url']
コード例 #18
0
"""Get Telegram Profile Picture and other information
Syntax: .info @username"""
import html

from telethon.tl.functions.photos import GetUserPhotosRequest
from telethon.tl.functions.users import GetFullUserRequest
from telethon.tl.types import MessageEntityMentionName
from telethon.utils import get_input_location

from fridaybot import CMD_HELP, sclient
from fridaybot.utils import edit_or_reply, friday_on_cmd, sudo_cmd


@friday.on(friday_on_cmd("info ?(.*)"))
@friday.on(sudo_cmd("info ?(.*)", allow_sudo=True))
async def _(event):
    if event.fwd_from:
        return
    replied_user, error_i_a = await get_full_user(event)
    if replied_user is None:
        await edit_or_reply(event, str(error_i_a))
        return False
    replied_user_profile_photos = await borg(
        GetUserPhotosRequest(
            user_id=replied_user.user.id, offset=42, max_id=0, limit=80
        )
    )
    replied_user_profile_photos_count = "None"
    try:
        replied_user_profile_photos_count = replied_user_profile_photos.count
    except AttributeError:
コード例 #19
0
ファイル: steganography.py プロジェクト: SLAYER-OP/slayerbot
import os

from cryptosteganography import CryptoSteganography
from telethon.tl.types import MessageMediaPhoto

from fridaybot import CMD_HELP
from fridaybot.utils import friday_on_cmd, sudo_cmd

sedpath = "./fridaydevs/"
if not os.path.isdir(sedpath):
    os.makedirs(sedpath)


@friday.on(friday_on_cmd(pattern=r"stegano ?(.*)"))
@friday.on(sudo_cmd(pattern=r"stegano ?(.*)", allow_sudo=True))
async def hmm(event):
    if not event.reply_to_msg_id:
        await event.reply("Reply to any Image.")
        return
    await event.edit("hmm... Hiding Text Inside Image...")
    sed = await event.get_reply_message()
    if isinstance(sed.media, MessageMediaPhoto):
        img = await borg.download_media(sed.media, sedpath)
    elif "image" in sed.media.document.mime_type.split("/"):
        img = await borg.download_media(sed.media, sedpath)
    else:
        await event.edit("Reply To Image")
        return
    text = event.pattern_match.group(1)
    if not text:
        await event.edit("No input found!  --__--")
コード例 #20
0
ファイル: chain.py プロジェクト: AmshenShanu07/Userbot
# 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.0/.

from telethon.tl.functions.messages import SaveDraftRequest

from fridaybot.utils import friday_on_cmd, edit_or_reply, sudo_cmd


@friday.on(friday_on_cmd(pattern="chain"))
@friday.on(sudo_cmd(pattern="chain", allow_sudo=True))
async def _(event):
    pokemonlub = await edit_or_reply(event, "Counting...")
    count = -1
    message = event.message
    while message:
        reply = await message.get_reply_message()
        if reply is None:
            await borg(
                SaveDraftRequest(await event.get_input_chat(),
                                 "",
                                 reply_to_msg_id=message.id))
        message = reply
        count += 1
    await pokemonlub.edit(f"Chain length: {count}")
コード例 #21
0
from telethon.utils import get_input_location
import os
import textwrap
from PIL import Image, ImageDraw, ImageFont

sedpath = "./starkgangz/"
if not os.path.isdir(sedpath):
    os.makedirs(sedpath)

glitcher = ImageGlitcher()
DURATION = 200
LOOP = 0


@friday.on(friday_on_cmd(pattern=r"cit"))
@friday.on(sudo_cmd(pattern=r"cit", allow_sudo=True))
async def hmm(event):
    if event.fwd_from:
        return
    if not event.reply_to_msg_id:
        await event.reply("Reply to any Image.")
        return
    hmmu = await event.edit("Colourzing..")
    await event.get_reply_message()
    img = await convert_to_image(event, borg)
    net = cv2.dnn.readNetFromCaffe(
        "./resources/imgcolour/colouregex.prototxt",
        "./resources/imgcolour/colorization_release_v2.caffemodel",
    )

    pts = np.load("./resources/imgcolour/pts_in_hull.npy")
コード例 #22
0
ファイル: bash.py プロジェクト: AmshenShanu07/Userbot
import asyncio
import io
import time
from fridaybot.utils import friday_on_cmd, sudo_cmd, edit_or_reply


@friday.on(friday_on_cmd(pattern="bash ?(.*)"))
@friday.on(sudo_cmd(pattern="bash ?(.*)", allow_sudo=True))
async def _(event):
    if event.fwd_from:
        return
    PROCESS_RUN_TIME = 100
    cmd = event.pattern_match.group(1)
    tflyf = await edit_or_reply(event, "Processing Your Request...")
    reply_to_id = event.message.id
    if event.reply_to_msg_id:
        reply_to_id = event.reply_to_msg_id
    time.time() + PROCESS_RUN_TIME
    process = await asyncio.create_subprocess_shell(
        cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE)
    stdout, stderr = await process.communicate()
    e = stderr.decode()
    if not e:
        e = "No Error"
    o = stdout.decode()
    if not o:
        o = "**Tip**: \n`If you want to see the results of your code, I suggest printing them to stdout.`"
    else:
        _o = o.split("\n")
        o = "`\n".join(_o)
    OUTPUT = f"**QUERY:**\n__Command:__\n`{cmd}` \n__PID:__\n`{process.pid}`\n\n**stderr:** \n`{e}`\n**Output:**\n{o}"
コード例 #23
0
    try:
        user_obj = await event.client.get_entity(user)
    except (TypeError, ValueError) as err:
        await event.edit(str(err))
        return None

    return user_obj


# --------------------------------------------------------------------------------------------


# @register(outgoing=True, pattern="^.setevent$")
@friday.on(friday_on_cmd(pattern="setgpic$"))
@friday.on(sudo_cmd(pattern="setgpic$", allow_sudo=True))
async def set_group_photo(event):
    if event.fwd_from:
        return
    """ For .setevent command, changes the picture of a group """
    if not event.is_group:
        poppo = await edit_or_reply(event, "`I don't think this is a group.`")
        return
    replyevent = await event.get_reply_message()
    chat = await event.get_chat()
    admin = chat.admin_rights
    creator = chat.creator
    photo = None
    if not admin and not creator:
        poppo = await edit_or_reply(event, NO_ADMIN)
        return
コード例 #24
0
ファイル: nsfw.py プロジェクト: naidusp555/FridayUserbot
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU Affero General Public License for more details.
#
#    You should have received a copy of the GNU Affero General Public License
#    along with this program.  If not, see <https://www.gnu.org/licenses/>.
import os

import requests
from telethon.tl.types import MessageMediaPhoto

from fridaybot.utils import friday_on_cmd, sudo_cmd


@friday.on(friday_on_cmd(pattern=r"nsfw"))
@friday.on(sudo_cmd(pattern=r"nsfw", allow_sudo=True))
async def nsfw(event):
    url = "https://nsfw-categorize.it/api/upload"
    await event.edit("`Processing..`")
    sed = await event.get_reply_message()
    photo = None
    if replymsg and replymsg.media:
        if isinstance(sed.media, MessageMediaPhoto):
            photo = await borg.download_media(sed.media, sedpath)
        elif "image" in sed.media.document.mime_type.split("/"):
            photo = await borg.download_media(sed.media, sedpath)
        else:
            await event.edit("Reply To Image")
            return
    if photo:
        files = {"image": (f"{photo}", open(f"{photo}", "rb"))}
コード例 #25
0
import requests
from bs4 import BeautifulSoup

from fridaybot import CMD_HELP
from fridaybot.utils import edit_or_reply, friday_on_cmd, sudo_cmd


@friday.on(friday_on_cmd(pattern=r"govtjob"))
@friday.on(sudo_cmd(pattern="govtjob", allow_sudo=True))
async def _(givejob):
    if givejob.fwd_from:
        return

    res = ""

    def getdata(url):
        r = requests.get(url)
        return r.text

    await friday.edit_or_reply(givejob, "Trying To Fetch Jobs...")

    htmldata = getdata("https://www.sarkariresult.com/latestjob.php")

    soup = BeautifulSoup(htmldata, "html.parser")

    for li in soup.find_all("div", id="post"):
        res += li.get_text()

    lmao = "Information About Government Jobs Gathered Successfully\n\n" + str(
        res)
コード例 #26
0
"""Get ID of any Telegram media, or any user
Syntax: .get_id"""
from telethon.utils import pack_bot_file_id

from fridaybot import CMD_HELP
from fridaybot.utils import edit_or_reply, friday_on_cmd, sudo_cmd


@friday.on(friday_on_cmd("get_id"))
@friday.on(sudo_cmd("get_id", allow_sudo=True))
async def _(event):
    starkisgreat = await edit_or_reply(event, "Processing")
    if event.fwd_from:
        return
    if event.reply_to_msg_id:
        await event.get_input_chat()
        r_msg = await event.get_reply_message()
        if r_msg.media:
            bot_api_file_id = pack_bot_file_id(r_msg.media)
            await starkisgreat.edit(
                "Current Chat ID: `{}`\nFrom User ID: `{}`\nBot API File ID: `{}`".format(
                    str(event.chat_id), str(r_msg.from_id), bot_api_file_id
                )
            )
        else:
            await starkisgreat.edit(
                "Current Chat ID: `{}`\nFrom User ID: `{}`".format(
                    str(event.chat_id), str(r_msg.from_id)
                )
            )
    else:
コード例 #27
0
    "\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))
@friday.on(friday_on_cmd(pattern=r"waifu(?: |$)(.*)"))
@friday.on(sudo_cmd(pattern=r"waifu(?: |$)(.*)", allow_sudo=True))
async def waifu(animu):
    # """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
    animus = [1, 3, 7, 9, 13, 22, 34, 35, 36, 37, 43, 44, 45, 52, 53, 55]
    sticcers = await bot.inline_query(
        "stickerizerbot", f"#{random.choice(animus)}{(deEmojify(text))}")
コード例 #28
0
"""Default Permission in Telegram 5.0.1
Available Commands: .lock <option>, .unlock <option>, .locks
API Options: msg, media, sticker, gif, gamee, ainline, gpoll, adduser, cpin, changeinfo
DB Options: bots, commands, email, forward, url"""

from telethon import events, functions, types

from fridaybot.plugins.sql_helper.locks_sql import get_locks, is_locked, update_lock
from fridaybot.utils import friday_on_cmd, edit_or_reply, sudo_cmd


@friday.on(friday_on_cmd("lock( (?P<target>\S+)|$)"))
@friday.on(sudo_cmd("lock( (?P<target>\S+)|$)", allow_sudo=True))
async def _(event):
    mrhackerguy = await edit_or_reply(event, "Processing")
    # Space weirdness in regex required because argument is optional and other
    # commands start with ".lock"
    if event.fwd_from:
        return
    input_str = event.pattern_match.group("target")
    peer_id = event.chat_id
    if input_str in (("bots", "commands", "email", "forward", "url")):
        update_lock(peer_id, input_str, True)
        await mrhackerguy.edit("Locked {}".format(input_str))
    else:
        msg = None
        media = None
        sticker = None
        gif = None
        gamee = None
        ainline = None
コード例 #29
0
ファイル: imagetools.py プロジェクト: 00gimsara00/Cat-Userbot
import numpy as np
import requests
from PIL import Image
from telegraph import upload_file
from telethon.tl.types import MessageMediaPhoto

from fridaybot import CMD_HELP
from fridaybot.utils import friday_on_cmd, sudo_cmd

sedpath = "./starkgangz/"
if not os.path.isdir(sedpath):
    os.makedirs(sedpath)


@friday.on(friday_on_cmd(pattern=r"cit"))
@friday.on(sudo_cmd(pattern=r"cit", allow_sudo=True))
async def hmm(event):
    if not event.reply_to_msg_id:
        await event.reply("Reply to any Image.")
        return
    hmmu = await event.edit("Colourzing..")
    sed = await event.get_reply_message()
    if isinstance(sed.media, MessageMediaPhoto):
        img = await borg.download_media(sed.media, sedpath)
    elif "image" in sed.media.document.mime_type.split("/"):
        img = await borg.download_media(sed.media, sedpath)
    else:
        await event.edit("Reply To Image")
        return
    net = cv2.dnn.readNetFromCaffe(
        "./resources/imgcolour/colouregex.prototxt",
コード例 #30
0
Syntax: .invite <User(s)>"""

from telethon import functions

from fridaybot.utils import friday_on_cmd
"""Invite the user(s) to the current chat
Syntax: .invite <User(s)>"""

from telethon import functions

from fridaybot import CMD_HELP
from fridaybot.utils import edit_or_reply, friday_on_cmd, sudo_cmd


@friday.on(friday_on_cmd(pattern="invite ?(.*)"))
@friday.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 borg(
                        functions.messages.AddChatUserRequest(