def setchatpic(update, context): chat = update.effective_chat msg = update.effective_message user = update.effective_user if user_can_changeinfo(chat, user, context.bot.id) is False: msg.reply_text("You are missing right to change group info!") return if msg.reply_to_message: if msg.reply_to_message.photo: pic_id = msg.reply_to_message.photo[-1].file_id elif msg.reply_to_message.document: pic_id = msg.reply_to_message.document.file_id else: msg.reply_text("You can only set some photo as chat pic!") return dlmsg = msg.reply_text("Just a sec...") tpic = context.bot.get_file(pic_id) tpic.download("gpic.png") try: with open("gpic.png", "rb") as chatp: context.bot.set_chat_photo(int(chat.id), photo=chatp) msg.reply_text("Successfully set new chatpic!") except BadRequest as excp: msg.reply_text(f"Error! {excp.message}") finally: dlmsg.delete() if os.path.isfile("gpic.png"): os.remove("gpic.png") else: msg.reply_text("Reply to some photo or file to set new chat pic!")
def set_sticker(update, context): msg = update.effective_message chat = update.effective_chat user = update.effective_user if user_can_changeinfo(chat, user, context.bot.id) is False: return msg.reply_text("You're missing rights to change chat info!") if msg.reply_to_message: if not msg.reply_to_message.sticker: return msg.reply_text( "You need to reply to some sticker to set chat sticker set!" ) stkr = msg.reply_to_message.sticker.set_name try: context.bot.set_chat_sticker_set(chat.id, stkr) msg.reply_text( f"Successfully set new group stickers in {chat.title}!" ) except BadRequest as excp: if excp.message == "Participants_too_few": return msg.reply_text( "Sorry, due to telegram restrictions chat needs to have minimum 100 members before they can have group stickers!" ) msg.reply_text(f"Error! {excp.message}.") else: msg.reply_text( "You need to reply to some sticker to set chat sticker set!" )
def set_sticker(update, context): msg = update.effective_message chat = update.effective_chat user = update.effective_user if user_can_changeinfo(chat, user, context.bot.id) is False: return msg.reply_text( "Anda tidak memiliki hak untuk mengubah info grup!") if msg.reply_to_message: if not msg.reply_to_message.sticker: return msg.reply_text( "Anda perlu membalas beberapa stiker untuk menyetel stiker grup!" ) stkr = msg.reply_to_message.sticker.set_name try: context.bot.set_chat_sticker_set(chat.id, stkr) msg.reply_text( f"Berhasil memasang stiker grup baru di{chat.title}!") except BadRequest as excp: if excp.message == "Participants_too_few": return msg.reply_text( "Maaf, karena pembatasan telegram, grup harus memiliki minimal 100 anggota sebelum mereka dapat memiliki stiker grup!" ) msg.reply_text(f"Error! {excp.message}.") else: msg.reply_text( "Anda perlu membalas beberapa stiker untuk menyetel stiker grup!")
def setchatpic(update, context): chat = update.effective_chat msg = update.effective_message user = update.effective_user if user_can_changeinfo(chat, user, context.bot.id) is False: msg.reply_text("Anda tidak memiliki hak untuk mengubah info grup!") return if msg.reply_to_message: if msg.reply_to_message.photo: pic_id = msg.reply_to_message.photo[-1].file_id elif msg.reply_to_message.document: pic_id = msg.reply_to_message.document.file_id else: msg.reply_text( "Anda hanya dapat mengatur beberapa foto sebagai profil grup!") return dlmsg = msg.reply_text("Tunggu sebentar...") tpic = context.bot.get_file(pic_id) tpic.download("gpic.png") try: with open("gpic.png", "rb") as chatp: context.bot.set_chat_photo(int(chat.id), photo=chatp) msg.reply_text("Berhasil mengganti foto profil grup!") except BadRequest as excp: msg.reply_text(f"Error! {excp.message}") finally: dlmsg.delete() if os.path.isfile("gpic.png"): os.remove("gpic.png") else: msg.reply_text( "Balas beberapa foto atau file untuk menjadikan nya profil grup!")
def rmchatpic(update, context): chat = update.effective_chat msg = update.effective_message user = update.effective_user if user_can_changeinfo(chat, user, context.bot.id) is False: msg.reply_text("You don't have enough rights to delete group photo") return try: context.bot.delete_chat_photo(int(chat.id)) msg.reply_text("Successfully deleted chat's profile photo!") except BadRequest as excp: msg.reply_text(f"Error! {excp.message}.") return
def rmchatpic(update, context): chat = update.effective_chat msg = update.effective_message user = update.effective_user if user_can_changeinfo(chat, user, context.bot.id) is False: msg.reply_text( "Anda tidak memiliki hak untuk menghapus foto profil grup") return try: context.bot.delete_chat_photo(int(chat.id)) msg.reply_text("Foto profil grup berhasil dihapus!") except BadRequest as excp: msg.reply_text(f"Error! {excp.message}.") return
def set_desc(update, context): msg = update.effective_message chat = update.effective_chat user = update.effective_user if user_can_changeinfo(chat, user, context.bot.id) is False: return msg.reply_text( "Anda tidak meiliki hak untuk mengubah info grup!") tesc = msg.text.split(None, 1) if len(tesc) >= 2: desc = tesc[1] else: return msg.reply_text( "Berikan beberapa teks untuk menyetel deskripsi grup!") try: if len(desc) > 255: return msg.reply_text( "Deskripsi grup tidak boleh lebih dari 255 karakter!") context.bot.set_chat_description(chat.id, desc) msg.reply_text(f"Deskripsi grup berhasil diperbarui ke {chat.title}!") except BadRequest as excp: msg.reply_text(f"Error! {excp.message}.")
def set_desc(update, context): msg = update.effective_message chat = update.effective_chat user = update.effective_user if user_can_changeinfo(chat, user, context.bot.id) is False: return msg.reply_text("You're missing rights to change chat info!") tesc = msg.text.split(None, 1) if len(tesc) >= 2: desc = tesc[1] else: return msg.reply_text("Setting empty description won't do anything!") try: if len(desc) > 255: return msg.reply_text( "Description must needs to be under 255 characters!" ) context.bot.set_chat_description(chat.id, desc) msg.reply_text( f"Successfully updated chat description in {chat.title}!" ) except BadRequest as excp: msg.reply_text(f"Error! {excp.message}.")
def setchat_title(update, context): chat = update.effective_chat msg = update.effective_message user = update.effective_user args = context.args if user_can_changeinfo(chat, user, context.bot.id) is False: msg.reply_text("You don't have enough rights to change chat info!") return title = " ".join(args) if not title: msg.reply_text("Enter some text to set new title in your chat!") return try: context.bot.set_chat_title(int(chat.id), str(title)) msg.reply_text( f"Successfully set <b>{title}</b> as new chat title!", parse_mode=ParseMode.HTML, ) except BadRequest as excp: msg.reply_text(f"Error! {excp.message}.") return
def setchat_title(update, context): chat = update.effective_chat msg = update.effective_message user = update.effective_user args = context.args if user_can_changeinfo(chat, user, context.bot.id) is False: msg.reply_text("Anda tidak memiliki hak untuk mengubah info grup!") return title = " ".join(args) if not title: msg.reply_text("Masukkan beberapa teks untuk menyetel nama grup Anda!") return try: context.bot.set_chat_title(int(chat.id), str(title)) msg.reply_text( f"Berhasil menyetel <b>{title}</b> sebagai nama grup baru!", parse_mode=ParseMode.HTML, ) except BadRequest as excp: msg.reply_text(f"Error! {excp.message}.") return