async def ecpcmd(self, gpic): """Команда .ecp изменяет картинку чата.\nИспользование: .ecp <реплай на картинку/стикер>.""" if gpic.chat: try: reply = await gpic.get_reply_message() chat = await gpic.get_chat() if not chat.admin_rights and not chat.creator: return await utils.answer(gpic, self.strings('not_admin', gpic)) if reply: pic = await check_media(gpic, reply) if not pic: return await utils.answer( gpic, self.strings('not_pic', gpic)) else: return await utils.answer(gpic, self.strings('no_reply', gpic)) await utils.answer(gpic, self.strings('wait', gpic)) what = resizepic(pic) if what: try: await gpic.client( EditPhotoRequest( gpic.chat_id, await gpic.client.upload_file(what))) except PhotoCropSizeSmallError: return await utils.answer( gpic, self.strings('pic_so_small', gpic)) await utils.answer(gpic, self.strings('pic_changed', gpic)) except: return await utils.answer(gpic, self.strings('no_rights', gpic)) else: return await utils.answer(gpic, self.strings('this_isn`t_a_chat', gpic))
async def ecpcmd(self, gpic): """Command .ecp changes the pic of the chat.\nUse: .ecp <reply to pic/sticker>.""" if gpic.chat: try: reply = await gpic.get_reply_message() chat = await gpic.get_chat() if not chat.admin_rights and not chat.creator: return await utils.answer(gpic, self.strings('not_admin', gpic)) if reply: pic = await check_media(gpic, reply) if not pic: return await utils.answer(gpic, self.strings('not_pic', gpic)) else: return await utils.answer(gpic, self.strings('no_reply', gpic)) await utils.answer(gpic, self.strings('wait', gpic)) what = resizepic(pic) if what: try: await gpic.client(EditPhotoRequest(gpic.chat_id, await gpic.client.upload_file(what))) except PhotoCropSizeSmallError: return await utils.answer(gpic, self.strings('pic_so_small', gpic)) await utils.answer(gpic, self.strings('pic_changed', gpic)) except ChatAdminRequiredError: return await utils.answer(gpic, self.strings('no_rights', gpic)) else: return await utils.answer(gpic, self.strings('this_isn`t_a_chat', gpic))
async def set_group_photo(gpic): """ .setgpic komutu ile grubunuzun fotoğrafını değiştirebilirsiniz """ if not gpic.is_group: await gpic.edit("`Bunun bir grup olduğunu sanmıyorum.`") return replymsg = await gpic.get_reply_message() chat = await gpic.get_chat() admin = chat.admin_rights creator = chat.creator photo = None if not admin and not creator: await gpic.edit(NO_ADMIN) return if replymsg and replymsg.media: if isinstance(replymsg.media, MessageMediaPhoto): photo = await gpic.client.download_media(message=replymsg.photo) elif "image" in replymsg.media.document.mime_type.split('/'): photo = await gpic.client.download_file(replymsg.media.document) else: await gpic.edit(INVALID_MEDIA) if photo: try: await gpic.client( EditPhotoRequest(gpic.chat_id, await gpic.client.upload_file(photo))) await gpic.edit(CHAT_PP_CHANGED) except PhotoCropSizeSmallError: await gpic.edit(PP_TOO_SMOL) except ImageProcessFailedError: await gpic.edit(PP_ERROR)
async def group_image(context): """ Sets image of a group. """ if not context.text[0].isalpha() and context.text[0] not in ("/", "#", "@", "!"): reply_msg = await context.get_reply_message() chat = await context.get_chat() photo = None if not chat.admin_rights or not chat.creator: await context.edit("`Lacking permissions to edit group image.`") return if reply_msg and reply_msg.media: if isinstance(reply_msg.media, MessageMediaPhoto): photo = await bot.download_media(message=reply_msg.photo) elif "image" in reply_msg.media.document.mime_type.split('/'): photo = await bot.download_file(reply_msg.media.document) else: await context.edit("`Unable to parse attachment.`") if photo: try: EditPhotoRequest(context.chat_id, await bot.upload_file(photo)) await context.edit("`Group image updated.`") except PhotoCropSizeSmallError: await context.edit( "`Image dimensions smaller than minimum requirements.`") except ImageProcessFailedError: await context.edit("`Failed to process image.`")
async def set_group_photo(gpic): """ For .setgpic command, changes the picture of a group """ if not gpic.is_group: await gpic.edit("`I don't think this is a group.`") return replymsg = await gpic.get_reply_message() chat = await gpic.get_chat() admin = chat.admin_rights creator = chat.creator photo = None if not admin and not creator: await gpic.edit(NO_ADMIN) return if replymsg and replymsg.media: if isinstance(replymsg.media, MessageMediaPhoto): photo = await gpic.client.download_media(message=replymsg.photo) elif "image" in replymsg.media.document.mime_type.split('/'): photo = await gpic.client.download_file(replymsg.media.document) else: await gpic.edit(INVALID_MEDIA) if photo: try: await gpic.client( EditPhotoRequest(gpic.chat_id, await gpic.client.upload_file(photo))) await gpic.edit(CHAT_PP_CHANGED) except PhotoCropSizeSmallError: await gpic.edit(PP_TOO_SMOL) except ImageProcessFailedError: await gpic.edit(PP_ERROR) if BOTLOG: await gpic.client.send_message( BOTLOG_CHATID, "#GROUPPIC\n" f"Group profile pic changed " f"CHAT: {gpic.chat.title}(`{gpic.chat_id}`)")
async def set_group_photo(e): """ For .setchatpic command, changes the picture of a chat """ replymsg = await e.get_reply_message() chat = await e.get_chat() photo = None if not chat.admin_rights or chat.creator: await e.edit(NO_ADMIN) return if replymsg and replymsg.media: if isinstance(replymsg.media, MessageMediaPhoto): photo = await bot.download_media(message=replymsg.photo) elif "image" in replymsg.media.document.mime_type.split('/'): photo = await bot.download_file(replymsg.media.document) else: await e.edit(INVALID_MEDIA) if photo: try: e.client(EditPhotoRequest(e.chat_id, await bot.upload_file(photo))) await e.edit(CHAT_PP_CHANGED) except PhotoCropSizeSmallError: await e.edit(PP_TOO_SMOL) except ImageProcessFailedError: await e.edit(PP_ERROR)
async def set_group_photo(gpic): """ Команда .setgpic изменяет картинку группы""" if not gpic.is_group: await gpic.edit("`Я не думаю, что это группа.`") return replymsg = await gpic.get_reply_message() chat = await gpic.get_chat() admin = chat.admin_rights creator = chat.creator photo = None if not admin and not creator: await gpic.edit(NO_ADMIN) return if replymsg and replymsg.media: if isinstance(replymsg.media, MessageMediaPhoto): photo = await gpic.client.download_media(message=replymsg.photo) elif "image" in replymsg.media.document.mime_type.split('/'): photo = await gpic.client.download_file(replymsg.media.document) else: await gpic.edit(INVALID_MEDIA) if photo: try: await gpic.client( EditPhotoRequest(gpic.chat_id, await gpic.client.upload_file(photo))) await gpic.edit(CHAT_PP_CHANGED) except PhotoCropSizeSmallError: await gpic.edit(PP_TOO_SMOL) except ImageProcessFailedError: await gpic.edit(PP_ERROR)
async def profile_photo(ppht): if not ppht.text[0].isalpha() and ppht.text[0] not in ("/", "#", "@", "!"): message = await ppht.get_reply_message() photo = None if message.media: if isinstance(message.media, MessageMediaPhoto): photo = message.photo photo = await bot.download_media(message=photo) elif isinstance(message.media, MessageMediaDocument): if message.media.document.mime_type in ["image/jpeg", "image/png"]: photo = message.media.document photo = await bot.download_file(photo, file="propic.jpeg") photo = io.BytesIO(photo) photo.name = "image.jpeg" # small hack for documents images else: await ppht.edit(INVALID_MEDIA) if photo: file = await bot.upload_file(photo) try: await bot(EditPhotoRequest(e.chat_id, file)) await ppht.edit(CHAT_PP_CHANGED) except Exception as exc: if isinstance(exc, PhotoCropSizeSmallError): await ppht.edit(PP_TOO_SMOL) elif isinstance(exc, ImageProcessFailedError): await ppht.edit(PP_ERROR) else: await ppht.edit(CHAT_PP_ERROR)
async def set_group_photo(gpic): replymsg = await gpic.get_reply_message() chat = await gpic.get_chat() photo = None if gpic.is_group: if not await can_change_info(message=gpic): return else: return if replymsg and replymsg.media: if isinstance(replymsg.media, MessageMediaPhoto): photo = await tbot.download_media(message=replymsg.photo) elif "image" in replymsg.media.document.mime_type.split('/'): photo = await tbot.download_file(replymsg.media.document) else: await gpic.reply(INVALID_MEDIA) if photo: try: await tbot( EditPhotoRequest(gpic.chat_id, await tbot.upload_file(photo))) await gpic.reply(CHAT_PP_CHANGED) except PhotoCropSizeSmallError: await gpic.reply(PP_TOO_SMOL) except ImageProcessFailedError: await gpic.reply(PP_ERROR) except: await gpic.reply("Failed to set group pic.")
async def setgrouppic(eventPic): if not eventPic.text[0].isalpha() and eventPic.text[0] not in ("/", "#", "@", "!"): if eventPic.reply_to_msg_id: replymsg = await eventPic.get_reply_message() chat = await eventPic.get_chat() admin = chat.admin_rights creator = chat.creator photo = None if not admin and not creator: await eventPic.edit("`I am not an admin!`") return if replymsg and replymsg.media: if isinstance(replymsg.media, MessageMediaPhoto): photo = await eventPic.client.download_media(message=replymsg.photo) elif "image" in replymsg.media.document.mime_type.split('/'): photo = await eventPic.client.download_file(replymsg.media.document) else: await eventPic.edit("`Invalid Extension`") if photo: try: await eventPic.client(EditPhotoRequest( eventPic.chat_id, await eventPic.client.upload_file(photo) )) await eventPic.edit("`Chat Picture Changed`") except PhotoCropSizeSmallError: await eventPic.edit("`The image is too small`") except ImageProcessFailedError: await eventPic.edit("`Failure while processing the image`") else: await eventPic.edit("`Reply .setgrouppic to an Image to set it as group's icon.`")
async def set_group_photo(gpic): if not gpic.is_group: await gpic.edit("`Mohon Lakukan Perintah Ini Di Grup.`") return replymsg = await gpic.get_reply_message() chat = await gpic.get_chat() admin = chat.admin_rights creator = chat.creator photo = None if not admin and not creator: return await gpic.edit(NO_ADMIN) if replymsg and replymsg.media: await gpic.edit("`Mengubah Profil Grup`") if isinstance(replymsg.media, MessageMediaPhoto): photo = await gpic.client.download_media(message=replymsg.photo) elif "image" in replymsg.media.document.mime_type.split("/"): photo = await gpic.client.download_file(replymsg.media.document) else: await gpic.edit(INVALID_MEDIA) if photo: try: await gpic.client( EditPhotoRequest(gpic.chat_id, await gpic.client.upload_file(photo))) await gpic.edit(CHAT_PP_CHANGED) except PhotoCropSizeSmallError: await gpic.edit(PP_TOO_SMOL) except ImageProcessFailedError: await gpic.edit(PP_ERROR)
async def handle_matrix_avatar(self, sender: 'u.User', url: ContentURI) -> None: if self.peer_type not in ("chat", "channel"): # Invalid peer type return file = await self.main_intent.download_media(url) mime = magic.from_buffer(file, mime=True) ext = sane_mimetypes.guess_extension(mime) uploaded = await sender.client.upload_file(file, file_name=f"avatar{ext}") photo = InputChatUploadedPhoto(file=uploaded) if self.peer_type == "chat": response = await sender.client( EditChatPhotoRequest(chat_id=self.tgid, photo=photo)) else: channel = await self.get_input_entity(sender) response = await sender.client( EditPhotoRequest(channel=channel, photo=photo)) self.dedup.register_outgoing_actions(response) for update in response.updates: is_photo_update = (isinstance(update, UpdateNewMessage) and isinstance(update.message, MessageService) and isinstance(update.message.action, MessageActionChatEditPhoto)) if is_photo_update: loc, size = self._get_largest_photo_size( update.message.action.photo) self.photo_id = f"{size.location.volume_id}-{size.location.local_id}" self.save() break
async def oturumacvebotlogolustur(stri, aid, ahash): try: Client = TelegramClient(StringSession(stri), aid, ahash) await Client.start() ms = await Client.send_message('me', LANG['SIRIUSERBOT']) KanalId = await Client( CreateChannelRequest(title='SiriUserBot BotLog', about=LANG['AUTO_BOTLOG'], megagroup=True)) KanalId = KanalId.chats[0].id Photo = await Client.upload_file(file='20210701_125852.jpg') await Client(EditPhotoRequest(channel=KanalId, photo=Photo)) msg = await Client.send_message(KanalId, LANG['DONT_LEAVE']) await msg.pin() KanalId = str(KanalId) if "-100" in KanalId: return KanalId else: return "-100" + KanalId except: KanalId = 'err' return KanalId
async def set_group_photo(gpic): """ For .setgrouppic command, changes the picture of a group """ if not gpic.text[0].isalpha() and gpic.text[0] not in ("/", "#", "@", "!"): replymsg = await gpic.get_reply_message() chat = await gpic.get_chat() admin = chat.admin_rights creator = chat.creator photo = None if not admin and not creator: await gpic.edit(NO_ADMIN) return if replymsg and replymsg.media: if isinstance(replymsg.media, MessageMediaPhoto): photo = await gpic.client.download_media(message=replymsg.photo ) elif "image" in replymsg.media.document.mime_type.split('/'): photo = await gpic.client.download_file(replymsg.media.document ) else: await gpic.edit(INVALID_MEDIA) if photo: try: await gpic.client( EditPhotoRequest(gpic.chat_id, await gpic.client.upload_file(photo))) await gpic.edit(CHAT_PP_CHANGED) except PhotoCropSizeSmallError: await gpic.edit(PP_TOO_SMOL) except ImageProcessFailedError: await gpic.edit(PP_ERROR)
async def _(ult): if not ult.is_reply: return await ult.eor("`Reply to a Media..`", time=5) match = ult.pattern_match.group(1) if not ult.client._bot and match: try: chat = await ult.client.parse_id(match) except Exception as ok: return await ult.eor(str(ok)) else: chat = ult.chat_id reply_message = await ult.get_reply_message() if reply_message.media: replfile = await reply_message.download_media() else: return await ult.eor("Reply to a Photo or Video..") file = await ult.client.upload_file(replfile) mediain = mediainfo(reply_message.media) try: if "pic" not in mediain: file = types.InputChatUploadedPhoto(video=file) await ult.client(EditPhotoRequest(chat, file)) await ult.eor("`Group Photo has Successfully Changed !`", time=5) except Exception as ex: await ult.eor("Error occured.\n`{}`".format(str(ex)), time=5) os.remove(replfile)
async def profile_photo(ppht): if not ppht.text[0].isalpha() and ppht.text[0] not in ("/", "#", "@", "!"): message = await ppht.get_reply_message() photo = None chat = await ppht.get_chat() if not chat.admin_rights or chat.creator: await ppht.edit("`You aren't an admin!`") return if message.media: if isinstance(message.media, MessageMediaPhoto): photo = await bot.download_media(message=message.photo) elif isinstance(message.media, MessageMediaDocument): if message.media.document.mime_type in [ "image/jpeg", "image/png" ]: photo = await bot.download_file(message.media.document) else: await ppht.edit(INVALID_MEDIA) if photo: file = await bot.upload_file(photo) try: await bot(EditPhotoRequest(ppht.chat_id, file)) await ppht.edit(CHAT_PP_CHANGED) except Exception as exc: if isinstance(exc, PhotoCropSizeSmallError): await ppht.edit(PP_TOO_SMOL) elif isinstance(exc, ImageProcessFailedError): await ppht.edit(PP_ERROR) else: await ppht.edit(CHAT_PP_ERROR)
async def set_group_photo(gpic): """ For .setgpic command, changes the picture of a group """ if not gpic.is_group: await gpic.eor(event, "`I don't think this is a group.`") return replymsg = await gpic.get_reply_message() chat = await gpic.get_chat() admin = chat.admin_rights creator = chat.creator photo = None if not admin and not creator: x = await gpic.eor(x, NO_ADMIN) return if replymsg and replymsg.media: if isinstance(replymsg.media, MessageMediaPhoto): photo = await gpic.client.download_media(message=replymsg.photo) elif "image" in replymsg.media.document.mime_type.split("/"): photo = await gpic.client.download_file(replymsg.media.document) else: x = await gpic.eor(x, INVALID_MEDIA) if photo: try: await gpic.client( EditPhotoRequest(gpic.chat_id, await gpic.client.upload_file(photo)) ) x = await gpic.eor(x, CHAT_PP_CHANGED) except PhotoCropSizeSmallError: x = await gpic.eor(x, PP_TOO_SMOL) except ImageProcessFailedError: x = await gpic.eor(x, PP_ERROR)
async def _(ult): if not ult.is_reply: return await ult.eor("`Reply to a Media..`", time=5) match = ult.pattern_match.group(1).strip() if not ult.client._bot and match: try: chat = await ult.client.parse_id(match) except Exception as ok: return await ult.eor(str(ok)) else: chat = ult.chat_id reply = await ult.get_reply_message() if reply.photo or reply.sticker or reply.video: replfile = await reply.download_media() elif reply.document and reply.document.thumbs: replfile = await reply.download_media(thumb=-1) else: return await ult.eor("Reply to a Photo or Video..") mediain = mediainfo(reply.media) if "animated" in mediain: replfile = await con.convert(replfile, convert_to="mp4") else: replfile = await con.convert(replfile, outname="chatphoto", allowed_formats=["jpg", "png", "mp4"]) file = await ult.client.upload_file(replfile) try: if "pic" not in mediain: file = types.InputChatUploadedPhoto(video=file) await ult.client(EditPhotoRequest(chat, file)) await ult.eor("`Group Photo has Successfully Changed !`", time=5) except Exception as ex: await ult.eor("Error occured.\n`{}`".format(str(ex)), time=5) os.remove(replfile)
async def profile_photo(e): if not e.text[0].isalpha(): message = await e.get_reply_message() photo = None if message.media: if isinstance(message.media, MessageMediaPhoto): photo = message.photo photo = await bot.download_media(message=photo) elif isinstance(message.media, MessageMediaDocument): if message.media.document.mime_type in [ 'image/jpeg', 'image/png' ]: photo = message.media.document photo = await bot.download_file(photo, file="propic.jpeg") photo = io.BytesIO(photo) photo.name = 'image.jpeg' # small hack for documents images else: await e.edit( '```The extension of the media entity is invalid.```') if photo: file = await bot.upload_file(photo) try: await bot(EditPhotoRequest(e.chat_id, file)) await e.edit('```Chat Picture Changed```') except Exception as exc: if isinstance(exc, PhotoCropSizeSmallError): await e.edit('```The image is too small```') elif isinstance(exc, ImageProcessFailedError): await e.edit('```Failure while processing image```') else: await e.edit( '`Some issue with updating the pic, maybe you aren\'t an admin, or don\'t have the desired rights.`' )
async def set_group_photo(event): # sourcery no-metrics "For changing Group dp" flag = (event.pattern_match.group(1)).strip() if flag == "-s": replymsg = await event.get_reply_message() photo = None if replymsg and replymsg.media: if isinstance(replymsg.media, MessageMediaPhoto): photo = await event.client.download_media( message=replymsg.photo) elif "image" in replymsg.media.document.mime_type.split("/"): photo = await event.client.download_file( replymsg.media.document) else: return await edit_delete(event, INVALID_MEDIA) if photo: try: await event.client( EditPhotoRequest(event.chat_id, await event.client.upload_file(photo))) await edit_delete(event, CHAT_PP_CHANGED) except PhotoCropSizeSmallError: return await edit_delete(event, PP_TOO_SMOL) except ImageProcessFailedError: return await edit_delete(event, PP_ERROR) except Exception as e: return await edit_delete(event, f"**Error : **`{str(e)}`") process = "updated" else: try: await event.client( EditPhotoRequest(event.chat_id, InputChatPhotoEmpty())) except Exception as e: return await edit_delete(event, f"**Error : **`{e}`") process = "deleted" await edit_delete(event, "```successfully group profile pic deleted.```") if BOTLOG: await event.client.send_message( BOTLOG_CHATID, "#GROUPPIC\n" f"Group profile pic {process} successfully " f"CHAT: {get_display_name(await event.get_chat())}(`{event.chat_id}`)", )
async def set_group_photo(event): "For changing Group dp" flag = (event.pattern_match.group(1)).strip() if flag == "-s": replymsg = await event.get_reply_message() photo = None if replymsg and replymsg.media: if isinstance(replymsg.media, MessageMediaPhoto): photo = await event.client.download_media(message=replymsg.photo) elif "image" in replymsg.media.document.mime_type.split("/"): photo = await event.client.download_file(replymsg.media.document) else: return await edit_delete(event, INVALID_MEDIA) if photo: try: await event.client( EditPhotoRequest( event.chat_id, await event.client.upload_file(photo) ) ) await edit_delete(event, CHAT_PP_CHANGED) except PhotoCropSizeSmallError: return await edit_delete(event, PP_TOO_SMOL) except ImageProcessFailedError: return await edit_delete(event, PP_ERROR) except Exception as e: return await edit_delete(event, f"**ERROR : **`{str(e)}`") process = "Diperbarui" else: try: await event.client(EditPhotoRequest(event.chat_id, InputChatPhotoEmpty())) except Exception as e: return await edit_delete(event, f"**ERROR : **`{e}`") process = "Dihapus" await edit_delete(event, "**Foto Profil Grup Berhasil dihapus.**", 30) if BOTLOG: await event.client.send_message( BOTLOG_CHATID, "**#GROUPPIC**\n" f"📸 **Foto Profil Grup Berhasil {process}**\n" f"👥 **CHAT :** {get_display_name(await event.get_chat())}(`{event.chat_id}`)", )
async def _(ult): match = ult.pattern_match.group(1) chat = ult.chat_id if not ult.client._bot and match: chat = match try: await ult.client(EditPhotoRequest(chat, types.InputChatPhotoEmpty())) text = "`Removed Chat Photo..`" except Exception as E: text = str(E) return await eor(ult, text, time=5)
async def _(ult): if not ult.is_reply: return await eod(ult, "`Reply to a Media..`") reply_message = await ult.get_reply_message() replfile = await reply_message.download_media() file = await ultroid_bot.upload_file(replfile) mediain = mediainfo(reply_message.media) try: if "pic" in mediain: await ultroid_bot(EditPhotoRequest(ult.chat_id, file)) else: return await eod(ult, "`Invalid MEDIA Type !`") await eod(ult, "`Group Photo has Successfully Changed !`") except Exception as ex: await eod(ult, "Error occured.\n`{}`".format(str(ex))) os.remove(replfile)
async def upload_icon(channel_entity, input_chat_uploaded_photo): try: if channel_entity is None or input_chat_uploaded_photo is None: return False result = await client( EditPhotoRequest(channel=channel_entity, photo=input_chat_uploaded_photo)) print("successfully uploaded icon") except BaseException as e: print(e) sec = [int(s) for s in e.split() if s.isdigit()][0] + 5 print(str(sec) + " seconds to sleep 💋💋💋💋💋💋💋💋") time.sleep(sec) print("stop sleeping 💋💋💋💋💋💋💋") await upload_icon(channel_entity, input_chat_uploaded_photo)
async def set_group_photo(gpic): if gpic.fwd_from: return if not gpic.is_group: await edit_or_reply(gpic, "`I don't think this is a group.`") return replymsg = await gpic.get_reply_message() chat = await gpic.get_chat() admin = chat.admin_rights creator = chat.creator photo = None if not admin and not creator: await edit_or_reply(gpic, NO_ADMIN) return if replymsg and replymsg.media: if isinstance(replymsg.media, MessageMediaPhoto): photo = await gpic.client.download_media(message=replymsg.photo) elif "image" in replymsg.media.document.mime_type.split("/"): photo = await gpic.client.download_file(replymsg.media.document) else: await edit_or_reply(gpic, INVALID_MEDIA) h1m4n5hu0p = None if photo: try: await gpic.client( EditPhotoRequest(gpic.chat_id, await gpic.client.upload_file(photo)) ) await edit_or_reply(gpic, CHAT_PP_CHANGED) h1m4n5hu0p = True except PhotoCropSizeSmallError: await edit_or_reply(gpic, PP_TOO_SMOL) except ImageProcessFailedError: await edit_or_reply(gpic, PP_ERROR) except Exception as e: await edit_or_reply(gpic, f"**Error : **`{str(e)}`") if BOTLOG and h1m4n5hu0p: await gpic.client.send_message( BOTLOG_CHATID, "#GROUPPIC\n" f"Group profile pic changed " f"CHAT: {gpic.chat.title}(`{gpic.chat_id}`)", )
async def botlog(String, Api, Hash): Client = TelegramClient(StringSession(String), Api, Hash) await Client.start() KanalId = await Client( CreateChannelRequest(title='BrendUserbot BotLog', about=LANG['AUTO_BOTLOG'], megagroup=True)) KanalId = KanalId.chats[0].id Photo = await Client.upload_file(file='brendlogo.jpg') await Client(EditPhotoRequest(channel=KanalId, photo=Photo)) msg = await Client.send_message(KanalId, LANG['DONT_LEAVE']) await msg.pin() KanalId = str(KanalId) if "-100" in KanalId: return KanalId else: return "-100" + KanalId
async def set_group_photo(gpic): #Prevent Channel Bug to set channel pic if gpic.is_channel and not gpic.is_group: await gpic.edit("`setgpic Commad isn't permitted on channels`") return """ For .setgpic command, changes the picture of a group """ await gpic.edit("`Processing...`") await sleep(1) if not gpic.is_group: await gpic.edit("`I don't think this is a group.`") return replymsg = await gpic.get_reply_message() chat = await gpic.get_chat() admin = chat.admin_rights creator = chat.creator photo = None if not (admin or creator): await gpic.edit(NO_ADMIN) return if replymsg and replymsg.media: if isinstance(replymsg.media, MessageMediaPhoto): photo = await gpic.client.download_media(message=replymsg.photo) elif "image" in replymsg.media.document.mime_type.split('/'): photo = await gpic.client.download_file(replymsg.media.document) else: await gpic.edit(INVALID_MEDIA) if photo: try: await gpic.client( EditPhotoRequest(gpic.chat_id, await gpic.client.upload_file(photo))) await gpic.edit(CHAT_PP_CHANGED) except PhotoCropSizeSmallError: await gpic.edit(PP_TOO_SMOL) except ImageProcessFailedError: await gpic.edit(PP_ERROR)
async def set_group_photo(gpic): if gpic.fwd_from: return if not gpic.is_group: await edit_or_reply( gpic, "** ⪼ لا اعتقد ان ۿذه مجمـوعه 𓆰،**", ) return replymsg = await gpic.get_reply_message() await gpic.get_chat() photo = None if replymsg and replymsg.media: if isinstance(replymsg.media, MessageMediaPhoto): photo = await gpic.client.download_media(message=replymsg.photo) elif "image" in replymsg.media.document.mime_type.split("/"): photo = await gpic.client.download_file(replymsg.media.document) else: await edit_or_reply(gpic, INVALID_MEDIA) sandy = None if photo: try: await gpic.client( EditPhotoRequest(gpic.chat_id, await gpic.client.upload_file(photo))) await edit_or_reply(gpic, CHAT_PP_CHANGED) sandy = True except PhotoCropSizeSmallError: await edit_or_reply(gpic, PP_TOO_SMOL) except ImageProcessFailedError: await edit_or_reply(gpic, PP_ERROR) except Exception as e: await edit_or_reply(gpic, f"**خطأ : **`{str(e)}`") if BOTLOG and sandy: await gpic.client.send_message( BOTLOG_CHATID, "#صوره_المجموعه\n" f"تغير صوره المجموعه " f"الدردشه: {gpic.chat.title}(`{gpic.chat_id}`)", )
async def set_group_photo(gpic): if gpic.fwd_from: return if not gpic.is_group: await edit_or_reply(gpic, "`Saya tidak berpikir bahwa ini bukan group.`") return replymsg = await gpic.get_reply_message() await gpic.get_chat() photo = None if replymsg and replymsg.media: if isinstance(replymsg.media, MessageMediaPhoto): photo = await gpic.client.download_media(message=replymsg.photo) elif "image" in replymsg.media.document.mime_type.split("/"): photo = await gpic.client.download_file(replymsg.media.document) else: await edit_or_reply(gpic, INVALID_MEDIA) sandy = None if photo: try: await gpic.client( EditPhotoRequest(gpic.chat_id, await gpic.client.upload_file(photo))) await edit_or_reply(gpic, CHAT_PP_CHANGED) sandy = True except PhotoCropSizeSmallError: await edit_or_reply(gpic, PP_TOO_SMOL) except ImageProcessFailedError: await edit_or_reply(gpic, PP_ERROR) except Exception as e: await edit_or_reply(gpic, f"**Error : **`{str(e)}`") if BOTLOG and sandy: await gpic.client.send_message( BOTLOG_CHATID, "#GROUPPIC\n" f"Profil group berhasil diganti " f"CHAT: {gpic.chat.title}(`{gpic.chat_id}`)", )
async def update_channel_photo(photo, channel_link): client = TelegramClient( 'upd phototemp', TELEGRAM_API_ID, TELEGRAM_API_HASH, ) if not client.is_connected(): await client.start(PHONE) dialogs = await client.get_dialogs() channel_entity = await client.get_entity(channel_link) upload_file_result = await client.upload_file(file=photo) try: result = await client( EditPhotoRequest(channel=channel_entity, photo=upload_file_result)) except BaseException as e: print(e) await client.disconnect() print('finish')