Пример #1
0
async def main(packTitle, packAuthor, listofStick, coverStick):
    def add_sticker(path, emoji):

        stick = Sticker()
        stick.id = pack.nb_stickers
        stick.emoji = emoji

        with open(path, "rb") as f_in:
            stick.image_data = f_in.read()

        pack._addsticker(stick)

    pack = LocalStickerPack()

    # Set here the pack title and author
    pack.title = packTitle
    pack.author = packAuthor

    # Add the stickers here, with their emoji
    # Accepted format:
    # - Non-animated webp
    # - PNG
    # - GIF <100kb for animated stickers
    for i in listofStick:
        add_sticker(i, "🤪")

    # Specifying a cover is optionnal
    # By default, the first sticker is the cover
    cover = Sticker()
    cover.id = pack.nb_stickers
    # Set the cover file here
    with open(coverStick, "rb") as f_in:
        cover.image_data = f_in.read()
    pack.cover = cover

    # Instanciate the client with your Signal crendentials
    async with StickersClient('YOUR_SIGNAL_UID',
                              'YOUR_SIGNAL_PASSWORD') as client:
        # Upload the pack
        pack_id, pack_key = await client.upload_pack(pack)


# How to obtain your Signal credentials? In Signal Desktop, open the Developer Tools, and type
# window.reduxStore.getState().items.uuid_id to get your USER
# and  window.reduxStore.getState().items.password to get your PASSWORD.

    print(
        "Pack uploaded!\n\nhttps://signal.art/addstickers/#pack_id={}&pack_key={}"
        .format(pack_id, pack_key))
    link = {
        "link":
        "https://signal.art/addstickers/#pack_id={}&pack_key={}".format(
            pack_id, pack_key)
    }

    response = app.response_class(response=json.dumps(link),
                                  status=200,
                                  mimetype='application/json')
    return response
Пример #2
0
async def main():
    def add_sticker(path, emoji):

        stick = Sticker()
        stick.id = pack.nb_stickers
        stick.emoji = emoji

        with open(path, "rb") as f_in:
            stick.image_data = f_in.read()

        pack._addsticker(stick)

    pack = LocalStickerPack()
    f = open("token", "r")
    token = f.readline().split("\n")[0]
    author = f.readline().split("\n")[0]
    uuid = f.readline().split("\n")[0]
    password = f.readline().split("\n")[0]
    pack.author = author
    bot = Bot(token)
    f = open("pack", "r")
    text = f.read()

    sticker_name = ""
    try:
        sticker_name = text.split("/addstickers/")[1]
    except:
        sticker_name = text.split("eu/stickers/")[1]
    sticker_set = bot.getStickerSet(sticker_name)
    pack.title = sticker_set.name
    ww = 0
    emoji = open("emoji", "r")
    for i in sticker_set.stickers:
        emoji_i = emoji.readline().split("\n")[0]
        file = "output/" + str(ww) + ".png"
        add_sticker(file, emoji_i)
        #      print (file + " corresponds to " + emoji_i)
        ww = ww + 1
    # Specifying a cover is optional
    # Instanciate the client with your Signal crendentials
    print("-->")
    print("Final stage Uploading is gonna start now!!!!!")
    print("token  =" + token)
    print("author =" + author)
    print("uuid (DO NOT SHARE)=" + uuid)
    print("password (DO NOT SHARE)=" + password)
    print("Pack name = " + pack.title)
    print("-->")
    ff = open("packs", "a+")
    async with StickersClient(uuid, password) as client:
        pack_id, pack_key = await client.upload_pack(pack)
    print(
        "Pack uploaded!\n\nhttps://signal.art/addstickers/#pack_id={}&pack_key={}"
        .format(pack_id, pack_key))
    ff.write("### Pack = " + pack.title +
             "\n\nhttps://signal.art/addstickers/#pack_id={}&pack_key={}".
             format(pack_id, pack_key) + "\n---\n")
    ff.close()
Пример #3
0
async def main():
    def add_sticker(path, emoji):

        stick = Sticker()
        stick.id = pack.nb_stickers
        stick.emoji = emoji

        with open(path, "rb") as f_in:
            stick.image_data = f_in.read()

        pack._addsticker(stick)

    pack = LocalStickerPack()
    pack.title = sys.argv[1]
    pack.author = sys.argv[2]
    uuid = sys.argv[3]
    password = sys.argv[4]
    filemoji = sys.argv[5]
    location = sys.argv[6]
    start = int(sys.argv[7])
    end = int(sys.argv[8])
    emoji = open(filemoji, "r")
    emojidata = emoji.readlines()
    # print(pack.title,pack.author,uuid,password,filemoji,location,start,emoji)
    ww = start
    while ww < end:
        emoji_i = emojidata[ww].split("\n")[0]
        file = location + str(ww) + ".png"
        add_sticker(file, emoji_i)
        print(file + " corresponds to " + emoji_i)
        ww = ww + 1
    # Specifying a cover is optional
    # Instanciate the client with your Signal crendentials
    print("-->")
    print("uuid =" + uuid + "")
    print("password ="******"-->")
    print("Final stage Uploading is gonna start now!!!!!")
    print("author =" + pack.author)
    print("Pack name = " + pack.title)
    print("-->")
    ff = open("packs", "a+")
    try:
        async with StickersClient(uuid, password) as client:
            pack_id, pack_key = await client.upload_pack(pack)
        print(
            "Pack uploaded!\n\nhttps://signal.art/addstickers/#pack_id={}&pack_key={}"
            .format(pack_id, pack_key))
    except:
        exit(12)
    ff.write("### Pack = " + pack.title +
             "\n\nhttps://signal.art/addstickers/#pack_id={}&pack_key={}".
             format(pack_id, pack_key) + "\n---\n")
    ff.close()
Пример #4
0
async def upload_pack(stickerly_pack_id, pack_name, pack_author):
    def add_sticker(path, emoji):
        stick = Sticker()
        stick.id = pack.nb_stickers
        stick.emoji = emoji

        with open(path, "rb") as f_in:
            stick.image_data = f_in.read()

        pack._addsticker(stick)

    pack = LocalStickerPack()

    pack.title = pack_name
    pack.author = pack_author

    # Add the stickers here, with their emoji
    # Accepted format:
    # - Non-animated webp
    # - PNG
    # - GIF <100kb for animated stickers
    images = os.listdir(f"res/{stickerly_pack_id}")
    for image_name in images:
        add_sticker(f"res/{stickerly_pack_id}/{image_name}", "🤪")

    # Specifying a cover is optional
    # By default, the first sticker is the cover
    cover = Sticker()
    cover.id = pack.nb_stickers
    # Set the cover file here
    with open(f"res/{stickerly_pack_id}/{images[0]}", "rb") as f_in:
        cover.image_data = f_in.read()
    pack.cover = cover
    print("downloaded all stickers!")

    # Instantiate the client with your Signal credentials
    user_id = open("user-id.txt", "r").read()
    password = open("password.txt", "r").read()
    print("\nuploading pack...")
    async with StickersClient(user_id, password) as client:
        # Upload the pack
        pack_id, pack_key = await client.upload_pack(pack)

    with open(
            "res/" + stickerly_pack_id + "/" + stickerly_pack_id +
            "_signal.txt", "w") as f:
        f.write(
            f"https://signal.art/addstickers/#pack_id={pack_id}&pack_key={pack_key}"
        )
    print(
        f"\nPack uploaded!\nhttps://signal.art/addstickers/#pack_id={pack_id}&pack_key={pack_key}"
    )
Пример #5
0
async def add_tg_sticker(tg_client,
                         signal_pack: signal_models.LocalStickerPack,
                         sticker_id: int, tg_sticker):
    signal_sticker = signal_models.Sticker()
    signal_sticker.id = sticker_id
    signal_sticker.emoji = next(
        attr for attr in tg_sticker.attributes
        if isinstance(attr, tl.types.DocumentAttributeSticker)).alt

    logger.debug('Downloading %s', signal_sticker.emoji)
    data = io.BytesIO()
    async for chunk in tg_client.iter_download(tg_sticker):
        data.write(chunk)
    data.seek(0)
    logger.debug('Downloaded %s', signal_sticker.emoji)

    if tg_sticker.mime_type == 'application/x-tgsticker':
        logger.debug('Converting %s to APNG', signal_sticker.emoji)
        image_data = await convert_tgs_to_apng(data)
    elif tg_sticker.mime_type == 'image/webp':
        image_data = data
    else:
        raise RuntimeError('unexpected image type', tg_sticker.mime_type,
                           'found in pack')

    signal_sticker.image_data = image_data.getvalue()

    signal_pack.stickers[sticker_id] = signal_sticker
async def main():

    # List of signal.art packs urls
    packs = [
        "https://signal.art/addstickers/#pack_id=FIXME&pack_key=FIXME",
        "https://signal.art/addstickers/#pack_id=FIXME&pack_key=FIXME",
        "https://signal.art/addstickers/#pack_id=FIXME&pack_key=FIXME",
        "https://signal.art/addstickers/#pack_id=FIXME&pack_key=FIXME",
        "https://signal.art/addstickers/#pack_id=FIXME&pack_key=FIXME",
    ]

    new_pack = LocalStickerPack()
    new_pack.title = 'My new combo pack!'
    new_pack.author = "Romain Ricard"

    id_offset = 0

    for pack_url in packs:
        pack_info = parse_qs(urlparse(pack_url).fragment)
        async with StickersClient() as client:
            old_pack = await client.get_pack(pack_info["pack_id"][0],
                                             pack_info["pack_key"][0])

        nb_stickers = 0
        for sticker in old_pack.stickers:

            if sticker.image_data:  # Sometimes, stickers are HTTP 403 for... reasons
                nb_stickers += 1
                new_stick = Sticker()
                new_stick.id = sticker.id + id_offset
                new_stick.emoji = sticker.emoji
                new_stick.image_data = sticker.image_data
                new_pack._addsticker(new_stick)

        id_offset += nb_stickers

    async with StickersClient(os.environ['SIGNAL_USER'],
                              os.environ['SIGNAL_PASS']) as client:
        # Upload the pack
        pack_id, pack_key = await client.upload_pack(new_pack)

    print(
        "Pack uploaded!\nhttps://signal.art/addstickers/#pack_id={}&pack_key={}"
        .format(pack_id, pack_key))
    print("\nPreview\nhttps://signalstickers.com/pack/{}?key={}".format(
        pack_id, pack_key))
Пример #7
0
from signalstickers_client.models import LocalStickerPack, Sticker


def add_sticker(path, emoji):

    stick = Sticker()
    stick.id = pack.nb_stickers
    stick.emoji = emoji

    with open(path, "rb") as f_in:
        stick.image_data = f_in.read()

    pack._addsticker(stick)


pack = LocalStickerPack()

# Set here the pack title and author
pack.title = 'Hello world!'
pack.author = "Romain Ricard"

# Add the stickers here, with their emoji
# Accepted format:
# - Non-animated webp
# - PNG
# - GIF <100kb for animated stickers

add_sticker("/tmp/1.webp", "🤪")
add_sticker("/tmp/2.gif", "�")

# Specifying a cover is optionnal
Пример #8
0
async def main():
    def add_sticker(path, emoji):

        stick = Sticker()
        stick.id = pack.nb_stickers
        stick.emoji = emoji

        with open(path, "rb") as f_in:
            stick.image_data = f_in.read()

        pack._addsticker(stick)

    def give_name(name, count, done):
        if count == 1:
            return name
        return name + " Part " + str((done + 1))

    f = open("token", "r")
    token = f.readline().split("\n")[0]
    author = f.readline().split("\n")[0]
    uuid = f.readline().split("\n")[0]
    password = f.readline().split("\n")[0]
    f = open("pack", "r")
    text = f.read()
    sticker_name = ""
    emoji = open("emoji", "r")
    try:
        sticker_name = text.split("/addstickers/")[1]
    except:
        sticker_name = text.split("eu/stickers/")[1]
    bot = Bot(token)
    sticker_set = bot.getStickerSet(sticker_name)
    length = len(sticker_set.stickers)
    chunk = 100
    totalloop = math.ceil(length / chunk)
    doneloop = 0
    while totalloop - doneloop > 0:
        pack = LocalStickerPack()
        pack.author = author
        pack.title = give_name(sticker_set.name, totalloop, doneloop)
        ww = chunk * doneloop
        i = 0
        while i < chunk:
            totalfile = (chunk * doneloop) + i
            if totalfile == length:
                break
            emoji_i = emoji.readline().split("\n")[0]
            file = "result/" + str(ww) + ".png"
            add_sticker(file, emoji_i)
            print(file + " corresponds to " + emoji_i)
            ww = ww + 1
            i = i + 1
    # Specifying a cover is optional
    # Instanciate the client with your Signal crendentials
        print("-->")
        print("Final stage Uploading is gonna start now!!!!!")
        print("token  =" + token)
        print("author =" + author)
        print("uuid (DO NOT SHARE)=" + uuid)
        print("password (DO NOT SHARE)=" + password)
        print("Pack name = " + pack.title)
        print("-->")
        ff = open("packs", "a+")
        async with StickersClient(uuid, password) as client:
            pack_id, pack_key = await client.upload_pack(pack)
        print(
            "Pack uploaded!\n\nhttps://signal.art/addstickers/#pack_id={}&pack_key={}"
            .format(pack_id, pack_key))
        ff.write("### Pack = " + pack.title +
                 "\n\nhttps://signal.art/addstickers/#pack_id={}&pack_key={}".
                 format(pack_id, pack_key) + "\n---\n")
        ff.close()
        doneloop = doneloop + 1