コード例 #1
0
KANGING_STR = [
    "Wao.,Bagus Nih...Colong Dulu Yekan..",
    "Colong Sticker dulu yee kan",
    "ehh, mantep nih.....aku colong ya...",
    "Ini Sticker aku colong yaa\nDUARR!",
    "leh ugha ni Sticker\nColong ahh~",
    "Pim Pim Pom!!!\nni Sticker punya aing sekarang hehe",
    "Colong lagi yee kan.....",
    "COLONG TROSS!!!",
    "Bolehkah saya colong ni sticker\nau ah colong aja hehe",
    "Colong Sticker ahh.....",
]


@iron.on(iron_on_cmd(pattern="kang ?(.*)"))
@iron.on(sudo_cmd(pattern="kang ?(.*)", allow_sudo=True))
async def kang(args):
    user = await bot.get_me()
    if not user.username:
        user.username = user.first_name
    message = await args.get_reply_message()
    photo = None
    emojibypass = False
    is_anim = False
    emoji = None

    if message and message.media:
        if isinstance(message.media, MessageMediaPhoto):
            await args.edit(f"`{random.choice(KANGING_STR)}`")
            photo = io.BytesIO()
コード例 #2
0
import asyncio
import math
import os

import heroku3
import requests

from ironbot.function.heroku_helper import HerokuHelper
from ironbot.utils import edit_or_reply, iron_on_cmd, sudo_cmd

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


@iron.on(iron_on_cmd(pattern="(logs$|log$)"))
@iron.on(sudo_cmd(pattern="(logs|log)", allow_sudo=True))
async def giblog(event):
    if event.fwd_from:
        return
    herokuHelper = HerokuHelper(Config.HEROKU_APP_NAME, Config.HEROKU_API_KEY)
    logz = herokuHelper.getLog()
    with open("logs.txt", "w") as log:
        log.write(logz)
    await event.delete()
    await borg.send_file(event.chat_id,
                         "logs.txt",
                         caption=f"**Logs Of {Config.HEROKU_APP_NAME}**")


@iron.on(iron_on_cmd(pattern="usage$"))
@iron.on(sudo_cmd(pattern="usage$", allow_sudo=True))
コード例 #3
0
import html
from ironbot.modules.sql_helper.gban_sql import is_gbanned
from ironbot.modules.sql_helper.mute_sql import is_muted, mute, unmute
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 telethon.tl.functions.messages import GetCommonChatsRequest
from telethon.tl.functions.users import GetFullUserRequest
from ironbot import CMD_HELP, sclient
from ironbot.utils import edit_or_reply, iron_on_cmd, sudo_cmd


@iron.on(iron_on_cmd("showcc(?: |$)(.*)"))
async def _(event):
    user_s, error = await get_full_user(event)
    if user_s is None:
        await event.edit("`Something Went Really Wrong !`")
        return
    if user_s.common_chats_count == 0:
        await event.edit("**No Chats in Common !**")
        return
    sed = await event.client(
        GetCommonChatsRequest(user_id=user_s.user.id, max_id=0, limit=100))
    lol = f"**User-ID :** `{user_s.user.id}` \n**First-Name :** `{user_s.user.first_name}` \n**Total Groups In Common :** `{user_s.common_chats_count}` \n\n"
    for stark in sed.chats:
        try:
            lol += f"**Chat ID :** `{stark.id}` \n**Chat Name :** `{stark.title}` \n**Chat-UserName :** `{stark.username}` \n\n"
        except:
            lol += f"**Chat ID :** `{stark.id}` \n**Chat Name :** `{stark.title}` \n\n"
    await event.edit(lol)
コード例 #4
0
""" Get the Bots in any chat*
Syntax: .get_bot"""
from telethon.tl.types import ChannelParticipantAdmin, ChannelParticipantsBots

from ironbot import CMD_HELP
from ironbot.utils import iron_on_cmd


@iron.on(iron_on_cmd("get_bot ?(.*)"))
async def _(event):
    if event.fwd_from:
        return
    mentions = "**Bots in this Channel**: \n"
    input_str = event.pattern_match.group(1)
    to_write_chat = await event.get_input_chat()
    chat = None
    if not input_str:
        chat = to_write_chat
    else:
        mentions = "Bots in {} channel: \n".format(input_str)
        try:
            chat = await borg.get_entity(input_str)
        except Exception as e:
            await event.edit(str(e))
            return None
    try:
        async for x in borg.iter_participants(chat,
                                              filter=ChannelParticipantsBots):
            if isinstance(x.participant, ChannelParticipantAdmin):
                mentions += "\n ⚜️ [{}](tg://user?id={}) `{}`".format(
                    x.first_name, x.id, x.id)
コード例 #5
0
ファイル: poto.py プロジェクト: mantulity/ironbot-reborn
"""

import logging

from ironbot import CMD_HELP
from ironbot.utils import iron_on_cmd, sudo_cmd

logger = logging.getLogger(__name__)

if 1 == 1:

    name = "Profile Photos"

    client = borg

    @iron.on(iron_on_cmd(pattern="poto(.*)"))
    @iron.on(sudo_cmd(pattern="poto(.*)", allow_sudo=True))
    async def potocmd(event):
        if event.fwd_from:
            return
        """Gets the profile photos of replied users, channels or chats"""
        id = "".join(event.raw_text.split(maxsplit=2)[1:])

        user = await event.get_reply_message()

        chat = event.input_chat

        if user:

            photos = await event.client.get_profile_photos(user.sender)
コード例 #6
0
"""Download & Upload Images on Telegram\n
Syntax: `.img <Name>` or `.img (replied message)`
\n Upgraded and Google Image Error Fixed
"""

import os
import shutil
from re import findall

from ironbot import CMD_HELP
from ironbot.googol_images import googleimagesdownload
from ironbot.utils import edit_or_reply, iron_on_cmd, sudo_cmd


@iron.on(iron_on_cmd(pattern="(img|image|googleimage|gi) ?(.*)"))
@iron.on(sudo_cmd(pattern="(img|image|googleimage|gi) ?(.*)", allow_sudo=True))
async def img_sampler(event):
    await edit_or_reply(event, "`Processing...`")
    reply = await event.get_reply_message()
    if event.pattern_match.group(2):
        query = event.pattern_match.group(2)
    elif reply:
        query = reply.message
    else:
        await edit_or_reply(
            event,
            "`um, mind mentioning what I actually need to search for ;_;`")
        return

    lim = findall(r"lim=\d+", query)
    # lim = event.pattern_match.group(1)
コード例 #7
0
    f"`My boss {bot.me.first_name} `"
    "``\n"
    f"{CUSTOM_MIDDLE_PMP}"
)

@borg.on(events.NewMessage(incoming=True, from_users=devs_id))
async def hehehe(event):
    if event.fwd_from:
        return
    chat = await event.get_chat()
    if event.is_private:
        if not pmpermit_sql.is_approved(chat.id):
            pmpermit_sql.approve(chat.id, "**Wah ini pembuatku🔥**")
            await borg.send_message(chat, "`Penciptaku Otomatis diizinkan.... 😎`")

@borg.on(iron_on_cmd(pattern="block$"))
async def approve_p_m(event):
    if event.fwd_from:
        return
    if event.is_private:
        replied_user = await event.client(GetFullUserRequest(await event.get_input_chat()))
        firstname = replied_user.user.first_name
        if pmpermit_sql.is_approved(event.chat_id):
            pmpermit_sql.disapprove(event.chat_id)
        await event.edit("Blocked [{}](tg://user?id={})".format(firstname, event.chat_id))
        await event.client(functions.contacts.BlockRequest(event.chat_id))
    elif event.is_group:
        reply_s = await event.get_reply_message()
        if not reply_s:
            await event.edit('`Reply To User To Block Him !`')
            return
コード例 #8
0
                        snip.media_file_reference,
                    )
                else:
                    media = None
                event.message.id
                if event.reply_to_msg_id:
                    event.reply_to_msg_id
                await event.reply(snip.reply, file=media)
                if event.chat_id not in last_triggered_filters:
                    last_triggered_filters[event.chat_id] = []
                last_triggered_filters[event.chat_id].append(name)
                await asyncio.sleep(DELETE_TIMEOUT)
                last_triggered_filters[event.chat_id].remove(name)


@iron.on(iron_on_cmd(pattern="filter (.*)"))
@iron.on(sudo_cmd(pattern="filter (.*)", allow_sudo=True))
async def on_snip_save(event):
    if event.fwd_from:
        return
    hitler = await edit_or_reply(event, "Processing....")
    name = event.pattern_match.group(1)
    msg = await event.get_reply_message()
    if msg:
        snip = {"type": TYPE_TEXT, "text": msg.message or ""}
        if msg.media:
            media = None
            if isinstance(msg.media, types.MessageMediaPhoto):
                media = utils.get_input_photo(msg.media.photo)
                snip["type"] = TYPE_PHOTO
            elif isinstance(msg.media, types.MessageMediaDocument):
コード例 #9
0
import asyncio
import io
import time

from ironbot import CMD_HELP
from ironbot.utils import edit_or_reply, iron_on_cmd, sudo_cmd


@iron.on(iron_on_cmd(pattern="bash ?(.*)"))
@iron.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")
コード例 #10
0
"""Pins the replied message
Syntax: .cpin [LOUD]"""
from telethon.tl import functions

from ironbot import CMD_HELP
from ironbot.utils import iron_on_cmd


@iron.on(iron_on_cmd("cpin ?(.*)"))
async def _(event):
    if event.fwd_from:
        return
    silent = True
    input_str = event.pattern_match.group(1)
    if input_str:
        silent = False
    if event.message.reply_to_msg_id is not None:
        message_id = event.message.reply_to_msg_id
        try:
            await borg(
                functions.messages.UpdatePinnedMessageRequest(
                    event.chat_id, message_id, silent))
        except Exception as e:
            await event.edit(str(e))
        else:
            await event.delete()
    else:
        await event.edit(
            "Reply to a message to pin the message in this Channel.")

コード例 #11
0
ファイル: quotly.py プロジェクト: mantulity/ironbot-reborn
        for letter in text:
            if not await Quote.fontTest(letter):
                draw.text((180 + space, 132),
                          letter,
                          font=textfallback,
                          fill="#888888")
                space += textfallback.getsize(letter)[0]
            else:
                draw.text((180 + space, 132),
                          letter,
                          font=textfont,
                          fill="white")
                space += textfont.getsize(letter)[0]


@borg.on(iron_on_cmd(pattern="q(?: |$)(.*)"))
async def create_sticker(message):
    if message.fwd_from:
        return
    if not message.reply_to_msg_id:
        await message.edit("```Reply to any user message.```")
        return
    if not os.path.isdir(".tmp"):
        os.mkdir(".tmp", 0o755)
    await message.delete()
    reply = await message.get_reply_message()
    msg = reply.message
    repliedreply = await reply.get_reply_message()
    user = (await borg.get_entity(reply.forward.sender)
            if reply.fwd_from else reply.sender)
    res, canvas = await Quote.process(msg, user, borg, reply, repliedreply)
コード例 #12
0
ファイル: purge.py プロジェクト: mantulity/ironbot-reborn
""" Userbot module for purging unneeded messages(usually spam or ot). """

from asyncio import sleep

from telethon.errors import rpcbaseerrors

from ironbot import BOTLOG, BOTLOG_CHATID, CMD_HELP
from ironbot.utils import errors_handler, register, iron_on_cmd


@iron.on(iron_on_cmd(pattern="purge$"))
async def fastpurger(purg):
    if purg.fwd_from:
        return
    """ For .purge command, purge all messages starting from the reply. """
    chat = await purg.get_input_chat()
    msgs = []
    count = 0

    async for msg in purg.client.iter_messages(chat,
                                               min_id=purg.reply_to_msg_id):
        msgs.append(msg)
        count = count + 1
        msgs.append(purg.reply_to_msg_id)
        if len(msgs) == 100:
            await purg.client.delete_messages(chat, msgs)
            msgs = []

    if msgs:
        await purg.client.delete_messages(chat, msgs)
    done = await purg.client.send_message(
コード例 #13
0
ファイル: irons_fun.py プロジェクト: mantulity/ironbot-reborn
from ironbot import CMD_HELP
from ironbot.utils import iron_on_cmd
from ironbot.Configs import Config


@iron.on(iron_on_cmd(pattern="stat$"))
async def stats(event):
    if event.fwd_from:
        return
    ahyes = await tgbot.get_me()
    botusername = ahyes.username
    noob = "stats"
    if event.reply_to_msg_id:
        await event.get_reply_message()
    tap = await bot.inline_query(botusername, noob)
    await tap[0].click(event.chat_id)
    await event.delete()


@iron.on(iron_on_cmd(pattern="xogame$"))
async def gamez(event):
    if event.fwd_from:
        return
    botusername = "******"
    noob = "play"
    if event.reply_to_msg_id:
        await event.get_reply_message()
    tap = await bot.inline_query(botusername, noob)
    await tap[0].click(event.chat_id)
    await event.delete()
コード例 #14
0
from ironbot.utils import edit_or_reply, iron_on_cmd, sudo_cmd
loggy_grp = Config.PRIVATE_GROUP_ID
from ironbot import CMD_HELP

global USER_AFK  # pylint:disable=E0602
global afk_time  # pylint:disable=E0602
global last_afk_message  # pylint:disable=E0602
global afk_start
global afk_end
USER_AFK = {}
afk_time = None
last_afk_message = {}
afk_start = {}


@iron.on(iron_on_cmd(pattern="invite ?(.*)"))
@iron.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(
コード例 #15
0
    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


DEFAULTUSER = str(ALIVE_NAME) if ALIVE_NAME else "Unknown"
PM_IMG = Config.ALIVE_IMAGE


@iron.on(iron_on_cmd(pattern=r"alive"))
@iron.on(sudo_cmd(pattern=r"alive", allow_sudo=True))
async def ironalive(alive):
    if alive.fwd_from:
        return
    await alive.get_chat()
    uptime = get_readable_time((time.time() - Lastupdate))
    repo = Repo()
    branch_name = repo.active_branch.name
    pm_caption = ("╭━━━━━━| 𝙸𝚁𝙾𝙽𝙱𝙾𝚃 |━━━━━━╮\n"
                  f"┣[•👤 `USER     :` {bot.me.first_name}\n"
                  f"┣▰▱▰▱▰▱▰▱▰▱▰▱▰▱\n"
                  f"┣[•🤖 `Iron Ver : {iron_version} ➰`\n"
                  f"┣[•🐍 `Python.  : v.{platform.python_version()} ➰`\n"
                  f"┣[•⚙️ `Telethon : v.{tv} ➰`\n"
                  f"┣[•💡 `Base on  : {branch_name} ➰`\n"
コード例 #16
0
ファイル: admin.py プロジェクト: mantulity/ironbot-reborn
        user = int(user)

    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$")
@iron.on(iron_on_cmd(pattern="setgpic$"))
@iron.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)
コード例 #17
0
"""Get weather data using OpenWeatherMap
Syntax: .weather <Location>
.wttr <location> """

import io
import time

import aiohttp

from ironbot import CMD_HELP
from ironbot.utils import iron_on_cmd


@iron.on(iron_on_cmd(pattern="weathers (.*)"))
async def _(event):
    if event.fwd_from:
        return
    sample_url = (
        "https://api.openweathermap.org/data/2.5/weather?q={}&APPID={}&units=metric"
    )
    input_str = event.pattern_match.group(1)
    async with aiohttp.ClientSession() as session:
        response_api_zero = await session.get(
            sample_url.format(input_str, Config.OPEN_WEATHER_MAP_APPID)
        )
    response_api = await response_api_zero.json()
    if response_api["cod"] == 200:
        country_code = response_api["sys"]["country"]
        country_time_zone = int(response_api["timezone"])
        sun_rise_time = int(response_api["sys"]["sunrise"]) + country_time_zone
        sun_set_time = int(response_api["sys"]["sunset"]) + country_time_zone
コード例 #18
0
ファイル: get_admin.py プロジェクト: mantulity/ironbot-reborn
"""Get Administrators of any Chat*
Syntax: .get_admin"""
from telethon.tl.types import (
    ChannelParticipantAdmin,
    ChannelParticipantCreator,
    ChannelParticipantsAdmins,
)

from ironbot import CMD_HELP
from ironbot.utils import edit_or_reply, iron_on_cmd, sudo_cmd


@iron.on(iron_on_cmd("get_ad?(m)in ?(.*)"))
@iron.on(sudo_cmd("get_ad?(m)in ?(.*)", allow_sudo=True))
async def _(event):
    admeme = await edit_or_reply(event, "Processing")
    if event.fwd_from:
        return
    mentions = "**Admins in this Channel**: \n"
    should_mention_admins = False
    reply_message = None
    pattern_match_str = event.pattern_match.group(1)
    if "m" in pattern_match_str:
        should_mention_admins = True
        if event.reply_to_msg_id:
            reply_message = await event.get_reply_message()
    input_str = event.pattern_match.group(2)
    to_write_chat = await event.get_input_chat()
    chat = None
    if not input_str:
        chat = to_write_chat
コード例 #19
0
ファイル: telegraph.py プロジェクト: mantulity/ironbot-reborn
from ironbot import CMD_HELP
from ironbot.utils import iron_on_cmd

telegraph = Telegraph()
r = telegraph.create_account(short_name=Config.TELEGRAPH_SHORT_NAME)
auth_url = r["auth_url"]

if Config.PRIVATE_GROUP_ID is None:
    BOTLOG = False
else:
    BOTLOG = True
    BOTLOG_CHATID = Config.PRIVATE_GROUP_ID


@iron.on(iron_on_cmd(pattern="telegraph (media|text) ?(.*)"))
async def _(event):
    if event.fwd_from:
        return
    if not os.path.isdir(Config.TMP_DOWNLOAD_DIRECTORY):
        os.makedirs(Config.TMP_DOWNLOAD_DIRECTORY)
    if BOTLOG:
        try:
            await borg.send_message(
                Config.PRIVATE_GROUP_ID,
                "Created New Telegraph account {} for the current session. \n**Do not give this url to anyone, even if they say they are from Telegram!**"
                .format(auth_url),
            )
        except:
            await borg.send_message(
                bot.uid,
コード例 #20
0
import asyncio

from telethon.errors.rpcerrorlist import YouBlockedUserError

from ironbot import CMD_HELP, bot
from ironbot.utils import iron_on_cmd


@iron.on(iron_on_cmd(pattern="songs ?(.*)"))
async def WooMai(netase):
    if netase.fwd_from:
        return
    song = netase.pattern_match.group(1)
    chat = "@WooMaiBot"
    link = f"/netease {song}"
    await netase.edit("```Getting Your Music```")
    async with bot.conversation(chat) as conv:
        await asyncio.sleep(2)
        await netase.edit("`Downloading...Please wait`")
        try:
            msg = await conv.send_message(link)
            response = await conv.get_response()
            respond = await conv.get_response()
            """ - don't spam notif - """
            await bot.send_read_acknowledge(conv.chat_id)
        except YouBlockedUserError:
            await netase.reply("```Please unblock @WooMaiBot and try again```")
            return
        await netase.edit("`Sending Your Music...`")
        await asyncio.sleep(3)
        await bot.send_file(netase.chat_id, respond)
コード例 #21
0
ファイル: get_id.py プロジェクト: mantulity/ironbot-reborn
"""Get ID of any Telegram media, or any user
Syntax: .get_id"""
from telethon.utils import pack_bot_file_id

from ironbot import CMD_HELP
from ironbot.utils import edit_or_reply, iron_on_cmd, sudo_cmd


@iron.on(iron_on_cmd("get_id"))
@iron.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.sender_id),
                        bot_api_file_id))
        else:
            await starkisgreat.edit(
                "Current Chat ID: `{}`\nFrom User ID: `{}`".format(
                    str(event.chat_id), str(r_msg.sender_id)))
    else:
        await starkisgreat.edit("Current Chat ID: `{}`".format(
            str(event.chat_id)))
コード例 #22
0
ファイル: warns.py プロジェクト: mantulity/ironbot-reborn
from ironbot.modules.sql_helper import warns_sql as sql
from ironbot.utils import iron_on_cmd
from ironbot import CMD_HELP

@iron.on(iron_on_cmd(pattern="warn(?: |$)(.*)"))
async def _s(event):
    if event.fwd_from:
        return
    if not event.is_group:
        await event.edit("This Command is Meant To Be Used in Chats/Groups")
        return
    user, reason = await get_user_from_event(event)
    sed = await iron.get_permissions(event.chat_id, user.id)
    if sed.is_admin:
        await event.edit("`Demn, Admins Can't Be Warned`")
        return
    dragon = await iron.get_permissions(event.chat_id, bot.uid)
    if not dragon.is_admin:
        await event.edit("`Demn, Me nOT Admin`")
        return
    limit, soft_warn = sql.get_warn_setting(event.chat_id)
    num_warns, reasons = sql.warn_user(user.id, event.chat_id, reason)
    if num_warns >= limit:
        sql.reset_warns(user.id, event.chat_id)
        if soft_warn:
            await iron.kick_participant(event.chat_id, user.id)
            reply = "{} warnings, {} has been kicked!".format(limit, user.id)
            await event.edit(reply)
        else:
            await iron.edit_permissions(event.chat_id, user.id, view_messages=False)
            reply = "{} warnings, {} has been banned!".format(
コード例 #23
0
ファイル: welcome.py プロジェクト: mantulity/ironbot-reborn
                current_saved_welcome_message.format(
                    mention=mention,
                    title=title,
                    count=count,
                    first=first,
                    last=last,
                    fullname=fullname,
                    username=username,
                    userid=userid,
                ),
                file=cws.media_file_id,
            )
            update_previous_welcome(event.chat_id, current_message.id)


@iron.on(iron_on_cmd(pattern="savewelcome"))
async def _(event):
    if event.fwd_from:
        return
    msg = await event.get_reply_message()
    if msg and msg.media:
        bot_api_file_id = pack_bot_file_id(msg.media)
        add_welcome_setting(event.chat_id, msg.message, True, 0,
                            bot_api_file_id)
        await event.edit("Welcome note saved. ")
    else:
        input_str = event.text.split(None, 1)
        add_welcome_setting(event.chat_id, input_str[1], True, 0, None)
        await event.edit("Welcome note saved. ")

コード例 #24
0
import io
import os
import random
import textwrap

from PIL import Image, ImageDraw, ImageFont
from telethon.tl.types import InputMessagesFilterDocument

from ironbot import CMD_HELP
from ironbot.utils import iron_on_cmd, sudo_cmd

# RegEx by https://t.me/c/1220993104/500653 ( @SnapDragon7410 )


@iron.on(iron_on_cmd(pattern="stcr ?(?:(.*?) \| )?(.*)", outgoing=True))
async def sticklet(event):
    if event.fwd_from:
        return
    R = random.randint(0, 256)
    G = random.randint(0, 256)
    B = random.randint(0, 256)
    reply_message = event.message
    # get the input text
    # the text on which we would like to do the magic on
    font_file_name = event.pattern_match.group(1)
    if not font_file_name:
        font_file_name = ""
    sticktext = event.pattern_match.group(2)
    if not sticktext and event.reply_to_msg_id:
        reply_message = await event.get_reply_message()
コード例 #25
0
ファイル: translate.py プロジェクト: mantulity/ironbot-reborn
from deep_translator import GoogleTranslator
from googletrans import LANGUAGES
from google_trans_new import google_translator
from langdetect import detect
import requests
from ironbot import CMD_HELP
from ironbot.utils import edit_or_reply, iron_on_cmd, sudo_cmd


@iron.on(iron_on_cmd("tr ?(.*)"))
@iron.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 "id"
    elif "|" in input_str:
        lan, text = input_str.split("|")
    else:
        await edit_or_reply(event,
                            "`.tr <Language-code>` as reply to a message")
        return

    lan = lan.strip()
    try:
        translator = google_translator()
コード例 #26
0
"""Remove.BG Plugin for @UniBorg
Syntax: .rmbg https://link.to/image.extension
Syntax: .rmbg as reply to a media"""
import io
import os
from datetime import datetime

import requests

from ironbot import CMD_HELP
from ironbot.utils import iron_on_cmd


@iron.on(iron_on_cmd("rmbg ?(.*)"))
async def _(event):
    HELP_STR = (
        "`.rmbg` as reply to a media, or give a link as an argument to this command"
    )
    if event.fwd_from:
        return
    if Config.REM_BG_API_KEY is None:
        await event.edit(
            "You need API token from remove.bg to use this plugin.")
        return False
    input_str = event.pattern_match.group(1)
    start = datetime.now()
    message_id = event.message.id
    if event.reply_to_msg_id:
        message_id = event.reply_to_msg_id
        reply_message = await event.get_reply_message()
        # check if media message
コード例 #27
0

class SubSubSection(SubSection):
    def __init__(self, *args: String, indent: int = 12) -> None:
        super().__init__(*args, indent=indent)


class TGDoc:
    def __init__(self, *args: Union[String, "Section"]) -> None:
        self.sections = args

    def __str__(self) -> str:
        return "\n\n".join([str(section) for section in self.sections])


@iron.on(iron_on_cmd(pattern=r"u(?:ser)?(\s+[\S\s]+|$)"))
async def who(event: NewMessage.Event):
    """ For .user command, get info about a user. """
    if event.fwd_from:
        return

    args, user = parse_arguments(
        event.pattern_match.group(1),
        ["id", "forward", "general", "bot", "misc", "all", "mention"],
    )

    args["forward"] = args.get("forward", True)
    args["user"] = user

    replied_user = await get_user_from_event(event, **args)
コード例 #28
0
.restart
.shutdown"""
# This Source Code Form is subject to the terms of the GNU
# General Public License, v.3.0. If a copy of the GPL was not distributed with this
# file, You can obtain one at https://www.gnu.org/licenses/gpl-3.0.en.html
import os
import sys
from ironbot.function.heroku_helper import HerokuHelper
from ironbot import CMD_HELP
from ironbot.utils import iron_on_cmd
import heroku3
import requests
Heroku = heroku3.from_key(Config.HEROKU_API_KEY)


@iron.on(iron_on_cmd("restart$"))
async def _(event):
    if event.fwd_from:
        return
    await event.edit(
        "**Restarted ! If You Want To Check If I am Alive, Do** `.ping` !")
    try:
        herokuHelper = HerokuHelper(Config.HEROKU_APP_NAME,
                                    Config.HEROKU_API_KEY)
        herokuHelper.restart()
    except:
        await borg.disconnect()
        os.execl(sys.executable, sys.executable, *sys.argv)


@iron.on(iron_on_cmd("shutdown$"))