def __init__(self): super().__init__( TG_BOT_SESSION, api_hash=API_HASH, api_id=APP_ID, base_logger=LOGGER(__name__) ) self.LOGGER = LOGGER
def __init__(self): name = self.__class__.__name__.lower() self.logger = LOGGER(__name__) super().__init__(name, api_id=API_ID, api_hash=API_HASH, bot_token=BOT_TOKEN, plugins={"root": "bot/plugins"})
def __init__(self): session_name = TG_USER_SESSION if (session_name == ":memory:" or len(session_name) > 17): session_name = re.sub(r"[\n\s]+]", "", session_name) session_name = StringSession(session_name) super().__init__(session_name, api_hash=API_HASH, api_id=APP_ID, base_logger=LOGGER(__name__)) self.LOGGER = LOGGER
async def start(bot, update): try: file_uid = update.command[1] except IndexError: file_uid = False if file_uid: file_id, file_name, file_caption, file_type = await db.get_file(file_uid) if (file_id or file_type) == None: return caption = file_caption if file_caption != ("" or None) else ("<code>" + file_name + "</code>") try: await update.reply_cached_media( file_id, quote=True, caption = caption, parse_mode="html", reply_markup=InlineKeyboardMarkup( [ [ InlineKeyboardButton ( 'Developers', url="https://t.me/CrazyBotsz" ) ] ] ) ) except Exception as e: await update.reply_text(f"<b>Error:</b>\n<code>{e}</code>", True, parse_mode="html") LOGGER(__name__).error(e) return buttons = [[ InlineKeyboardButton('Developers', url='https://t.me/CrazyBotsz'), InlineKeyboardButton('Source Code 🧾', url ='https://github.com/CrazyBotsz/Adv-Auto-Filter-Bot-V2') ],[ InlineKeyboardButton('Support 🛠', url='https://t.me/CrazyBotszGrp') ],[ InlineKeyboardButton('Help ⚙', callback_data="help") ]] reply_markup = InlineKeyboardMarkup(buttons) await bot.send_message( chat_id=update.chat.id, text=Translation.START_TEXT.format( update.from_user.first_name), reply_markup=reply_markup, parse_mode="html", reply_to_message_id=update.message_id )
async def main(): await BOT.start() IMPORTED = {} for module_name in ALL_MODULES: imported_module = importlib.import_module("bot.plugins." + module_name) if not hasattr(imported_module, "__mod_name__"): imported_module.__mod_name__ = imported_module.__name__ if not imported_module.__mod_name__.lower() in IMPORTED: IMPORTED[imported_module.__mod_name__.lower()] = imported_module else: raise Exception( "Can't have two modules with the same name! Please change one") LOGGER(__name__).info("Successfully loaded modules: " + str(ALL_MODULES)) # await BOT.run_until_disconnected()
import random import string import asyncio from pyrogram import Client, filters from pyrogram.errors import UserAlreadyParticipant, FloodWait from bot import VERIFY, LOGGER # pylint: disable=import-error from bot.bot import Bot # pylint: disable=import-error from bot.database import Database # pylint: disable=import-error from bot.plugins.auto_filter import recacher # pylint: disable=import-error db = Database() logger = LOGGER(__name__) @Client.on_message(filters.command(["add"]) & filters.group, group=1) async def connect(bot: Bot, update): """ A Funtion To Handle Incoming /add Command TO COnnect A Chat With Group """ chat_id = update.chat.id user_id = update.from_user.id if update.from_user else None target_chat = update.text.split(None, 1) global VERIFY if VERIFY.get(str(chat_id)) == None: # Make Admin's ID List admin_list = [] async for x in bot.iter_chat_members(chat_id=chat_id, filter="administrators"): admin_id = x.user.id
async def start(bot, update): try: file_uid = update.command[1] except IndexError: file_uid = False if file_uid: file_id, file_name, file_caption, file_type = await db.get_file( file_uid) if (file_id or file_type) == None: return caption = file_caption if file_caption != ("" or None) else ( "<code>" + file_name + "</code>") try: await update.reply_cached_media( file_id, quote=True, caption=caption, parse_mode="html", reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton('🎭 ⭕️ FOR YOUR QUERY, CONTACT ME ⭕️', url="https://t.me/UFSChatBot") ]])) except Exception as e: await update.reply_text(f"<b>Error:</b>\n<code>{e}</code>", True, parse_mode="html") LOGGER(__name__).error(e) return buttons = [[ InlineKeyboardButton('Developers', url='https://t.me/joinchat/TRlZZilyh-MVa66t'), InlineKeyboardButton('Source Code 🧾', url='https://t.me/joinchat/YS-WlsUC9nFiOWM0') ], [ InlineKeyboardButton( 'Support 🛠', url='https://t.me/joinchat/YS-WlsUC9nFiOWM0') ], [InlineKeyboardButton('Help ⚙', callback_data="help")]] reply_markup = InlineKeyboardMarkup(buttons) if update.from_user.id not in OWNER_ID: await bot.send_message(chat_id=update.chat.id, text="""<b>Hey {}!!</b> ഈ ബോട്ട് <b><u><a href="https://t.me/joinchat/TRlZZilyh-MVa66t">Universal Film Studio Group</a></u></b> ലേക്ക് ഉള്ളത് എന്ന് ഇനി വീണ്ടും വീണ്ടും പറയണോ?? അപ്പോ പിന്നെ എന്തിനാ വീണ്ടും വീണ്ടും സ്റ്റാർട്ട് കുത്തി കളിക്കാൻ വരുന്നേ... ആ സൈഡിലോട്ട് എങ്ങാനും മാറി ഇരിക്ക് ഇനി🤭🤭""" .format(update.from_user.first_name), parse_mode="html", reply_to_message_id=update.message_id) return await bot.send_message(chat_id=update.chat.id, text=Translation.START_TEXT.format( update.from_user.first_name), reply_markup=reply_markup, parse_mode="html", reply_to_message_id=update.message_id)
from bot import LOGGER def __list_all_modules(): from os.path import dirname, basename, isfile import glob # This generates a list of modules in this folder # for the * in __main__ to work. mod_paths = glob.glob(dirname(__file__) + "/*.py") all_modules = [ basename(f)[:-3] for f in mod_paths if (isfile(f) and f.endswith(".py") and not f.endswith('__init__.py')) ] return all_modules ALL_MODULES = sorted(__list_all_modules()) LOGGER(__name__).info("Modules to load: %s", str(ALL_MODULES)) __all__ = ALL_MODULES + ["ALL_MODULES"]
# First we need the asyncio library import asyncio import importlib from bot import (LOGGER, BOT) from bot.plugins import ALL_MODULES async def main(): await BOT.start() IMPORTED = {} for module_name in ALL_MODULES: imported_module = importlib.import_module("bot.plugins." + module_name) if not hasattr(imported_module, "__mod_name__"): imported_module.__mod_name__ = imported_module.__name__ if not imported_module.__mod_name__.lower() in IMPORTED: IMPORTED[imported_module.__mod_name__.lower()] = imported_module else: raise Exception( "Can't have two modules with the same name! Please change one") LOGGER(__name__).info("Successfully loaded modules: " + str(ALL_MODULES)) # await BOT.run_until_disconnected() if __name__ == '__main__': LOGGER(__name__).info("Successfully loaded modules: " + str(ALL_MODULES)) # Then we need a loop to work with loop = asyncio.get_event_loop() # Then, we need to run the loop with a task loop.run_until_complete(main())