# 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 RaVaN.config import get_str_key from RaVaN.services.events import register from RaVaN.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
# This file is part of RaVaN (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 RaVaN.config import get_str_key from RaVaN.utils.logger import log log.info("Starting sentry.io integraion...") sentry_sdk.init(get_str_key("SENTRY_API_KEY"), integrations=[RedisIntegration()])
from RaVaN.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
# 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 io import os from datetime import datetime import requests from telethon import types from telethon.tl import functions from RaVaN.config import get_str_key from RaVaN.services.events import register from RaVaN.services.telethon import tbot REM_BG_API_KEY = get_str_key("REM_BG_API_KEY", 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
saavn_func, shortify, torrent_func, translate_func, urban_func, wall_func, webss, ) from RaVaN.function.pluginhelpers import fetch, json_prettify from RaVaN.services.pyrogram import pbot as app from RaVaN.config import get_str_key from search_engine_parser import GoogleSearch import wikipedia from wikipedia.exceptions import DisambiguationError, PageError 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:
# 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 RaVaN.config import get_str_key from RaVaN.services.events import register from RaVaN.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:
# I KNOW YOU ARE GOOD YOU KEEP MY CREDITS 😘 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 RaVaN import OWNER_ID from RaVaN.config import get_str_key from RaVaN.services.events import register from RaVaN.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/atleastskem/skem" 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 += ( f"•[{c.committed_datetime.strftime(d_form)}]: {c.summary} by <{c.author}>\n"
import io import os import lyricsgenius from pyrogram import filters from tswift import Song from RaVaN.config import get_str_key from RaVaN.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:
# This file is part of RaVaN (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/>. from telethon import TelegramClient from RaVaN.config import get_int_key, get_str_key TOKEN = get_str_key("TOKEN", required=True) NAME = TOKEN.split(":")[0] tbot = TelegramClient(NAME, get_int_key("APP_ID", required=True), get_str_key("APP_HASH", required=True)) # Telethon tbot.start(bot_token=TOKEN)
# Support Dual Mongo DB now # For free users from motor.motor_asyncio import AsyncIOMotorClient as MongoClient from RaVaN.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.daisy
# 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 RaVaN.config import get_str_key from RaVaN.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()
from pymongo import MongoClient from telethon import * from telethon.tl import * from RaVaN import BOT_ID from RaVaN.config import get_str_key from RaVaN.services.events import register from RaVaN.services.telethon import tbot MONGO_DB_URI = get_str_key("MONGO_URI", required=True) client = MongoClient() client = MongoClient(MONGO_DB_URI) db = client["RaVaN"] approved_users = db.approve dbb = client["RaVaN"] 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(
from google_trans_new import google_translator from gtts import gTTS, gTTSError #from RaVaN.services.sql.talk_mode_sql import add_talkmode, rmtalkmode, get_all_chat_id, is_talkmode_indb translator = google_translator() from RaVaN.function.telethonbasics import is_admin from RaVaN import OWNER_ID, BOT_ID from RaVaN.services.pyrogram import pbot from pyrogram import filters import asyncio, os def extract_emojis(s): return "".join(c for c in s if c in emoji.UNICODE_EMOJI) LYDIA_API_KEY = get_str_key("LYDIA_API_KEY", required=False) CoffeeHouseAPI = API(LYDIA_API_KEY) api_client = LydiaAI(CoffeeHouseAPI) en_chats = [] ws_chats = [] async def can_change_info(message): try: result = await tbot( functions.channels.GetParticipantRequest( channel=message.chat_id, user_id=message.sender_id, )) p = result.participant return isinstance(p, types.ChannelParticipantCreator) or (isinstance(
# This file is part of RaVaNBot (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/>. from telethon import TelegramClient from telethon.sessions import StringSession from RaVaN.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)
import io import time import aiohttp from telethon.tl import functions, types from telethon.tl.types import * from RaVaN.config import get_str_key OPENWEATHERMAP_ID = get_str_key("OPENWEATHERMAP_ID", "") from RaVaN.services.events import register from RaVaN.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), ) if isinstance(chat, types.InputPeerUser):
from RaVaN.utils.logger import log from RaVaN.versions import DAISY_VERSION log.info("----------------------") log.info("| 𝐑𝐀𝐕𝐀𝐍 |") log.info("----------------------") log.info("Version: " + DAISY_VERSION) if get_bool_key("DEBUG_MODE") is True: DAISY_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:
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(
import pymongo from RaVaN.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["RaVaN"] 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):
# Ported 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 RaVaN.config import get_str_key from RaVaN.services.events import register from RaVaN.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):
# 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 RaVaN import log from RaVaN.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..."))