def run(message, matches, chat_id, step): response = Message(chat_id) if is_mod(message): ex = int(r.ttl('expire:{}'.format(chat_id))) - time.time() days = int(ex / 86400) key = [[ InlineKeyboardButton(text='🔐 منوی قفل ها', callback_data='/locks'), InlineKeyboardButton(text='📝تنظیمات پیام', callback_data='/pmsetting'), ], [ InlineKeyboardButton(text='👥لیست مدیران', callback_data='/admins'), ], [ InlineKeyboardButton(text='روز {}'.format(days), callback_data='/expire'), InlineKeyboardButton(text='📆شارژ گروه', callback_data='/expire'), ], [ InlineKeyboardButton(text='💡ورود به کانال راهنما💡', url='https://t.me/spntaHelp'), ]] markup = InlineKeyboardMarkup(inline_keyboard=key) response.set_text( "📋به پنل تنظیمات ربات خوش آمدید برای مدیریت گروه از کیبورد زیر استفاده کنید.(" "فقط ادمین های ربات در گروه قابلیت کار کردن با این کیبورد را دارند)", parse_mode="Markdown", reply_markup=markup) return [response]
async def run(message, matches, chat_id, step): if is_mod(message): if matches[0] == 'music': show_keyboard = [] i = 0 user_steps[chat_id] = { "name": "Soundcloud", "step": 0, "data": {}, "cover": {}, "title": {} } for song in await search(matches[1]): title, link, cover = song[0], song[1], song[2] cover_music = '' if cover: cover_music = cover.replace('large', 't500x500') else: cover_music = 'https://www.apple.com/v/apple-music/e/images/shared/og_image.png?201802090801' user_steps[chat_id]['cover'][i] = cover_music user_steps[chat_id]['data'][i] = link user_steps[chat_id]['title'][i] = title show_keyboard.append([ InlineKeyboardButton(text=title, callback_data='music {}'.format(i)) ]) i += 1 if i == 20: break if len(show_keyboard) in [0, 1]: return [Message(chat_id).set_text('چیزی پیدا نکردم :(')] markup = InlineKeyboardMarkup(inline_keyboard=show_keyboard) bot.sendMessage(chat_id, "یکی از اینارو انتخاب کن 🙃👇🏻", reply_markup=markup)
def run(message, matches, chat_id, step): if matches[0] == 'setexpire': if is_sudo(message): exp = time.time() + int(matches[1]) * 86400 r.setex('expire:{}'.format(chat_id), int(exp), 'hemmhm') bot.sendMessage(chat_id, 'تاریخ انقضای گروه برای {} روز دیگر تنظیم شد☘️'.format(matches[1])) elif matches == 'expire': if is_mod(message): ex = int(r.ttl('expire:{}'.format(chat_id))) - time.time() days = int(ex / 86400) bot.sendMessage(chat_id, '📋 روز های باقیمانده از اعتبار گروه : {}'.format(days))
async def run(message, matches, chat_id, step): if is_mod(message): if 'reply_to_message' in message: reply = message['reply_to_message'] if 'audio' in reply: await download(reply['audio']['file_id'], 'tmp/{}.mp3'.format(message['from']['id'])) s = matches[1].split(':') title = s[0] performer = s[1] bot.sendChatAction(chat_id, 'upload_audio') bot.sendAudio(chat_id, open('tmp/{}.mp3'.format(message['from']['id']), 'rb'), performer=performer, title=title, duration=reply['audio']['duration']) os.remove('tmp/{}.mp3'.format(message['from']['id']))
def run(message, matches, chat_id, step): if matches == 'setowner': if 'reply_to_message' in message: if is_sudo(message): r.hset('owner', chat_id, message['reply_to_message']['from']['id']) r.hset('owner:{}'.format(chat_id), message['reply_to_message']['from']['id'], True) text = str(ln['ingroup']['setowner']).format( message['reply_to_message']['from']['first_name'], message['reply_to_message']['from']['id']) bot.sendMessage(chat_id, text, parse_mode='Markdown') if matches == 'admin': if 'reply_to_message' in message: if is_owner(message): r.sadd('mod:{}'.format(chat_id), message['reply_to_message']['from']['id']) text = str(ln['ingroup']['setowner']).format( message['reply_to_message']['from']['first_name'], message['reply_to_message']['from']['id']) bot.sendMessage(chat_id, text, parse_mode='Markdown') if matches == 'user': if 'reply_to_message' in message: if is_owner(message): r.srem('mod:{}'.format(chat_id), message['reply_to_message']['from']['id']) text = str(ln['ingroup']['user']).format( message['reply_to_message']['from']['first_name'], message['reply_to_message']['from']['id']) bot.sendMessage(chat_id, text, parse_mode='Markdown') if matches[0] == 'title' and matches[1]: if is_mod(message): try: set = bot.setChatTitle(chat_id, matches[1]) bot.sendMessage(chat_id, ln['ingroup']['title'], reply_to_message_id=message['message_id']) except: pass if matches == 'pin': if is_mod(message): if 'reply_to_message' in message: bot.pinChatMessage(chat_id, message['reply_to_message']['message_id']) bot.sendMessage(chat_id, ln['ingroup']['pin'], reply_to_message_id=message['reply_to_message'] ['message_id']) if matches == 'unpin': if is_mod(message): bot.unpinChatMessage(chat_id) bot.sendMessage(chat_id, ln['ingroup']['unpin']) if matches == 'ban': if is_mod(message): if 'reply_to_message' in message: user = message['reply_to_message'] if not is_mod(user): bot.kickChatMember(chat_id, user['from']['id']) bot.sendMessage(chat_id, str(ln['ingroup']['ban']).format( user['from']['first_name'], user['from']['id']), parse_mode='Markdown') else: bot.sendMessage(chat_id, ln['ingroup']['banError']) if matches[0] == 'ban': if is_mod(message): user = str(matches[1]) bot.kickChatMember(chat_id, user) bot.sendMessage(chat_id, str(ln['ingroup']['ban_id']).format(user)) if matches == 'avatar': if is_mod(message): try: bot.download_file( message['reply_to_message']['photo'][1]['file_id'], '{}.jpg'.format(chat_id)) bot.setChatPhoto(chat_id, open('{}.jpg'.format(chat_id), 'rb')) os.remove('{}.jpg'.format(chat_id)) except Exception as e: bot.sendMessage(chat_id, '#Error:\n{}'.format(e), reply_to_message_id=message['reply_to_message'] ['message_id']) if matches == 'admins': if is_mod(message): owner = r.hget('owner', chat_id) if owner: oner = '[{}](tg://user?id={})'.format(owner, owner) else: oner = ln['ingroup']['admins']['0'] mods = r.smembers('mod:{}'.format(chat_id)) if mods: mod = '👥' sc = r.scard('mod:{}'.format(chat_id)) scnum = int(sc) i = 1 for x in mods: if scnum == i: mod += '\n└ > [{}](tg://user?id={})'.format(x, x) else: mod += '\n├> [{}](tg://user?id={})'.format(x, x) i = i + 1 else: mod = ln['ingroup']['admins']['0'] text = str(ln['ingroup']['admins'][1]).format(oner, mod) bot.sendMessage(chat_id, text, parse_mode='Markdown') if matches[0] == 'filter': if is_mod(message): text = message['text'].replace(matches[0], '').replace('/ ', '').replace( '# ', '').replace('! ', '') lines = re.findall('[^\n]+', text) fil = '' for x in lines: r.sadd('filter:{}'.format(chat_id), x) fil += '\n>{}'.format(x) bot.sendMessage(chat_id, str(ln['ingroup']['filter']).format(fil)) if matches[0] == 'unfilter': if is_mod(message): text = message['text'].replace(matches[0], '').replace('/ ', '').replace( '# ', '').replace('! ', '') lines = re.findall('[^\n]+', text) fil = '' for x in lines: r.srem('filter:{}'.format(chat_id), x) fil += '\n>{}'.format(x) bot.sendMessage(chat_id, str(ln['ingroup']['unfilter']).format(fil)) if matches == 'filters': if is_mod(message): filters = r.smembers('filter:{}'.format(chat_id)) text = '' for x in filters: text += '\n>{}'.format(x) bot.sendMessage(chat_id, str(ln['ingroup']['filters']).format(text)) if matches[0] == 'mute': if is_mod(message): if 'reply_to_message' in message: user = message['reply_to_message'] if not is_mod(user): name = message['reply_to_message']['from']['first_name'] bot.restrictChatMember(chat_id, user['from']['id'], until_date=time.time() + int(matches[1]) * 86400, can_send_messages=False, can_send_media_messages=False, can_send_other_messages=False, can_add_web_page_previews=False) bot.sendMessage(chat_id, str(ln['ingroup']['mute']).format( name, user['from']['id'], matches[1]), parse_mode='Markdown') else: bot.sendMessage(chat_id, ln['ingroup']['muteError']) if matches == 'unmute': if is_mod(message): if 'reply_to_message' in message: user = message['reply_to_message'] bot.restrictChatMember(chat_id, user['from']['id'], can_send_messages=True, can_send_media_messages=True, can_send_other_messages=True, can_add_web_page_previews=True) bot.sendMessage(chat_id, ln['ingroup']['unmute']) if matches[0] == 'unmute': if is_mod(message): if 'reply_to_message' in message: bot.restrictChatMember(chat_id, matches[1], can_send_messages=True, can_send_media_messages=True, can_send_other_messages=True, can_add_web_page_previews=True) bot.sendMessage(chat_id, ln['ingroup']['unmute']) if matches[0] == 'mute' and matches[1] == 'all': if is_mod(message): if r.hget('lock_all', chat_id): bot.sendMessage(chat_id, ln['ingroup']['muteAll']['0']) else: r.hset('lock_all', chat_id, True) bot.sendMessage(chat_id, ln['ingroup']['muteAll']['1']) if matches[0] == 'unmute' and matches[1] == 'all': if is_mod(message): if r.hget('lock_all', chat_id): r.hdel('lock_all', chat_id) bot.sendMessage(chat_id, ln['ingroup']['unmuteAll']['0']) else: bot.sendMessage(chat_id, ln['ingroup']['unmuteAll']['1']) if matches == 'newlink': if is_mod(message): link = bot.exportChatInviteLink(chat_id) r.hset('group_link', chat_id, link) text = '''{} {}'''.format(message['chat']['title'], link) bot.sendMessage(chat_id, text) if matches == 'newlink': if is_mod(message): link = r.hget( 'group_link', chat_id) or 'link not Found\ncreate new link with /newlink' text = '''{} {}'''.format(message['chat']['title'], link) bot.sendMessage(chat_id, text) if matches == 'admins_set': if is_owner(message): admins = bot.getChatAdministrators(chat_id) bot.sendMessage(chat_id, ln['ingroup']['admins_set']) i = 1 for x in admins: if x['status'] == 'administrator': r.sadd('mod:{}'.format(chat_id), x['user']['id']) text = str(ln['ingroup']['setowner']).format( x['user']['first_name'], x['user']['id']) bot.sendMessage(chat_id, text, parse_mode='Markdown') i = i + 1
async def run(message, matches, chat_id, step): from_id = message['from']['id'] if not is_group(message): if step == 0: user_steps[from_id] = { "name": "voice_search", "step": 1, "data": {} } hide_keyboard = {'hide_keyboard': True, "selective": True} return [ Message(chat_id).set_text( "لطفا 10 الی 15 ثانیه از موزیک را بصورت ویس ارسال کنید🎼", reply_to_message_id=message['message_id'], reply_markup=hide_keyboard) ] elif step == 1: content_type, chat_type, chat_id = telepot.glance(message) bot.download_file(message['voice']['file_id'], 'tmp/{}.mp3'.format(message['from']['id'])) req = acr.recognize_by_file( 'tmp/{}.mp3'.format(message['from']['id']), 0) os.remove('tmp/{}.mp3'.format(message['from']['id'])) jdat = json.loads(req) if jdat['status']['msg'] == 'No result': del user_steps[from_id] return [ Message(chat_id).set_text("چیزی پیدا نکردم ☹️", parse_mode="markdown", reply_markup=key) ] else: arc = jdat['metadata']['music'][0] text = '''🗣خواننده : {} 📆سال ساخت : {} 🎼عنوان موزیک : {} 🎧نام آلبوم : {} از بخش جستجوی موزیک با استفاده از نام موزیک و اسم خواننده موزیک را سرچ کنید 😉'''.format( arc['artists'][0]['name'] or '', arc['release_date'] or '', arc['title'] or '', arc['album']['name'] or '') bot.sendMessage(chat_id, text, reply_to_message_id=message['message_id'], reply_markup=key) del user_steps[from_id] else: if is_mod(message): m = message['reply_to_message'] if 'audio' in m: bot.download_file(m['audio']['file_id'], 'tmp/{}.mp3'.format(message['from']['id'])) elif 'voice' in m: bot.download_file(m['voice']['file_id'], 'tmp/{}.mp3'.format(message['from']['id'])) elif 'video' in m: bot.download_file(m['video']['file_id'], 'tmp/{}.mp3'.format(message['from']['id'])) elif 'video_note' in m: bot.download_file(m['video_note']['file_id'], 'tmp/{}.mp3'.format(message['from']['id'])) req = acr.recognize_by_file( 'tmp/{}.mp3'.format(message['from']['id']), 0) os.remove('tmp/{}.mp3'.format(message['from']['id'])) jdat = json.loads(req) if jdat['status']['msg'] == 'No result': return [ Message(chat_id).set_text("چیزی پیدا نکردم ☹️", parse_mode="markdown") ] else: arc = jdat['metadata']['music'][0] text = '''🗣خواننده : {} 📆سال ساخت : {} 🎼عنوان موزیک : {} 🎧نام آلبوم : {} از بخش جستجوی موزیک(در پیوی ربات) با استفاده از نام موزیک و اسم خواننده موزیک را سرچ کنید 😉'''.format( arc['artists'][0]['name'] or '', arc['release_date'] or '', arc['title'] or '', arc['album']['name'] or '') bot.sendMessage(chat_id, text, reply_to_message_id=message['message_id'])
def run(message, matches, chat_id, step): if matches == 'setowner': if 'reply_to_message' in message: if is_sudo(message): r.hset('owner', chat_id, message['reply_to_message']['from']['id']) r.hset('owner:{}'.format(chat_id), message['reply_to_message']['from']['id'], True) text= 'کاربر [{}](tg://user?id={}) ادمین اصلی ربات در گروه شد👤'.\ format(message['reply_to_message']['from']['first_name'], message['reply_to_message']['from']['id']) bot.sendMessage(chat_id, text, parse_mode='Markdown') if matches == 'ادمین': if 'reply_to_message' in message: if is_owner(message): r.sadd('mod:{}'.format(chat_id), message['reply_to_message']['from']['id']) text= 'کاربر [{}](tg://user?id={}) ادمین ربات در گروه شد👤'.\ format(message['reply_to_message']['from']['first_name'], message['reply_to_message']['from']['id']) bot.sendMessage(chat_id, text, parse_mode='Markdown') if matches == 'کاربر': if 'reply_to_message' in message: if is_owner(message): r.srem('mod:{}'.format(chat_id), message['reply_to_message']['from']['id']) text= 'کاربر [{}](tg://user?id={}) از این به بعد یک کاربر معمولی میباشد👌'.\ format(message['reply_to_message']['from']['first_name'], message['reply_to_message']['from']['id']) bot.sendMessage(chat_id, text, parse_mode='Markdown') if matches[0] == 'عنوان' and matches[1]: if is_mod(message): try: set = bot.setChatTitle(chat_id, matches[1]) bot.sendMessage(chat_id, 'نام گروه با موفقیت تغییر یافت✅', reply_to_message_id=message['message_id']) except: bot.sendMessage(chat_id, 'ربات ادمین نیست 🤔') if matches == 'پین': if is_mod(message): if 'reply_to_message' in message: bot.pinChatMessage(chat_id, message['reply_to_message']['message_id']) bot.sendMessage(chat_id, 'سنجاق شد📌', reply_to_message_id=message['reply_to_message']['message_id']) if matches == 'حذف پین': if is_mod(message): bot.unpinChatMessage(chat_id) bot.sendMessage(chat_id, 'سنجاق گروه برداشته شد📌') if matches == 'اخراج': if is_mod(message): if 'reply_to_message' in message: user = message['reply_to_message'] if not is_mod(user): bot.kickChatMember(chat_id, user['from']['id']) bot.sendMessage(chat_id, 'کاربر [{}](tg://user?id={}) از گروه اخراج شد❌'. format(user['from']['first_name'], user['from']['id']), parse_mode='Markdown') bot.sendMessage(r.hget('owner', chat_id), '''کاربر [{}](tg://user?id={}) از گروه {} اخراج شد❌ اخراج کننده : [{}](tg://user?id={}) '''.format(user['from']['first_name'], user['from']['id'], message['chat']['title'], message['from']['first_name'], message['from']['id']), parse_mode='Markdown') else: bot.sendMessage(chat_id, 'شما نمیتوانید ادمین را اخراج کنید🙄') if matches[0] == 'اخراج': if is_mod(message): user = str(matches[1]) bot.kickChatMember(chat_id, user) bot.sendMessage(chat_id, 'کاربر {} از گروه اخراج شد❌'.format(user)) bot.sendMessage(r.hget('owner', chat_id), '''کاربر [{}](tg://user?id={}) از گروه {} اخراج شد❌ اخراج کننده : [{}](tg://user?id={}) '''.format(user, user, message['chat']['title'], message['from']['id'], message['from']['id']), parse_mode='Markdown') if matches == 'آواتار': if is_mod(message): try: bot.download_file(message['reply_to_message']['photo'][1]['file_id'], '{}.jpg'.format(chat_id)) bot.setChatPhoto(chat_id, open('{}.jpg'.format(chat_id), 'rb')) os.remove('{}.jpg'.format(chat_id)) except Exception as e: bot.sendMessage(chat_id, '#Error:\n{}'.format(e), reply_to_message_id=message['reply_to_message']['message_id']) if matches == 'لیست ادمین': if is_mod(message): owner = r.hget('owner', chat_id) if owner: oner = '[{}](tg://user?id={})'.format(owner, owner) else: oner = 'وجود ندارد❌' mods = r.smembers('mod:{}'.format(chat_id)) if mods: mod = '' for x in mods: mod += '\n>[{}](tg://user?id={})'.format(x, x) else: mod = 'وجود ندارد❌' text = '''👤 ادمین اصلی : {} 👥 سایر ادمین ها : {}'''.format(oner, mod) bot.sendMessage(chat_id, text, parse_mode='Markdown') if matches[0] == 'فیلتر': if is_mod(message): text = message['text'].replace(matches[0], '').replace('/ ', '').replace('# ', '').replace('! ', '') lines = re.findall('[^\n]+', text) fil = '' for x in lines: r.sadd('filter:{}'.format(chat_id), x) fil += '\n>{}'.format(x) bot.sendMessage(chat_id, '''☠️کلمات زیر به لیست فیلتر افزوده شدند : {}'''.format(fil)) if matches[0] == 'حذف': if is_mod(message): text = message['text'].replace(matches[0], '').replace('/ ', '').replace('# ', '').replace('! ', '') lines = re.findall('[^\n]+', text) fil = '' for x in lines: r.srem('filter:{}'.format(chat_id), x) fil += '\n>{}'.format(x) bot.sendMessage(chat_id, '''☠️کلمات زیر از لیست فیلتر حذف شدند : {}'''.format(fil)) if matches == 'لیست فیلتر': if is_mod(message): filters = r.smembers('filter:{}'.format(chat_id)) text = '' for x in filters: text += '\n>{}'.format(x) bot.sendMessage(chat_id, '''🤐لیست کلمات فیلتر شده : {}'''.format(text)) if matches[0] == 'mute': if is_mod(message): if 'reply_to_message' in message: user = message['reply_to_message'] if not is_mod(user): name = message['reply_to_message']['from']['first_name'] bot.restrictChatMember(chat_id, user['from']['id'], until_date=time.time() + int(matches[1]) * 86400, can_send_messages=False, can_send_media_messages=False, can_send_other_messages=False, can_add_web_page_previews=False ) bot.sendMessage(chat_id, 'کاربر [{}](tg://user?id={})' ' به مدت {} روز نمیتواند در گروه پیامی ارسال کند😕' .format(name, user['from']['id'], matches[1]), parse_mode='Markdown') else: bot.sendMessage(chat_id, 'ادمینه 🤧') if matches == 'unmute': if is_mod(message): if 'reply_to_message' in message: user = message['reply_to_message'] bot.restrictChatMember(chat_id, user['from']['id'], can_send_messages=True, can_send_media_messages=True, can_send_other_messages=True, can_add_web_page_previews=True) bot.sendMessage(chat_id, 'آزاد شد :)') if matches[0] == 'unmute': if is_mod(message): if 'reply_to_message' in message: bot.restrictChatMember(chat_id, matches[1], can_send_messages=True, can_send_media_messages=True, can_send_other_messages=True, can_add_web_page_previews=True) bot.sendMessage(chat_id, 'آزاد شد :)') if matches[0] == 'قفل' and matches[1] == 'گروه': if is_mod(message): if r.hget('lock_all', chat_id): bot.sendMessage(chat_id, 'قفل گروه از قبل فعال بوده است✔️') else: r.hset('lock_all', chat_id, True) bot.sendMessage(chat_id, 'گروه قفل شد✔️') bot.sendDocument(chat_id, open('tmp/mute.gif', 'rb'), caption='''#گروه_تعطیل_است #چیزی_ارسال_نکنید_چون #توسط_ربات_حذف_خواهد_شد @spntaBot''') if matches[0] == 'بازکردن' and matches[1] == 'گروه': if is_mod(message): if r.hget('lock_all', chat_id): r.hdel('lock_all', chat_id) bot.sendMessage(chat_id, 'قفل گروه باز شد✅') else: bot.sendMessage(chat_id, 'گروه قفل نبوده ک 🙄') if matches == 'ربات': txt = '[{} هستم 🐣](tg://user?id={})'.format(message['from']['first_name'], message['from']['id']) bot.sendMessage(chat_id, txt, parse_mode='Markdown') if matches == 'link': link = bot.exportChatInviteLink(chat_id) text = '''{} {}'''.format(message['chat']['title'], link) bot.sendMessage(chat_id, text) if matches == 'سازنده': if is_sudo(message): admins = bot.getChatAdministrators(chat_id) for x in admins: if x['status'] == 'creator': print(x) r.hset('owner', chat_id, x['user']['id']) r.hset('owner:{}'.format(chat_id), x['user']['id'], True) text = 'کاربر [{}](tg://user?id={}) ادمین اصلی گروه است'. \ format(x['user']['first_name'], x['user']['id']) bot.sendMessage(chat_id, text, parse_mode='Markdown') if matches == 'ساعت': now = datetime.now(pytz.timezone("Asia/Tehran")).strftime("%H:%M:%S") bot.sendMessage(chat_id, now)
def run(message, matches, chat_id, step): ln = lang if r.hget('lang_gp', chat_id) == 'en': ln = ln.en else: ln = ln.fa if matches == 'setowner': if 'reply_to_message' in message: if is_sudo(message): r.hset('owner', chat_id, message['reply_to_message']['from']['id']) r.hset('owner:{}'.format(chat_id), message['reply_to_message']['from']['id'], True) text= str(ln['ingroup']['setowner']).format(message['reply_to_message']['from']['first_name'], message['reply_to_message']['from']['id']) bot.sendMessage(chat_id, text, parse_mode='Markdown') if matches == 'admin': if 'reply_to_message' in message: if is_owner(message): r.sadd('mod:{}'.format(chat_id), message['reply_to_message']['from']['id']) text= 'کاربر [{}](tg://user?id={}) ادمین ربات در گروه شد👤'.\ format(message['reply_to_message']['from']['first_name'], message['reply_to_message']['from']['id']) bot.sendMessage(chat_id, text, parse_mode='Markdown') if matches == 'user': if 'reply_to_message' in message: if is_owner(message): r.srem('mod:{}'.format(chat_id), message['reply_to_message']['from']['id']) text= 'کاربر [{}](tg://user?id={}) از این به بعد یک کاربر معمولی میباشد👌'.\ format(message['reply_to_message']['from']['first_name'], message['reply_to_message']['from']['id']) bot.sendMessage(chat_id, text, parse_mode='Markdown') if matches[0] == 'title' and matches[1]: if is_mod(message): try: set = bot.setChatTitle(chat_id, matches[1]) bot.sendMessage(chat_id, 'نام گروه با موفقیت تغییر یافت✅', reply_to_message_id=message['message_id']) except: bot.sendMessage(chat_id, 'ربات ادمین نیست 🤔') if matches == 'pin': if is_mod(message): if 'reply_to_message' in message: bot.pinChatMessage(chat_id, message['reply_to_message']['message_id']) bot.sendMessage(chat_id, 'سنجاق شد📌', reply_to_message_id=message['reply_to_message']['message_id']) if matches == 'unpin': if is_mod(message): bot.unpinChatMessage(chat_id) bot.sendMessage(chat_id, 'سنجاق گروه برداشته شد📌') if matches == 'ban': if is_mod(message): if 'reply_to_message' in message: user = message['reply_to_message'] if not is_mod(user): bot.kickChatMember(chat_id, user['from']['id']) bot.sendMessage(chat_id, 'کاربر [{}](tg://user?id={}) از گروه اخراج شد❌'. format(user['from']['first_name'], user['from']['id']), parse_mode='Markdown') bot.sendMessage(r.hget('owner', chat_id), '''کاربر [{}](tg://user?id={}) از گروه {} اخراج شد❌ اخراج کننده : [{}](tg://user?id={}) '''.format(user['from']['first_name'], user['from']['id'], message['chat']['title'], message['from']['first_name'], message['from']['id']), parse_mode='Markdown') else: bot.sendMessage(chat_id, 'شما نمیتوانید ادمین را اخراج کنید🙄') if matches[0] == 'ban': if is_mod(message): user = str(matches[1]) bot.kickChatMember(chat_id, user) bot.sendMessage(chat_id, 'کاربر {} از گروه اخراج شد❌'.format(user)) bot.sendMessage(r.hget('owner', chat_id), '''کاربر [{}](tg://user?id={}) از گروه {} اخراج شد❌ اخراج کننده : [{}](tg://user?id={}) '''.format(user, user, message['chat']['title'], message['from']['id'], message['from']['id']), parse_mode='Markdown') if matches == 'avatar': if is_mod(message): try: bot.download_file(message['reply_to_message']['photo'][1]['file_id'], '{}.jpg'.format(chat_id)) bot.setChatPhoto(chat_id, open('{}.jpg'.format(chat_id), 'rb')) os.remove('{}.jpg'.format(chat_id)) except Exception as e: bot.sendMessage(chat_id, '#Error:\n{}'.format(e), reply_to_message_id=message['reply_to_message']['message_id']) if matches == 'admins': if is_mod(message): owner = r.hget('owner', chat_id) if owner: oner = '[{}](tg://user?id={})'.format(owner, owner) else: oner = 'وجود ندارد❌' mods = r.smembers('mod:{}'.format(chat_id)) if mods: mod = '👥' sc = r.scard('mod:{}'.format(chat_id)) scnum = int(sc) i = 1 for x in mods: if scnum == i: mod += '\n└ > [{}](tg://user?id={})'.format(x, x) else: mod += '\n├> [{}](tg://user?id={})'.format(x, x) i = i + 1 else: mod = 'وجود ندارد❌' text = '''👤 ادمین اصلی : {} سایر ادمین ها : {}'''.format(oner, mod) bot.sendMessage(chat_id, text, parse_mode='Markdown') if matches[0] == 'filter': if is_mod(message): text = message['text'].replace(matches[0], '').replace('/ ', '').replace('# ', '').replace('! ', '') lines = re.findall('[^\n]+', text) fil = '' for x in lines: r.sadd('filter:{}'.format(chat_id), x) fil += '\n>{}'.format(x) bot.sendMessage(chat_id, '''☠️کلمات زیر به لیست فیلتر افزوده شدند : {}'''.format(fil)) if matches[0] == 'unfilter': if is_mod(message): text = message['text'].replace(matches[0], '').replace('/ ', '').replace('# ', '').replace('! ', '') lines = re.findall('[^\n]+', text) fil = '' for x in lines: r.srem('filter:{}'.format(chat_id), x) fil += '\n>{}'.format(x) bot.sendMessage(chat_id, '''☠️کلمات زیر از لیست فیلتر حذف شدند : {}'''.format(fil)) if matches == 'filters': if is_mod(message): filters = r.smembers('filter:{}'.format(chat_id)) text = '' for x in filters: text += '\n>{}'.format(x) bot.sendMessage(chat_id, '''🤐لیست کلمات فیلتر شده : {}'''.format(text)) if matches[0] == 'mute': if is_mod(message): if 'reply_to_message' in message: user = message['reply_to_message'] if not is_mod(user): name = message['reply_to_message']['from']['first_name'] bot.restrictChatMember(chat_id, user['from']['id'], until_date=time.time() + int(matches[1]) * 86400, can_send_messages=False, can_send_media_messages=False, can_send_other_messages=False, can_add_web_page_previews=False ) bot.sendMessage(chat_id, 'کاربر [{}](tg://user?id={})' ' به مدت {} روز نمیتواند در گروه پیامی ارسال کند😕' .format(name, user['from']['id'], matches[1]), parse_mode='Markdown') else: bot.sendMessage(chat_id, 'ادمینه 🤧') if matches == 'unmute': if is_mod(message): if 'reply_to_message' in message: user = message['reply_to_message'] bot.restrictChatMember(chat_id, user['from']['id'], can_send_messages=True, can_send_media_messages=True, can_send_other_messages=True, can_add_web_page_previews=True) bot.sendMessage(chat_id, 'آزاد شد :)') if matches[0] == 'unmute': if is_mod(message): if 'reply_to_message' in message: bot.restrictChatMember(chat_id, matches[1], can_send_messages=True, can_send_media_messages=True, can_send_other_messages=True, can_add_web_page_previews=True) bot.sendMessage(chat_id, 'آزاد شد :)') if matches[0] == 'mute' and matches[1] == 'all': if is_mod(message): if r.hget('lock_all', chat_id): bot.sendMessage(chat_id, 'قفل گروه از قبل فعال بوده است✔️') else: r.hset('lock_all', chat_id, True) bot.sendMessage(chat_id, 'گروه قفل شد✔️') if matches[0] == 'unmute' and matches[1] == 'all': if is_mod(message): if r.hget('lock_all', chat_id): r.hdel('lock_all', chat_id) bot.sendMessage(chat_id, 'قفل گروه باز شد✅') else: bot.sendMessage(chat_id, 'گروه قفل نبوده ک 🙄') if matches == 'robot': txt = '[{} هستم 🐣](tg://user?id={})'.format(message['from']['first_name'], message['from']['id']) bot.sendMessage(chat_id, txt, parse_mode='Markdown') if matches == 'link': link = bot.exportChatInviteLink(chat_id) text = '''{} {}'''.format(message['chat']['title'], link) bot.sendMessage(chat_id, text) if matches == 'creator': if is_sudo(message): admins = bot.getChatAdministrators(chat_id) for x in admins: if x['status'] == 'creator': print(x) r.hset('owner', chat_id, x['user']['id']) r.hset('owner:{}'.format(chat_id), x['user']['id'], True) text = 'کاربر [{}](tg://user?id={}) ادمین اصلی گروه است'. \ format(x['user']['first_name'], x['user']['id']) bot.sendMessage(chat_id, text, parse_mode='Markdown') if matches == 'time': now = datetime.now(pytz.timezone("Asia/Tehran")).strftime("%H:%M:%S") bot.sendMessage(chat_id, now) if matches == 'admins_set': if is_owner(message): admins = bot.getChatAdministrators(chat_id) bot.sendMessage(chat_id, 'شروع عملیات معرفی کردن کل ادمین های گروه به ربات') i = 1 for x in admins: if x['status'] == 'administrator': print(x) r.sadd('mod:{}'.format(chat_id), x['user']['id']) text = 'کاربر [{}](tg://user?id={}) ادمین ربات در گروه شد'. \ format(x['user']['first_name'], x['user']['id']) bot.sendMessage(chat_id, text, parse_mode='Markdown') i = i + 1 bot.sendMessage(chat_id, 'تعداد {} نفر ادمین ربات شدند'.format(i)) if matches[0] == 'setlang': if is_mod(message): r.hset('lang_gp', chat_id, matches[1]) return [Message(chat_id).set_text(str(ln['ingroup']['setlang']).format(matches[1]))]