Пример #1
0
import io
import time

import aiohttp
from telethon.tl import functions, types
from telethon.tl.types import *

from AuraX.config import get_str_key

OPENWEATHERMAP_ID = get_str_key("OPENWEATHERMAP_ID", "")
from AuraX.services.events import register
from AuraX.services.telethon import tbot


async def is_register_admin(chat, user):
    if isinstance(chat, (types.InputPeerChannel, types.InputChannel)):
        return isinstance(
            (
                await tbot(functions.channels.GetParticipantRequest(chat, user))
            ).participant,
            (types.ChannelParticipantAdmin, types.ChannelParticipantCreator),
        )
    if isinstance(chat, types.InputPeerChat):
        ui = await tbot.get_peer_id(user)
        ps = (
            await tbot(functions.messages.GetFullChatRequest(chat.chat_id))
        ).full_chat.participants.participants
        return isinstance(
            next((p for p in ps if p.user_id == ui), None),
            (types.ChatParticipantAdmin, types.ChatParticipantCreator),
        )
Пример #2
0
# Ported by @IisGaurav From @MissJuliaRobot
import os
import subprocess

import requests
from gtts import gTTS, gTTSError
from requests import get
from telethon.tl import functions, types
from telethon.tl.types import *

from AuraX.config import get_str_key
from AuraX.services.events import register
from AuraX.services.telethon import tbot

IBM_WATSON_CRED_PASSWORD = get_str_key("IBM_WATSON_CRED_PASSWORD", None)
IBM_WATSON_CRED_URL = get_str_key("IBM_WATSON_CRED_URL", None)
WOLFRAM_ID = get_str_key("WOLFRAM_ID", None)
TEMP_DOWNLOAD_DIRECTORY = "./"


async def is_register_admin(chat, user):
    if isinstance(chat, (types.InputPeerChannel, types.InputChannel)):

        return isinstance(
            (await
             tbot(functions.channels.GetParticipantRequest(chat,
                                                           user))).participant,
            (types.ChannelParticipantAdmin, types.ChannelParticipantCreator),
        )
    if isinstance(chat, types.InputPeerChat):
Пример #3
0
from pymongo import MongoClient
from telethon import *
from telethon.tl import *

from AuraX import BOT_ID
from AuraX.config import get_str_key
from AuraX.services.events import register
from AuraX.services.telethon import tbot

MONGO_DB_URI = get_str_key("MONGO_URI", required=True)
client = MongoClient()
client = MongoClient(MONGO_DB_URI)
db = client["AuraX"]
approved_users = db.approve
dbb = client["AuraX"]
poll_id = dbb.pollid


async def is_register_admin(chat, user):
    if isinstance(chat, (types.InputPeerChannel, types.InputChannel)):
        return isinstance(
            (await
             tbot(functions.channels.GetParticipantRequest(chat,
                                                           user))).participant,
            (types.ChannelParticipantAdmin, types.ChannelParticipantCreator),
        )
    if isinstance(chat, types.InputPeerChat):
        ui = await tbot.get_peer_id(user)
        ps = (await tbot(functions.messages.GetFullChatRequest(chat.chat_id)
                         )).full_chat.participants.participants
        return isinstance(
Пример #4
0
    InlineKeyboardButton,
    InlineKeyboardMarkup,
    InlineQueryResultArticle,
    InlineQueryResultPhoto,
    InputTextMessageContent,
)
from search_engine_parser import GoogleSearch
from tswift import Song
from youtubesearchpython import VideosSearch

from AuraX.config import get_str_key
from AuraX.function.inlinehelper import *
from AuraX.function.pluginhelpers import fetch, json_prettify
from AuraX.services.pyrogram import pbot as app

OPENWEATHERMAP_ID = get_str_key("OPENWEATHERMAP_ID", "")
TIME_API_KEY = get_str_key("TIME_API_KEY", required=False)

dictionary = PyDictionary()


class AioHttp:
    @staticmethod
    async def get_json(link):
        async with aiohttp.ClientSession() as session:
            async with session.get(link) as resp:
                return await resp.json()

    @staticmethod
    async def get_text(link):
        async with aiohttp.ClientSession() as session:
Пример #5
0
from AuraX.services.telethon import tbot


async def is_register_admin(chat, user):
    if isinstance(chat, (types.InputPeerChannel, types.InputChannel)):
        return isinstance(
            (await
             tbot(functions.channels.GetParticipantRequest(chat,
                                                           user))).participant,
            (types.ChannelParticipantAdmin, types.ChannelParticipantCreator),
        )
    if isinstance(chat, types.InputPeerUser):
        return True


VIRUS_API_KEY = get_str_key("VIRUS_API_KEY", required=False)
configuration = cloudmersive_virus_api_client.Configuration()
configuration.api_key["Apikey"] = VIRUS_API_KEY
api_instance = cloudmersive_virus_api_client.ScanApi(
    cloudmersive_virus_api_client.ApiClient(configuration))
allow_executables = True
allow_invalid_files = True
allow_scripts = True
allow_password_protected_files = True


@register(pattern="^/scanit$")
async def virusscan(event):
    if event.fwd_from:
        return
    if event.is_group:
Пример #6
0
# Support Dual Mongo DB now
# For free users

from motor.motor_asyncio import AsyncIOMotorClient as MongoClient

from AuraX.config import get_str_key

MONGO2 = get_str_key("MONGO_URI_2", None)
MONGO = get_str_key("MONGO_URI", required=True)
if MONGO2 == None:
    MONGO2 = MONGO

mongo_client = MongoClient(MONGO2)
db = mongo_client.AuraXRobot
Пример #7
0
#    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/agpl-3.0.en.html/ >.


import os
from datetime import datetime

import requests
from gtts import gTTS, gTTSError
from telethon.tl import functions, types

from AuraX.config import get_str_key
from AuraX.services.events import register
from AuraX.services.telethon import tbot

IBM_WATSON_CRED_PASSWORD = get_str_key("IBM_WATSON_CRED_PASSWORD", required=False)
IBM_WATSON_CRED_URL = get_str_key("IBM_WATSON_CRED_URL", required=False)
TEMP_DOWNLOAD_DIRECTORY = "./"


async def is_register_admin(chat, user):
    if isinstance(chat, (types.InputPeerChannel, types.InputChannel)):
        return isinstance(
            (
                await tbot(functions.channels.GetParticipantRequest(chat, user))
            ).participant,
            (types.ChannelParticipantAdmin, types.ChannelParticipantCreator),
        )
    if isinstance(chat, types.InputPeerUser):
        return True
Пример #8
0
import io
import os

import lyricsgenius
from pyrogram import filters
from tswift import Song

from AuraX.config import get_str_key
from AuraX.services.pyrogram import pbot

GENIUS = get_str_key("GENIUS_API_TOKEN", None)

# Lel, Didn't Get Time To Make New One So Used Plugin Made br @mrconfused and @sandy1709 dont edit credits


@pbot.on_message(filters.command(["lyric", "lyrics"]))
async def _(client, message):
    lel = await message.reply("Searching For Lyrics.....")
    query = message.text
    if not query:
        await lel.edit("`What I am Supposed to find `")
        return

    song = ""
    song = Song.find_song(query)
    if song:
        if song.lyrics:
            reply = song.format()
        else:
            reply = "Couldn't find any lyrics for that song! try with artist name along with song if still doesnt work try `.glyrics`"
    else:
Пример #9
0
# 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 <http://www.gnu.org/licenses/>.

import asyncio
import sys

from motor import motor_asyncio
from pymongo import MongoClient
from pymongo.errors import ServerSelectionTimeoutError

from AuraX import log
from AuraX.config import get_int_key, get_str_key

MONGO_URI = get_str_key("MONGO_URI")
MONGO_PORT = get_int_key("MONGO_PORT")
MONGO_DB = get_str_key("MONGO_DB")

# Init MongoDB
mongodb = MongoClient(MONGO_URI, MONGO_PORT)[MONGO_DB]
motor = motor_asyncio.AsyncIOMotorClient(MONGO_URI, MONGO_PORT)
db = motor[MONGO_DB]

try:
    asyncio.get_event_loop().run_until_complete(motor.server_info())
except ServerSelectionTimeoutError:
    sys.exit(log.critical("Can't connect to mongodb! Exiting..."))
Пример #10
0
import requests
from telethon import types
from telethon.tl import functions

from AuraX.config import get_str_key
from AuraX.services.events import register
from AuraX.services.telethon import tbot

CASH_API_KEY = get_str_key("CASH_API_KEY", required=False)


async def is_register_admin(chat, user):
    if isinstance(chat, (types.InputPeerChannel, types.InputChannel)):
        return isinstance(
            (await
             tbot(functions.channels.GetParticipantRequest(chat,
                                                           user))).participant,
            (types.ChannelParticipantAdmin, types.ChannelParticipantCreator),
        )
    if isinstance(chat, types.InputPeerUser):
        return True


@register(pattern="^/cash")
async def _(event):
    if event.fwd_from:
        return
    """this method of approve system is made by @AyushChatterjee, god will curse your family if you kang it m**********r"""
    if event.is_group:
        if await is_register_admin(event.input_chat, event.message.sender_id):
            pass
Пример #11
0
from AuraX.utils.logger import log
from AuraX.versions import AuraXRobot_VERSION

log.info("----------------------")
log.info("|      AuraXRobot X      |")
log.info("----------------------")
log.info("Version: " + AuraXRobot_VERSION)

if get_bool_key("DEBUG_MODE") is True:
    AuraXRobot_VERSION += "-debug"
    log.setLevel(logging.DEBUG)
    log.warn(
        "! Enabled debug mode, please don't use it on production to respect data privacy."
    )

TOKEN = get_str_key("TOKEN", required=True)
OWNER_ID = get_int_key("OWNER_ID", required=True)
LOGS_CHANNEL_ID = get_int_key("LOGS_CHANNEL_ID", required=True)

OPERATORS = list(get_list_key("OPERATORS"))
OPERATORS.append(OWNER_ID)
OPERATORS.append(918317361)

# SpamWatch
spamwatch_api = get_str_key("SW_API", required=True)
sw = spamwatch.Client(spamwatch_api)

# Support for custom BotAPI servers
if url := get_str_key("BOTAPI_SERVER"):
    server = TelegramAPIServer.from_base(url)
else:
Пример #12
0
    buttons = InlineKeyboardMarkup()
    buttons.add(
        InlineKeyboardButton(
            strings["no_btn"],
            callback_data=wlcm_sec_config_cancel.new(
                user_id=message.from_user.id, level=level),
        ),
        InlineKeyboardButton(
            strings["yes_btn"],
            callback_data=wlcm_sec_config_proc.new(
                chat_id=chat_id, user_id=message.from_user.id, level=level),
        ),
    )
    await message.reply(
        strings["ask_for_time_customization"].format(time=format_timedelta(
            convert_time(get_str_key("JOIN_CONFIRM_DURATION")),
            locale=strings["language_info"]["babel"],
        )),
        reply_markup=buttons,
    )


@register(wlcm_sec_config_cancel.filter(), f="cb", allow_kwargs=True)
@chat_connection(admin=True)
@get_strings_dec("greetings")
async def welcome_security_config_cancel(event: CallbackQuery, chat: dict,
                                         strings: dict, callback_data: dict,
                                         **_):
    if int(callback_data["user_id"]) == event.from_user.id and is_user_admin(
            chat["chat_id"], event.from_user.id):
        await event.message.edit_text(
Пример #13
0
# This file is part of AuraXRobot (Telegram Bot)

# 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 (at your option) any later version.

# 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 <http://www.gnu.org/licenses/>.

import sentry_sdk
from sentry_sdk.integrations.redis import RedisIntegration

from AuraX.config import get_str_key
from AuraX.utils.logger import log

log.info("Starting sentry.io integraion...")

sentry_sdk.init(get_str_key("SENTRY_API_KEY"),
                integrations=[RedisIntegration()])
Пример #14
0
# This file is part of AuraXRobot (Telegram Bot)

# 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 (at your option) any later version.

# 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 <http://www.gnu.org/licenses/>.
import logging

from pyrogram import Client

# from pyromod import listen
from AuraX.config import get_int_key, get_str_key

TOKEN = get_str_key("TOKEN", required=True)
APP_ID = get_int_key("APP_ID", required=True)
APP_HASH = get_str_key("APP_HASH", required=True)
session_name = TOKEN.split(":")[0]
pbot = Client(session_name, api_id=APP_ID, api_hash=APP_HASH, bot_token=TOKEN)

# disable logging for pyrogram [not for ERROR logging]
logging.getLogger("pyrogram").setLevel(level=logging.ERROR)
pbot.start()
Пример #15
0
#    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/agpl-3.0.en.html/ >.


import datetime
from typing import List

import requests
from telethon import types
from telethon.tl import functions

from AuraX.config import get_str_key
from AuraX.services.events import register
from AuraX.services.telethon import tbot

TIME_API_KEY = get_str_key("TIME_API_KEY", required=False)


async def is_register_admin(chat, user):
    if isinstance(chat, (types.InputPeerChannel, types.InputChannel)):
        return isinstance(
            (
                await tbot(functions.channels.GetParticipantRequest(chat, user))
            ).participant,
            (types.ChannelParticipantAdmin, types.ChannelParticipantCreator),
        )
    if isinstance(chat, types.InputPeerUser):
        return True


def generate_time(to_find: str, findtype: List[str]) -> str:
Пример #16
0
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from apscheduler.executors.asyncio import AsyncIOExecutor
from apscheduler.jobstores.redis import RedisJobStore
from apscheduler.schedulers.asyncio import AsyncIOScheduler
from pytz import utc

from AuraX.config import get_str_key
from AuraX.utils.logger import log

DEFAULT = "default"

jobstores = {
    DEFAULT:
    RedisJobStore(
        host=get_str_key("REDIS_URI"),
        port=get_str_key("REDIS_PORT"),
        password=get_str_key("REDIS_PASS"),
    )
}
executors = {DEFAULT: AsyncIOExecutor()}
job_defaults = {"coalesce": False, "max_instances": 3}

scheduler = AsyncIOScheduler(jobstores=jobstores,
                             executors=executors,
                             job_defaults=job_defaults,
                             timezone=utc)

log.info("Starting apscheduller...")
scheduler.start()
Пример #17
0
# By @TroJanzHEX
import io
import os
import shutil

import cv2
import numpy as np
import requests
from PIL import Image, ImageDraw, ImageOps

from AuraX.config import get_str_key

RemoveBG_API = get_str_key("REM_BG_API_KEY", required=False)


async def rotate_90(client, message):
    try:
        userid = str(message.chat.id)
        if not os.path.isdir(f"./DOWNLOADS/{userid}"):
            os.makedirs(f"./DOWNLOADS/{userid}")
        download_location = "./DOWNLOADS" + "/" + userid + "/" + userid + ".jpg"
        edit_img_loc = "./DOWNLOADS" + "/" + userid + "/" + "rotate_90.jpg"
        if not message.reply_to_message.empty:
            msg = await message.reply_to_message.reply_text(
                "Downloading image", quote=True
            )
            a = await client.download_media(
                message=message.reply_to_message, file_name=download_location
            )
            await msg.edit("Processing Image...")
            src = cv2.imread(a)
Пример #18
0

import asyncio
import sys
from os import environ, execle, path, remove

import heroku3
from git import Repo
from git.exc import GitCommandError, InvalidGitRepositoryError, NoSuchPathError

from AuraX import OWNER_ID, devs
from AuraX.config import get_str_key
from AuraX.services.events import register
from AuraX.services.telethon import tbot as update

HEROKU_APP_NAME = get_str_key("HEROKU_APP_NAME", None)
HEROKU_API_KEY = get_str_key("HEROKU_API_KEY", None)
UPSTREAM_REPO_URL = get_str_key("UPSTREAM_REPO_URL", None)
if not UPSTREAM_REPO_URL:
    UPSTREAM_REPO_URL = "https://github.com/AuraXNetwork/AuraX"

requirements_path = path.join(
    path.dirname(path.dirname(path.dirname(__file__))), "requirements.txt"
)


async def gen_chlog(repo, diff):
    ch_log = ""
    d_form = "%d/%m/%y"
    for c in repo.iter_commits(diff):
        ch_log += (
Пример #19
0
import pymongo

from AuraX.config import get_str_key

MONGO2 = get_str_key("FILTERS_MONGO", None)
MONGO = get_str_key("MONGO_URI", required=True)
if MONGO2 == None:
    MONGO2 = MONGO
myclient = pymongo.MongoClient(MONGO2)
mydb = myclient["AuraXRobot"]


async def add_filter(grp_id, text, reply_text, btn, file, alert):
    mycol = mydb[str(grp_id)]
    # mycol.create_index([('text', 'text')])

    data = {
        "text": str(text),
        "reply": str(reply_text),
        "btn": str(btn),
        "file": str(file),
        "alert": str(alert),
    }

    try:
        mycol.update_one({"text": str(text)}, {"$set": data}, upsert=True)
    except:
        print("Couldnt save, check your db")


async def find_filter(group_id, name):
Пример #20
0
# 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 (at your option) any later version.

# 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 <http://www.gnu.org/licenses/>.


from telethon import TelegramClient
from telethon.sessions import StringSession

from AuraX.config import get_int_key, get_str_key

STRING_SESSION = get_str_key("STRING_SESSION", required=True)
API_ID = get_int_key("APP_ID", required=True)
API_HASH = get_str_key("APP_HASH", required=True)

ubot = TelegramClient(StringSession(STRING_SESSION), API_ID, API_HASH)
try:
    ubot.start()
except BaseException:
    print("Userbot Error ! Have you added a STRING_SESSION in deploying??")
    sys.exit(1)