def who_is(client, message): user_info = extract_args(message) reply = message.reply_to_message edit(message, f'`{get_translation("whoisProcess")}`') media_perm = True if 'group' in message.chat.type: perm = message.chat.permissions media_perm = perm.can_send_media_messages if user_info: try: reply_user = client.get_users(user_info) reply_chat = client.get_chat(user_info) except Exception: edit(message, f'`{get_translation("whoisError")}`') return elif reply: reply_user = client.get_users(reply.from_user.id) reply_chat = client.get_chat(reply.from_user.id) else: edit(message, f'`{get_translation("whoisError")}`') return if reply_user or reply_chat is not None: try: user_photo = reply_user.photo.big_file_id photo = download_media_wc(user_photo, 'photo.png') except BaseException: photo = None pass first_name = reply_user.first_name or get_translation('notSet') last_name = reply_user.last_name or get_translation('notSet') username = f'@{reply_user.username}' if reply_user.username else get_translation( 'notSet') user_id = reply_user.id photos = client.get_profile_photos_count(user_id) dc_id = reply_user.dc_id bot = reply_user.is_bot scam = reply_user.is_scam verified = reply_user.is_verified chats = len(client.get_common_chats(user_id)) bio = reply_chat.bio or get_translation('notSet') status = reply_user.status last_seen = LastSeen(bot, status) caption = get_translation('whoisResult', [ '**', '`', first_name, last_name, username, user_id, photos, dc_id, bot, scam, verified, chats, bio, last_seen ]) if photo and media_perm: reply_img(message, photo, caption=caption, delete_file=True, delete_orig=True) else: return edit(message, caption)
def meme_maker(message): args = extract_args(message).upper().split(',') reply = message.reply_to_message font = 'sedenecem/fonts/impact.ttf' if len(args) == 2: top, bottom = args[0], args[1] else: bottom = args[0 if args[1] == '' else 1] if (reply and reply.media and (reply.photo or (reply.sticker and not reply.sticker.is_animated) or (reply.document and 'image' in reply.document.mime_type))): media = download_media_wc(reply, f'{get_download_dir()}/image.jpg') image = Image.open(media) draw = ImageDraw.Draw(image) width, height = image.size estimated_font_size = find_font_size(''.join(args), font, image, 1) text_font = ImageFont.truetype(font, estimated_font_size) text_per_line = width // text_font.size top_text = wrap(top, width=(text_per_line + 5)) bottom_text = wrap(bottom, width=(text_per_line + 5)) y = 10 for text in top_text: text_width, text_height = text_font.getsize(text) x = (width - text_width) / 2 draw.text( (x, y), text, fill='white', font=text_font, stroke_width=3, stroke_fill='black', ) y += text_height y = height - text_height * len(bottom_text) - 15 for text in bottom_text: text_width, text_height = text_font.getsize(text) x = (width - text_width) / 2 draw.text( (x, y), text, fill='white', font=text_font, stroke_width=3, stroke_fill='black', ) y += text_height image.convert('RGB').save(media, 'JPEG') reply_img(reply or message, media, delete_file=True) message.delete() else: edit(message, 'Lütfen bir resim yanıtlayın.')
def deepfry(message): text = (message.text or message.caption).split(' ', 1) fry = parse_cmd(text[0]) == 'fry' try: frycount = int(text[1]) if frycount < 1: raise ValueError except BaseException: frycount = 1 MAX_LIMIT = 5 if frycount > MAX_LIMIT: frycount = MAX_LIMIT reply = message.reply_to_message if not reply and message.caption: reply = message if reply: data = check_media(reply) if not data: edit(message, f'`{get_translation("deepfryError")}`') return else: edit( message, get_translation('deepfryNoPic', ['`', f'{"f" if fry else "deepf"}ry']), ) return # Download Media edit(message, f'`{get_translation("deepfryDownload")}`') image_file = download_media_wc(reply, 'image.png') image = Image.open(image_file) remove(image_file) # Apply effect to media edit(message, get_translation('deepfryApply', ['`', f'{"" if fry else "deep"}'])) for _ in range(frycount): image = deepfry_media(image, fry) fried_io = open('image.jpeg', 'w+') image.save(fried_io, 'JPEG') fried_io.close() reply_img(reply or message, 'image.jpeg', delete_file=True) message.delete()
def show_users_detail( self, username, message, ): if username == None: return edit(message, (get_translation("invalidUsername"))) else: r = get(f"https://open.spotify.com/user/{username}") if r.status_code == 404: edit(message, get_translation("userNotFound", ['**', '`', username])) else: user = self.sp.user(username) profile_photo = [i['url'] for i in user['images']] if profile_photo: r = urlretrieve("".join(profile_photo), 'Spotify/pfp.png') else: profile_photo = None pass out = get_translation( 'spotifyResult', [ '**', '`', username, user['external_urls']['spotify'], self.show_playlist(username), counter, ], ) media_perm = True if message.chat.type in [ enums.ChatType.SUPERGROUP, enums.ChatType.GROUP, ]: perm = message.chat.permissions media_perm = perm.can_send_media_messages if profile_photo and media_perm: reply_img( message, photo='Spotify/pfp.png', caption=out, delete_file=True, delete_orig=True, ) else: edit(message, out, preview=False)
def deepfry(client, message): text = message.text.split(' ', 1) fry = parse_cmd(text[0])[:3] == 'fry' try: frycount = int(text[1]) if frycount < 1: raise ValueError except BaseException: frycount = 1 MAX_LIMIT = 5 if frycount > MAX_LIMIT: frycount = MAX_LIMIT reply = message.reply_to_message if reply: data = check_media(reply) if not data: edit(message, f'`{get_translation("deepfryError")}`') return else: edit( message, get_translation('deepfryNoPic', ['`', f'{"f" if fry else "deepf"}ry'])) return # Fotoğrafı (yüksek çözünürlük) bayt dizisi olarak indir edit(message, f'`{get_translation("deepfryDownload")}`') image_file = download_media(client, reply, 'image.png') image = Image.open(image_file) remove(image_file) # Resime uygula edit(message, get_translation('deepfryApply', ['`', f'{"" if fry else "deep"}'])) for _ in range(frycount): image = deepfry(image, fry) fried_io = open('image.jpeg', 'w+') image.save(fried_io, "JPEG") fried_io.close() reply_img(message, 'image.jpeg', delete_file=True)
def picspam(message): arr = extract_args_arr(message) if len(arr) < 2 or not arr[0].isdigit(): edit(message, f'`{get_translation("spamWrong")}`') return message.delete() if not spam_allowed(): return count = int(arr[0]) url = arr[1] for i in range(0, count): reply_img(message, url) limit = increment_spam_count() if not limit: break send_log(get_translation('picspamLog'))
def color(message): input_str = extract_args(message) if input_str.startswith('#'): try: usercolor = ImageColor.getrgb(input_str) except Exception as e: edit(message, str(e)) return False else: im = Image.new(mode='RGB', size=(1920, 1080), color=usercolor) im.save('sedencik.png', 'PNG') reply_img(message, 'sedencik.png', caption=input_str, delete_file=True, delete_orig=True) else: edit(message, f'`{get_translation("colorsUsage")}`')
def picspam(message): arr = extract_args_arr(message) if len(arr) < 2 or not arr[0].isdigit(): edit(message, f'`{get_translation("spamWrong")}`') return message.delete() if not spam_allowed(): return miktar = int(arr[0]) link = arr[1] for i in range(0, miktar): reply_img(message, link) count = increment_spam_count() if not count: break send_log(f'{get_translation("picspamLog")}')
def color(message): input_str = extract_args(message) message_id = message.chat.id if message.reply_to_message: message_id = message.reply_to_message if input_str.startswith('#'): try: usercolor = ImageColor.getrgb(input_str) except Exception as e: edit(message, str(e)) return False else: im = Image.new(mode='RGB', size=(1280, 720), color=usercolor) im.save('sedencik.png', 'PNG') input_str = input_str.replace('#', '#RENK_') reply_img(message, 'sedencik.png', caption=input_str) remove('sedencik.png') message.delete() else: edit(message, f'`{get_translation("colorsUsage")}`')
def who_is(client, message): find_user = extract_user(message) reply = message.reply_to_message media_perm = None edit(message, f'`{get_translation("whoisProcess")}`') if len(find_user) < 1: return edit(message, f'`{get_translation("banFailUser")}`') if message.chat.type in [enums.ChatType.SUPERGROUP, enums.ChatType.GROUP]: perm = message.chat.permissions media_perm = perm.can_send_media_messages for reply_user in find_user: try: reply_chat = client.get_chat(reply_user.id) except Exception: return edit(message, f'`{get_translation("whoisError")}`') if reply_user or reply_chat is not None: try: user_photo = reply_user.photo.big_file_id photo = download_media_wc(user_photo, 'photo.png') except BaseException: photo = None pass first_name = reply_user.first_name or get_translation('notSet') last_name = reply_user.last_name or get_translation('notSet') username = (f'@{reply_user.username}' if reply_user.username else get_translation('notSet')) user_id = reply_user.id photos = client.get_chat_photos_count(user_id) dc_id = reply_user.dc_id or get_translation('notSet') bot = reply_user.is_bot chats = len(client.get_common_chats(user_id)) premium = reply_user.is_premium bio = reply_chat.bio or get_translation('notSet') status = reply_user.status last_seen = LastSeen(bot, status) sudo = SudoCheck(user_id) blacklist = BlacklistCheck(user_id) caption = get_translation( 'whoisResult', [ '**', '`', first_name, last_name, username, user_id, photos, dc_id, chats, premium, bio, last_seen, sudo if sudo else '', blacklist if blacklist else '', ], ) if photo and media_perm: reply_img(reply or message, photo, caption=caption, delete_file=True) message.delete() else: return edit(message, caption)
def get_chat_info(client, message): args = extract_args(message) reply = message.reply_to_message chat_id = message.chat.id media_perm = None edit(message, f'`{get_translation("processing")}`') try: reply_chat = client.get_chat(args or chat_id) peer = client.resolve_peer(args or chat_id) except PeerIdInvalid: edit(message, f'`{get_translation("groupNotFound")}`') return if message.chat.type in [enums.ChatType.SUPERGROUP, enums.ChatType.GROUP]: perm = message.chat.permissions media_perm = perm.can_send_media_messages try: online_users = client.invoke(GetOnlines(peer=peer)) online = online_users.onlines except PeerIdInvalid: edit(message, f'`{get_translation("groupNotFound")}`') return try: group_photo = reply_chat.photo.big_file_id photo = download_media_wc(group_photo, 'photo.png') except BaseException: photo = None pass title = reply_chat.title or get_translation('notSet') username = (f'**@{reply_chat.username}**' if reply_chat.username else f'`{get_translation("notFound")}`') chat_id = reply_chat.id dc_id = reply_chat.dc_id or get_translation('notFound') group_type = reply_chat.type sticker_pack = ( f'**[Pack](https://t.me/addstickers/{reply_chat.sticker_set_name})**' if reply_chat.sticker_set_name else f'`{get_translation("notSet")}`') members = reply_chat.members_count description = (f'\n{reply_chat.description}' if reply_chat.description else get_translation('notSet')) caption = get_translation( 'groupinfoResult', [ '**', '`', title, chat_id, dc_id, group_type, members, online, sticker_pack, username, description, ], ) if photo and media_perm: reply_img(reply or message, photo, caption=caption, delete_file=True) message.delete() else: edit(message, caption, preview=False)
def speed_test(message): input_str = extract_args(message) as_text = False if input_str == 'text': as_text = True edit(message, f'`{get_translation("speedtest")}`') start = datetime.now() spdtst = Speedtest() spdtst.get_best_server() spdtst.download() spdtst.upload() end = datetime.now() ms = (end - start).microseconds / 1000 response = spdtst.results.dict() download_speed = response.get('download') upload_speed = response.get('upload') ping_time = response.get('ping') client_infos = response.get('client') i_s_p = client_infos.get('isp') i_s_p_rating = client_infos.get('isprating') try: response = spdtst.results.share() speedtest_image = response if as_text: edit( message, get_translation( 'speedtestResultText', [ '**', ms, convert_from_bytes(download_speed), convert_from_bytes(upload_speed), ping_time, i_s_p, i_s_p_rating, '', ], ), ) else: reply_img( message, speedtest_image, caption=get_translation('speedtestResultDoc', ['**', ms]), delete_file=True, delete_orig=True, ) except Exception as exc: edit( message, get_translation( 'speedtestResultText', [ '**', ms, convert_from_bytes(download_speed), convert_from_bytes(upload_speed), ping_time, i_s_p, i_s_p_rating, f'ERROR: {str(exc)}', ], ), )