Exemple #1
0
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
#SOFTWARE.
from pyrogram import Client, filters
from pyrogram.types import Message
from utils import mp, RADIO, USERNAME
from config import Config
from config import STREAM
CHAT = Config.CHAT
ADMINS = Config.ADMINS


@Client.on_message(
    filters.command(["radio", f"radio@{USERNAME}"]) & filters.user(ADMINS) &
    (filters.chat(CHAT) | filters.private))
async def radio(client, message: Message):
    if 1 in RADIO:
        k = await message.reply_text(
            "Kindly stop existing Radio Stream /stopradio")
        await mp.delete(k)
        await message.delete()
        return
    await mp.start_radio()
    k = await message.reply_text(f"Started Radio: <code>{STREAM}</code>")
    await mp.delete(k)
    await message.delete()


@Client.on_message(
Exemple #2
0
from pyrogram import client, filters
import asyncio
import time
from pyrogram.types import ChatPermissions
from kingbot import kingbot, vr, Adminsettings
__MODULE__ = "unlock"
__HELP__ = """
__**This command helps you to unlock chat for non-admins in the chat**__
──「 **Usage** 」──
-> `unlock`
"""


@kingbot.on_message(
    filters.command("unlock", vr.get("HNDLR")) & filters.user(Adminsettings))
def unlock(_, message):
    chat_id = message.chat.id
    message.reply("Chat has been unlocked !!")
    kingbot.set_chat_permissions(
        chat_id,
        ChatPermissions(can_send_messages=True,
                        can_send_stickers=True,
                        can_send_media_messages=True,
                        can_send_animations=True))
Exemple #3
0
logger = logging.getLogger(__name__)


@Client.on_message(filters.command('start'))
async def start(bot, message):
    """Start command handler"""
    buttons = [[
        InlineKeyboardButton('тнХ Search Here тнХ',
                             switch_inline_query_current_chat=''),
        InlineKeyboardButton('тнХ Go Inline тнХ', switch_inline_query=''),
    ]]
    reply_markup = InlineKeyboardMarkup(buttons)
    await message.reply(START_MSG, reply_markup=reply_markup)


@Client.on_message(filters.command('channel') & filters.user(ADMINS))
async def channel_info(bot, message):
    """Send basic information of channel"""

    if isinstance(CHANNELS, (int, str)):
        channels = [CHANNELS]
    elif isinstance(CHANNELS, list):
        channels = CHANNELS
    else:
        raise ValueError("Unexpected type of CHANNELS")

    for channel in channels:
        channel_info = await bot.get_chat(channel)
        string = str(channel_info)
        if len(string) > 4096:
            filename = (channel_info.title or channel_info.first_name) + ".txt"
Exemple #4
0
GET_FORMAT = {
    Types.TEXT.value: app.send_message,
    Types.DOCUMENT.value: app.send_document,
    Types.PHOTO.value: app.send_photo,
    Types.VIDEO.value: app.send_video,
    Types.STICKER.value: app.send_sticker,
    Types.AUDIO.value: app.send_audio,
    Types.VOICE.value: app.send_voice,
    Types.VIDEO_NOTE.value: app.send_video_note,
    Types.ANIMATION.value: app.send_animation,
    Types.ANIMATED_STICKER.value: app.send_sticker,
    Types.CONTACT: app.send_contact
}


@app.on_message(filters.user(Owner) & filters.command(["save"], Command))
async def save_note(_client, message):
    if not DB_AVAILABLE:
        await message.edit("Your database is not avaiable!")
        return
    note_name, text, data_type, content = get_note_type(message)

    if not note_name:
        await message.edit("```" + message.text + '```\n\nError: You must give a name for this note!')
        return

    if data_type == Types.TEXT:
        teks, _ = parse_button(text)
        if not teks:
            await message.edit("```" + message.text + '```\n\nError: There is no text in here!')
            return
Exemple #5
0
    time_list.reverse()
    ping_time += ":".join(time_list)

    return ping_time


@setbot.on_callback_query(dynamic_data_filter("alive_message"))
async def alivemsg_callback(client, query):
    start_time = time.time()
    uptime = get_readable_time((time.time() - BOT_RUNTIME))
    reply_msg = f"{OwnerUsername}@nana-remix\n"
    reply_msg += "------------------\n"
    end_time = time.time()
    ping_time = round((end_time - start_time) * 1000, 3)
    reply_msg += f"Ping: {ping_time}ms\n"
    reply_msg += f"Userbot uptime: {uptime}"
    await client.answer_callback_query(query.id, reply_msg, show_alert=True)


@app.on_message(
    filters.user(AdminSettings) & filters.command("alive", Command))
async def google_search(client, message):
    x = await client.get_inline_bot_results(f"{BotUsername}", "alive")
    await message.delete()
    await client.send_inline_bot_result(
        chat_id=message.chat.id,
        query_id=x.query_id,
        result_id=x.results[0].id,
        reply_to_message_id=ReplyCheck(message),
        hide_via=True)
    #
    
    app = Client(
        SESSION_NAME,
        bot_token=TG_BOT_TOKEN,
        api_id=APP_ID,
        api_hash=API_HASH,
        workers=2
    )
    #
    app.set_parse_mode("html")
    #
    # STATUS ADMIN Command
    incoming_status_command = MessageHandler(
        sts,
        filters=filters.command(["status"]) & filters.user(AUTH_USERS)
    )
    app.add_handler(incoming_status_command)

    # BAN Admin Command
    incoming_ban_command = MessageHandler(
        ban,
        filters=filters.command(["ban_user"]) & filters.user(AUTH_USERS)
    )
    app.add_handler(incoming_ban_command)

    # UNBAN Admin Command
    incoming_unban_command = MessageHandler(
        unban,
        filters=filters.command(["unban_user"]) & filters.user(AUTH_USERS)
    )
from pyrogram import filters
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message

from wbb import SUDOERS, app, eor


# Module help for this is in sudoers.py
async def aexec(code, client, message):
    exec("async def __aexec(client, message): " +
         "".join(f"\n {a}" for a in code.split("\n")))
    return await locals()["__aexec"](client, message)


@app.on_message(
    filters.user(SUDOERS)
    & ~filters.forwarded
    & ~filters.via_bot
    & ~filters.edited
    & filters.command("eval"))
async def executor(client, message: Message):
    try:
        cmd = message.text.split(" ", maxsplit=1)[1]
    except IndexError:
        return await message.delete()
    t1 = time()
    old_stderr = sys.stderr
    old_stdout = sys.stdout
    redirected_output = sys.stdout = StringIO()
    redirected_error = sys.stderr = StringIO()
    stdout, stderr, exc = None, None, None
import re
import time
import datetime
from config import Config
from pyrogram import Client, filters
from pyrogram.types.messages_and_media import message
from database.repository.user import UserRepository
from database.repository.superban import SuperbanRepository
from pyrogram.handlers import MessageHandler

app = Client("my_account", api_id=Config.API_ID, api_hash=Config.API_HASH)


@app.on_message(
    filters.command("getall") & filters.group & filters.user(Config.OWNER))
def get_all_chat_members(client, message):
    chat = message.chat.id
    for member in app.iter_chat_members(chat):
        current_time = datetime.datetime.utcnow().isoformat()
        if member.user.username is not None:
            user_id = member.user.id
            user_username = '******' + member.user.username
            user = UserRepository().getById(user_id)
            default_count_warn = 0
            if user:
                print("User {}, {} exists on the database".format(
                    user_username, user_id))
                data = [(user_username, current_time, user_id)]
                UserRepository().update(data)
            else:
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""

from wbb import app, app2, BOT_ID, USERBOT_ID, SUDOERS, USERBOT_PREFIX
from pyrogram import filters
from wbb.utils.dbfunctions import is_pmpermit_approved, approve_pmpermit, disapprove_pmpermit
from wbb.core.decorators.errors import capture_err
import asyncio

flood = {}


@app2.on_message(filters.private & ~filters.edited & ~filters.me & ~filters.bot
                 & ~filters.user(SUDOERS))
@capture_err
async def pmpermit_func(_, message):
    user_id = message.from_user.id
    if await is_pmpermit_approved(user_id):
        return
    async for m in app2.iter_history(user_id, limit=6):
        if m.reply_markup:
            await m.delete()
    if str(user_id) in flood:
        flood[str(user_id)] += 1
    else:
        flood[str(user_id)] = 1
    if flood[str(user_id)] > 5:
        await app2.block_user(user_id)
        await message.reply_text("SPAM DETECTED, USER BLOCKED.")
Exemple #10
0
-> /setsticker This command only for Assistant bot,
to set your sticker pack. When sticker pack is full,
type that command and select another or create new from @Stickers!

-> /setanimation This command is used to set animated pack through Assistant.
When sticker pack is full,
type that command and select another or create new from @Stickers!

"""


stickers_lock = asyncio.Lock()


@app.on_message(
    filters.user(AdminSettings) &
    filters.command('kang', COMMAND_PREFIXES),
)
async def kang_stickers(client, message):
    if not DB_AVAILABLE:
        await edit_or_reply(message, text="You haven't set up a database!")
        return
    async with stickers_lock:
        sticker_pack = get_sticker_set(message.from_user.id)
        animation_pack = get_stanim_set(message.from_user.id)
        if not sticker_pack:
            await edit_or_reply(
                message,
                text='Sticker pack doesnt exist.',
            )
            await setbot.send_message(
Exemple #11
0
		if message.photo:
			return
		try:
			forwarded_msg = await message.forward(DB_CHANNEL)
			file_er_id = forwarded_msg.message_id
			share_link = f"https://telegram.dog/{BOT_USERNAME}?start=AbirHasan2005_{file_er_id}"
			CH_edit = await bot.edit_message_reply_markup(message.chat.id, message.message_id, reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("Get Sharable Stored Link", url=share_link)]]))
			if message.chat.username:
				await forwarded_msg.reply_text(f"#CHANNEL_BUTTON:\n\n[{message.chat.title}](https://t.me/{message.chat.username}/{CH_edit.message_id}) Channel's Broadcasted File's Button Added!")
			else:
				private_ch = str(message.chat.id)[4:]
				await forwarded_msg.reply_text(f"#CHANNEL_BUTTON:\n\n[{message.chat.title}](https://t.me/c/{private_ch}/{CH_edit.message_id}) Channel's Broadcasted File's Button Added!")
		except Exception as err:
			print(f"Error: {err}")

@Bot.on_message(filters.private & filters.command("broadcast") & filters.user(BOT_OWNER) & filters.reply)
async def broadcast_(c, m):
	all_users = await db.get_all_users()
	broadcast_msg = m.reply_to_message
	while True:
	    broadcast_id = ''.join([random.choice(string.ascii_letters) for i in range(3)])
	    if not broadcast_ids.get(broadcast_id):
	        break
	out = await m.reply_text(
	    text = f"Broadcast Started! You will be notified with log file when all the users are notified."
	)
	start_time = time.time()
	total_users = await db.total_users_count()
	done = 0
	failed = 0
	success = 0
Exemple #12
0
from pyrogram.types.messages_and_media import message
from config import OWNER_ID
from pyrogram import filters
from pyrogram.errors import BadRequest
from AlexaSongBot import app
import AlexaSongBot.sql.blacklist_sql as sql
from AlexaSongBot.pikachu import get_arg


@app.on_message(filters.user(OWNER_ID) & filters.command("blacklist"))
async def blacklist(client, message):
    if message.reply_to_message:
        user_id = message.reply_to_message.from_user["id"]
    else:
        arg = get_arg(message)
        if len(arg) != 1:
            await message.reply(
                "pass a user id or user name or reply to a user message")
            return ""
        if arg.startswith("@"):
            try:
                user = await app.get_users(arg)
                user_id = user.id
            except BadRequest as ex:
                await message.reply("not a valid user")
                print(ex)
                return ""
        else:
            user_id = int(arg)
        sql.add_user_to_bl(int(user_id))
        await message.reply(f"[blacklisted](tg://user?id={user_id})")
Exemple #13
0
        ungbun.edit("`You Have No Chats! So Sad`")
        return
    await ungbun.edit("`Starting Un-GBans Now!`")
    for ujwal in chat_dict:
        try:
            await client.unban_chat_member(ujwal, int(userz.id))
        except:
            failed += 1
    await ungban_user(userz.id)
    ungbanned = f"**#Un_GBanned** \n**User :** [{userz.first_name}](tg://user?id={userz.id}) \n**Affected Chats :** `{chat_len-failed}`"
    await ungbun.edit(ungbanned)
    log = LogIt(message)
    await log.log_msg(client, ungbanned)


@listen(filters.incoming & ~filters.me & ~filters.user(Config.AFS))
async def delete_user_msgs(client, message):
    if not message:
        message.continue_propagation()
        return
    if not message.from_user:
        message.continue_propagation()
        return
    user = message.from_user.id
    if await is_gmuted(user):
        try:
            await message.delete()
        except:
            message.continue_propagation()
            return
    if await gban_info(user):
Exemple #14
0
@app.on_message(filters.command("start") & filters.chat(sudo_chat_id))
async def start(_, message):
    await send(START_TEXT)


@app.on_message(filters.command("help") & filters.chat(sudo_chat_id))
async def help(_, message):
    await send(HELP_TEXT)


@app.on_message(filters.command("repo") & filters.chat(sudo_chat_id))
async def repo(_, message):
    await send(REPO_TEXT)


@app.on_message(filters.command("joinvc") & filters.user(owner_id))
async def joinvc(_, message):
    global chat_joined
    try:
        if chat_joined:
            await send("__**Bot Is Already In Voice Chat.**__")
            return
        chat_id = message.chat.id
        await vc.start(chat_id)
        chat_joined = True
        m = await send("__**Joined The Voice Chat.**__")
    except Exception as e:
        print(str(e))
        await send(str(e))

Exemple #15
0
    if mp.msg.get('current') is not None:
        await mp.msg['current'].delete()
    mp.msg['current'] = await playlist[0].reply_text(
        f"{emoji.PLAY_BUTTON}  {utcnow - start_time} / "
        f"{timedelta(seconds=playlist[0].audio.duration)}",
        parse_mode="Markdown",
        reply_markup=InlineKeyboardMarkup([
            [
                InlineKeyboardButton("🔄", callback_data="replay"),
                InlineKeyboardButton("⏯", callback_data="pause"),
                InlineKeyboardButton("⏩", callback_data="skip")
            ],
        ]))


@Client.on_message(current_vc & filters.command("skip") & filters.user(ADMINS))
async def skip_track(_, m: Message):
    playlist = mp.playlist
    if len(m.command) == 1:
        await mp.skip_current_playing()
        playlist = mp.playlist
        if not playlist:
            pl = f"{emoji.NO_ENTRY} empty playlist"
        else:
            if len(playlist) == 1:
                pl = f"{emoji.REPEAT_SINGLE_BUTTON} **Playlist**:\n"
            else:
                pl = f"{emoji.PLAY_BUTTON} **Playlist**:\n"
            pl += "\n".join([
                f"**{i}**. **[{x.audio.title}]({x.link})**"
                for i, x in enumerate(playlist)
Exemple #16
0
# Telegram - Twitter - Bot
# Github.com/New-dev0/TgTwitterBot
# CopyLeft AGPLv3 (C) 2020 The Authors
# 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 pyrogram import Client, filters
from twitterbot import AUTH, api
from twitterbot.funcs import user_eazy, tweeteazy


@Client.on_inline_query(filters.regex("^search") & filters.user(AUTH))
async def searchthing(client, query):
    try:
        match = query.query.split(" ", maxsplit=1)[1]
    except IndexError:
        return await query.answer([],
                                  switch_pm_text="Enter Query to Search",
                                  switch_pm_parameter="start")
    outex = api.search(match)
    results = tweeteazy(outex)
    await query.answer(results,
                       switch_pm_text=f"Showing {len(results)} Results",
                       switch_pm_parameter="start")


@Client.on_inline_query(filters.regex("^user") & filters.user(AUTH))
async def searchuser(client, query):
    try:
        match = query.query.split(" ", maxsplit=1)[1]
    except IndexError:
Exemple #17
0
import traceback
import sys
import os
import re
import subprocess
from io import StringIO

from pyrogram import filters

from naruto import Owner, setbot
from naruto.plugins.dev import aexec


@setbot.on_message(filters.user(Owner) & filters.command(["eval"]))
async def eval(client, message):
    status_message = await message.reply_text("`Running ...`")
    try:
        cmd = message.text.split(" ", maxsplit=1)[1]
    except IndexError:
        await status_message.delete()
        return
    reply_to_id = message.message_id
    if message.reply_to_message:
        reply_to_id = message.reply_to_message.message_id
    old_stderr = sys.stderr
    old_stdout = sys.stdout
    redirected_output = sys.stdout = StringIO()
    redirected_error = sys.stderr = StringIO()
    stdout, stderr, exc = None, None, None
    try:
        await aexec(cmd, client, message)
Exemple #18
0
from pyrogram import Client, filters

from plugins import r, admin


@Client.on_message(filters.private & filters.user(admin)
                   & filters.command("help"))
async def help_message(c, m):

    chat_id = m.chat.id

    help_message = """⚡️ **اپشن های موجود** ⚡️
        \n☔️ اضافه کردن پیام به ربات با کامند     /add_msg        
		\n☔️ حذف کردن پیام از ربات با کامند       /del_msg        
		\n☔️ نمایش جملات موجود با کامند       /show_msg        
		\n☔️ نمایش وضعیت ربات     /info        
		\n☔️ چک کردن وضعیت ربات با کامند      /status        
		\n☔️ فوروارد کردن پیام       /forward        
		\b☔️ جوین شدن داخل گروه مورد نظر     /join_chat        
		\n☔️ ست کردن پیام بعد از جوین شدن ربات در گروه       /join_msg
		\n.
	"""

    await c.send_chat_action(chat_id=chat_id, action="typing")

    await c.send_message(chat_id=chat_id, text=help_message)


@Client.on_message(filters.private & filters.user(admin)
                   & filters.command("add_msg"))
async def add_msg(c, m):
Exemple #19
0
        await message.edit("`PM Logger disabled !`", del_in=3)
    else:
        Config.PM_LOGGING = True
        await message.edit("`PM Logger enabled !`", del_in=3)
    await SAVED_SETTINGS.update_one({"_id": "PM_LOGGING"},
                                    {"$set": {
                                        "is_active": Config.PM_LOGGING
                                    }},
                                    upsert=True)


@userge.on_message(
    filters.private
    & filters.incoming
    & ~filters.me
    & ~filters.user(Config.TG_IDS)
    & ~filters.service
    & ~filters.bot
    & ~filters.edited
    & ~allowAllFilter
    & allowPmLoggingFilter,
    group=2,
)
async def pm_logger(_, message: Message):
    u_id = message.from_user.id
    u_name = message.from_user.first_name
    found = await NO_PM_LOG.find_one({"user_id": u_id})
    if found:
        return
    pm_logger_msg = "<b><i>ID</i></b> : <code>{}</code>\n👤 {} sent"
    new_pm_logger = pm_logger_msg + " a new message."
Exemple #20
0
import asyncio

from pyrogram import filters
from pyrogram.types import Message

from userbot import UserBot, ALLOWED_USERS
from userbot.plugins.help import add_command_help


@UserBot.on_message(
    filters.command(["l", "lyrics"], ".") &
    (filters.me | filters.user(ALLOWED_USERS)))
async def send_lyrics(_, message: Message):
    try:
        cmd = message.command

        song_name = ""
        if len(cmd) > 1:
            song_name = " ".join(cmd[1:])
        elif message.reply_to_message:
            if message.reply_to_message.audio:
                song_name = f"{message.reply_to_message.audio.title} {message.reply_to_message.audio.performer}"
            elif len(cmd) == 1:
                song_name = message.reply_to_message.text
        elif not message.reply_to_message and len(cmd) == 1:
            await message.edit("Give a song name")
            await asyncio.sleep(2)
            await message.delete()
            return

        await message.edit(f"Getting lyrics for `{song_name}`")
Exemple #21
0
                                   whitelist_chat)

__MODULE__ = "Blacklist Chat"
__HELP__ = """
**THIS MODULE IS ONLY FOR DEVS**

Use this module to make the bot leave some chats
in which you don't want it to be in.

/blacklist_chat [CHAT_ID] - Blacklist a chat.
/whitelist_chat [CHAT_ID] - Whitelist a chat.
/blacklisted - Show blacklisted chats.
"""


@app.on_message(filters.command("blacklist_chat") & filters.user(SUDOERS))
@capture_err
async def blacklist_chat_func(_, message: Message):
    if len(message.command) != 2:
        await message.reply_text("**Usage:**\n/blacklist_chat [CHAT_ID]")
        return
    chat_id = int(message.text.strip().split()[1])
    if chat_id in await blacklisted_chats():
        await message.reply_text("Chat is already blacklisted.")
        return
    blacklisted = await blacklist_chat(chat_id)
    if blacklisted:
        await message.reply_text("Chat has been successfully blacklisted")
        return
    await message.reply_text("Something wrong happened, check logs.")
Exemple #22
0
|  c++ |  elixir  |    erlang     |   f#  |
|  go  |  fortran |    haskell    |   d   |
| java |  kotlin  |  objective-c  |   js  |
| lua  |   mysql  |   postgresql  |  node |
| lisp |   ocaml  | python3 - py3 |  php  |
| perl |  oracle  |  python - py  |  perl |
| nasm |  pascal  |     prolog    |  sql  |
| ruby |  octave  |     scheme    |   r   |
| tcl  |  scheme  |     scala     |  sql  |
|swift |   tcl    |      vb
```
"""


@app.on_message(
    filters.user(AdminSettings) & filters.command('rex', COMMAND_PREFIXES), )
async def rex_tester(_, message):
    try:
        args = message.text.split(None, 2)
        language = args[1]
        code = args[2]
    except IndexError:
        await edit_or_reply(
            message,
            text='Format: `rex lang code`',
        )
        return
    try:
        output = await rexec_aio(language, code)
        final = f'**Language:** `{language}`\n'
        final += f'**Input:**\n`{code}`\n'
Exemple #23
0
import os

import pydrive
from pydrive.drive import GoogleDrive
from pyrogram import filters

from nana import setbot, AdminSettings, gauth, gdrive_credentials, HEROKU_API
from nana.tr_engine.strings import tld


@setbot.on_message(filters.user(AdminSettings) & filters.command(["gdrive"]))
async def gdrive_helper(_client, message):
    if len(message.text.split()) == 1:
        gdriveclient = os.path.isfile("client_secrets.json")
        if HEROKU_API:
            if not gdrive_credentials:
                await message.reply(tld("gdrive_credential_err_heroku"))
                return
            elif not gdriveclient:
                with open("client_secrets.json", "w") as gfile:
                    gfile.write(gdrive_credentials)
                    gfile.close()
                gdriveclient = os.path.isfile("client_secrets.json")
        if not gdriveclient:
            await message.reply(
                "Hello, look like you're not logged in to google drive 🙂\nI can help you to login.\n\nFirst of all, "
                "you need to activate your google drive API\n1. [Go here]("
                "https://developers.google.com/drive/api/v3/quickstart/python), click **Enable the drive API**\n2. "
                "Login to your google account (skip this if you're already logged in)\n3. After logged in, "
                "click **Enable the drive API** again, and click **Download Client Configuration** button, "
                "download that.\n4. After downloaded that file, open that file then copy all of that content, "
Exemple #24
0
from asyncio import sleep
from pyrogram import filters
from nana import app, Command, AdminSettings, edrep

__MODULE__ = "Quotly"
__HELP__ = """
This module can make message text to sticker. (Experimental)

──「 **Make Quote From Message** 」──
-> `q`
__Reply To Message Text To Create Quote Sticker.__

"""


@app.on_message(filters.user(AdminSettings) & filters.command("q", Command))
async def q_maker(_client, message):
    if not message.reply_to_message:
        await edrep(message, text="**Reply to any users text message**")
        return
    await message.reply_to_message.forward("@QuotLyBot")
    is_sticker = False
    while not is_sticker:
        try:
            ms_g = await app.get_history("@QuotLyBot", 1)
            check = ms_g[0]["sticker"]["file_id"]
            print(check)
            is_sticker = True
        except Exception as e:
            print(e)
            await sleep(0.5)
Exemple #25
0
                ]]))
            if message.chat.username:
                await forwarded_msg.reply_text(
                    f"#CHANNEL_BUTTON:\n\n[{message.chat.title}](https://t.me/{message.chat.username}/{CH_edit.message_id}) Channel's Broadcasted File's Button Added!"
                )
            else:
                private_ch = str(message.chat.id)[4:]
                await forwarded_msg.reply_text(
                    f"#CHANNEL_BUTTON:\n\n[{message.chat.title}](https://t.me/c/{private_ch}/{CH_edit.message_id}) Channel's Broadcasted File's Button Added!"
                )
        except Exception as err:
            print(f"Error: {err}")


@Bot.on_message(filters.private & filters.command("broadcast")
                & filters.user(BOT_OWNER) & filters.reply)
async def broadcast_(c, m):
    all_users = await db.get_all_users()
    broadcast_msg = m.reply_to_message
    while True:
        broadcast_id = ''.join(
            [random.choice(string.ascii_letters) for i in range(3)])
        if not broadcast_ids.get(broadcast_id):
            break
    out = await m.reply_text(
        text=
        f"Broadcast Started! You will be notified with log file when all the users are notified."
    )
    start_time = time.time()
    total_users = await db.total_users_count()
    done = 0
Exemple #26
0
    ]

    delta = time.time() - start
    messages.sort(key=lambda k: k['date'])

    return '\n'.join([
        '{} last [message]({}) was {}'.format(
            m.from_user.mention,
            m.link,
            timeago.format(m.date),
        ) for m in messages
    ] + [f'`{int(delta * 1000)}ms`'], )


@app.on_message(
    filters.user(AdminSettings) & filters.command(
        ['wordcount', 'wc'],
        COMMAND_PREFIXES,
    ), )
async def word_count(client, message):
    await message.delete()
    words = Custom()
    progress = await client.send_message(
        message.chat.id,
        '`Processing 1000 messages...`',
    )
    async for ms_g in client.iter_history(message.chat.id, 1000):
        if ms_g.text:
            for word in ms_g.text.split():
                words[word.lower()] += 1
        if ms_g.caption:
Exemple #27
0
from pyrogram import filters as Filters

from bot.config import Config
from bot.screenshotbot import ScreenShotBot


@ScreenShotBot.on_callback_query(
    Filters.create(lambda _, __, query: query.data.startswith('sts_bdct'))
    & Filters.user(Config.AUTH_USERS))
async def sts_broadcast_(c, cb):

    _, broadcast_id = cb.data.split('+')

    if not c.broadcast_ids.get(broadcast_id):
        await cb.answer(text=f"No active broadcast with id {broadcast_id}",
                        show_alert=True)
        return

    sts_txt = ''
    for key, value in c.broadcast_ids[broadcast_id].items():
        sts_txt += f'{key} = {value}\n'

    await cb.answer(text=f"Broadcast Status for {broadcast_id}\n\n{sts_txt}",
                    show_alert=True)
Exemple #28
0
-> `ls (path)`
see list of files and directories, path is optional

──「 **Direct Link Download** 」──
-> `direct (url)`
Create A direct link download

Supported Link
`gdrive     | zippyshare   | mega
yadi.sk    | mediafire    | osdn.net
github.com | Sourceforge
androidfilehost.com`
"""


@app.on_message(filters.user(AdminSettings) & filters.command("ls", Command))
async def ls(_client, message):
    args = message.text.split(None, 1)
    basepath = "nana/{}".format(args[1]) if len(args) == 2 else "nana/"
    directory = ""
    listfile = ""
    for entry in os.listdir(basepath):
        if os.path.isdir(os.path.join(basepath, entry)):
            directory += "\n{}".format(entry)
    for entry in os.listdir(basepath):
        if os.path.isfile(os.path.join(basepath, entry)):
            listfile += "\n{}".format(entry)
    await edrep(message,
                text="**List directory :**`{}`\n**List file :**`{}`".format(
                    directory, listfile))
Exemple #29
0
from AsunaBot.utils.botinfo import BOT_ID
from AsunaBot.utils.dbfunctions import (is_gbanned_user, add_gban_user,
                                        remove_gban_user, get_served_chats)

__MODULE__ = "Sudoers"
__HELP__ = '''/log - To Get Logs From Last Run.
/speedtest - To Perform A Speedtest.
/stats - To Check System Status.
/global_stats - To Check Bot's Global Stats.
/gban - To Ban A User Globally.
/broadcast - To Broadcast A Message In All Groups.'''

# Logs Module


@app.on_message(filters.user(SUDOERS) & filters.command("log"))
@capture_err
async def logs_chat(_, message):
    keyb = types.InlineKeyboardMarkup([[
        types.InlineKeyboardButton("Paste on Nekobin",
                                   callback_data="paste_log_nekobin")
    ]])
    await message.reply_document("error.log", reply_markup=keyb)


def logs_callback(_, __, query):
    if re.match("paste_log_nekobin", query.data):
        return True


logs_create = filters.create(logs_callback)
Exemple #30
0
import io

import requests
from pyrogram import Client, filters, emoji
from pyrogram.types import Message
from telegraph import utils

from main import prefixes

HEADERS = {"Origin": "https://telegra.ph"}


@Client.on_message(
    filters.user("self") & filters.command("telegraph", prefixes=prefixes))
def telegraph(c: Client, msg: Message):
    if len(msg.command) > 1:
        targetmsg = msg
        text = (targetmsg.text[len("/telegraph"):]
                or targetmsg.caption[len("/telegraph"):])
        author = targetmsg.from_user.first_name
        title = msg.chat.username or msg.chat.title or msg.chat.first_name
    elif msg.reply_to_message:
        targetmsg = msg.reply_to_message
        text = targetmsg.text
        author = targetmsg.from_user.first_name
        title = msg.chat.username or msg.chat.title or msg.chat.first_name
    else:
        msg.edit_text(
            "Please reply to a message or specify the text with <code>/telegraph Some Text Here</code>"
        )
        return 1