def meme(bot, update): filename = datetime.now().strftime("%d%m%y-%H%M%S%f") if len(update.message.photo) > 0: args = update.message.caption.split(" ") else: args = update.message.text.split(" ") args = args[1:] if len(args) < 1: update.message.reply_text("Type in some text!") return font = fonts_dict["impact"] for i in fonts_dict: if "-" + i in args[0] or "-" + i[0] in args[0]: font = fonts_dict[i] args = args[1:] break if len(args) < 1: update.message.reply_text("Type in some text!") return initial_text = " ".join(args) split_text = initial_text.split("@", maxsplit=1) update.message.chat.send_action(ChatAction.UPLOAD_PHOTO) try: extension = get_image(bot, update, path, filename) except IndexError as e: update.message.reply_text("Can't get the image! :(") return if extension not in extensions: update.message.reply_text("Unsupported file, onii-chan!") return top_text, bottom_text = text_format(update, split_text) make_meme(top_text, bottom_text, filename, extension, path, font) update.message.chat.send_action(ChatAction.UPLOAD_PHOTO) send_image(update, path, filename + "-meme", extension) os.remove(path + filename + extension) os.remove(path + filename + "-meme" + extension)
def nyameme(update, context): filename = datetime.now().strftime("%d%m%y-%H%M%S%f") update.message.chat.send_action(ChatAction.UPLOAD_PHOTO) font, args = get_font(context.args) meme_text = get_text(update, args) top_text, bottom_text = text_split(meme_text) random_image = random.choice(files) filename = random_image.split(".")[0] extension = "." + random_image.split(".")[1] if extension not in extensions: update.message.reply_text("Unexpected error") return shutil.copy(nyapath + random_image, path + random_image) update.message.chat.send_action(ChatAction.UPLOAD_PHOTO) make_meme(top_text, bottom_text, filename, extension, path, font) with open(path + filename + "-meme" + extension, "rb") as f: update.message.reply_photo(f) os.remove(path + filename + extension) os.remove(path + filename + "-meme" + extension) return
def animeme(update, context): filename = datetime.now().strftime("%d%m%y-%H%M%S%f") update.message.chat.send_action(ChatAction.UPLOAD_PHOTO) font, args = get_font(context.args) meme_text = get_text(update, args) top_text, bottom_text = text_split(meme_text) _, _, sample_link = get_image("rating:safe", yandere_request_link, "") extension = "." + sample_link.split(".")[-1] if extension not in extensions: update.message.reply_text("Unexpected error") return response = requests.get(sample_link, proxies=proxies) with open(path + filename + extension, "wb") as img: img.write(response.content) update.message.chat.send_action(ChatAction.UPLOAD_PHOTO) make_meme(top_text, bottom_text, filename, extension, path, font) with open(path + filename + "-meme" + extension, "rb") as f: update.message.reply_photo(f) os.remove(path + filename + extension) os.remove(path + filename + "-meme" + extension) return