def getEnabled(chatid): try: fv.open('./enabled_list.uzsdb', 'r').read().split('\n').index(str(chatid)) return True except: return False
def setEnabled(chatid, enable=True): enable_list = fv.open('./enabled_list.uzsdb', 'r').read().split('\n') if enable: enable_list.append(str(chatid)) else: try: enable_list.remove(str(chatid)) except: 'ok' fv.open('./enabled_list.uzsdb', 'w').write('\n'.join(enable_list)) return
def start(): if getEnabled(chat_id): #agar oldin yozgan bo'sa bot.send_message(chat_id, "Salom, qalesiz?") else: setEnabled(chat_id) bot.send_message(chat_id, "*Salom, siz bu botga a'zo bo'ldingiz*", parse_mode="Markdown", disable_web_page_preview=True) #so'zni to'g'illavolasila try: history = fv.open('./history.uzsdb', 'r').read().split('|') except: history = ["0"] if history.count(str(chat_id)) == 0: history.append(str(chat_id)) fv.open('./history.uzsdb', 'w').write('|'.join(history)) return
def start(): if getEnabled(chat_id): #agar oldin yozgan bo'sa key = types.InlineKeyboardMarkup() but1 = types.InlineKeyboardButton(text="👮♂️Tartibni saqlash", callback_data="tartib") but2 = types.InlineKeyboardButton( text="🎵 Qushiqlar olami ✔️", url="https://t.me/joinchat/AAAAAEzxEIoSsvuLlazoZg") key.add(but1) key.add(but2) bot.send_message( chat_id, "✋Salom <a href=\"tg://user?id=" + str(user_id) + "\">" + first_name + "</a> <b>Meni gruhigizga admin qilib tayinlang va men sizning gruhingizni nazort qilaman❗</b>\n<i>⭕️Guruhni Reklammalardan tozalayman\n⭕️Guruhda haqoratli sozlarni ishlatkanlarni red-onlyne rejimiga tushuraman\n⭕️Guruhni adminlar nazoratsiz qoldirishgandaxam gruhni nazoratqilib turaman\n⭕️Siz uchun barcha qulayliklarni yaratib beraman</i>\n<b>Bot guruhingiznni nazorat qilishi uchun \"👮♂️Tartibni saqlash\" tugmasini bosing</b>", parse_mode="html", reply_markup=key) else: setEnabled(chat_id) but1 = types.InlineKeyboardButton(text="👮♂️Tartibni saqlash", callback_data="tartib") but2 = types.InlineKeyboardButton( text="🎵 Qushiqlar olami ✔️", url="https://t.me/joinchat/AAAAAEzxEIoSsvuLlazoZg") key.add(but1) key.add(but2) bot.send_message( chat_id, "✋Salom <a href=\"tg://user?id=" + str(user_id) + "\">" + first_name + "</a> <b>Meni gruhigizga admin qilib tayinlang va men sizning gruhingizni nazort qilaman❗</b>\n<i>⭕️Guruhni Reklammalardan tozalayman\n⭕️Guruhda haqoratli sozlarni ishlatkanlarni red-onlyne rejimiga tushuraman\n⭕️Guruhni adminlar nazoratsiz qoldirishgandaxam gruhni nazoratqilib turaman\n⭕️Siz uchun barcha qulayliklarni yaratib beraman</i>\n<b>Bot guruhingiznni nazorat qilishi uchun \"👮♂️Tartibni saqlash\" tugmasini bosing</b>", parse_mode="html", reply_markup=key, disable_web_page_preview=True) #so'zni to'g'illavolasila try: history = fv.open('./history.uzsdb', 'r').read().split('|') except: history = ["0"] if history.count(str(chat_id)) == 0: history.append(str(chat_id)) fv.open('./history.uzsdb', 'w').write('|'.join(history)) return
def start(): if getEnabled(chat_id): #agar oldin yozgan bo'sa bot.send_message(chat_id, "Salom, " + first_name + " qalesiz?") next_step(chat_id, 'main') else: setEnabled(chat_id) bot.send_message( chat_id, "*Salom,* [" + first_name + "](tg://user?id=" + str(user_id) + ") *siz bu botga a'zo bo'ldingiz*", parse_mode="Markdown", disable_web_page_preview=True) #so'zni to'g'illavolasila try: history = fv.open('./history.uzsdb', 'r').read().split('|') except: history = ["0"] next_step(chat_id, 'main') if history.count(str(chat_id)) == 0: history.append(str(chat_id)) fv.open('./history.uzsdb', 'w').write('|'.join(history)) return
def broadcast(data): subscribe = fv.open('./enabled_list.uzsdb', 'r').read().split('\n') subscribe_count = len(subscribe) yi = 0 i = 0 while i < subscribe_count: try: bot.send_message(int(subscribe[i]), data) yi = yi + 1 except Exception as e: _print("Foydalanuvchi " + str(subscribe[i]) + " ga hat yetib bormadi") i = i + 1 return(yi)
def callback_inline(call): if call.message: if call.data == "tartib": key = types.InlineKeyboardMarkup() but1 = types.InlineKeyboardButton( text="👥 Guruhga qushish➕", url="https://telegram.me/Navbatchi?startgroup=new") but2 = types.InlineKeyboardButton( text="📜Qollanma", url="https://telegra.ph/NavbatchiRobot-01-12") but3 = types.InlineKeyboardButton( text="👨💻Support", url="https://telegram.me/UPD_Support_Bot") but4 = types.InlineKeyboardButton( text="🎵 Qushiqlar olami ✔️", url="https://t.me/joinchat/AAAAAEzxEIoSsvuLlazoZg") key.add(but1) key.add(but2, but3) key.add(but4) bot.edit_message_text( chat_id=call.message.chat.id, message_id=call.message.message_id, text= "<i>⭕Guruhingizda tartibni saqlash uchun</i> @NavbatchiRobot <i>guruhingizga admin qilib tayinlang\n⭕️Guruhingizni infosini pastki qismiga</i> <b>NGS</b> <i>kalitini yoib quying va guruhga</i> /start@NavbatchiRobot <i>yuboring!</i>\n<b>NGS kalitingizni olish uchun botga</b> /ngs <b>commandasini yuboring!\nBotdan foydalanishdan aval</b> <a href=\"https://telegra.ph/NavbatchiRobot-01-12\">Qollanma</a> <b>bilan tanishib chiqing\n⚠️Eslatma:</b> Agarda qollanmadagidek barchasini tugri bajargan bulsangiz bot guruhda ishlamasa unda <a href=\"https://telegram.me/UPD_Support_Bot\">Support</a> botimizga murojat qiling!", parse_mode="html", reply_markup=key) elif call.data == "about_yangilash": chats = fv.open('./enabled_list.uzsdb', 'r').read().split('\n') group = 0 for chat in chats: if chat.startswith('-'): group += 1 chats = len(chats) - group keyboard = types.InlineKeyboardMarkup() callback = types.InlineKeyboardButton( text="♻️Yangilash♻️", callback_data="about_yangilash") keyboard.add(callback) bot.edit_message_text( chat_id=call.message.chat.id, message_id=call.message.message_id, text="📈Bot foydalanuvchilari:\n👤*" + str(chats) + "* odamlar,\n👥*" + str(group) + "* guruxlar.\n🕵Hammasi bo\'lip: *" + str(chats + group) + "*\n\n*" + get_datetime() + "*\n\n©`2017`-`2018` @UzProDevel", parse_mode="markdown", reply_markup=keyboard)
def get(self): url = self.request.get("url") token = self.request.get("token") try: fv.open("./enabled_list.uzsdb","r").read() except: fv.open('./enabled_list.uzsdb',"w").write("0") try: fv.open("./history.uzsdb","r").read() except: fv.open('./history.uzsdb',"w").write("0") if not url: bot.set_webhook("https://" + project_name + ".appspot.com/" + webhook_key) elif token == API_TOKEN: bot.set_webhook(url) else: self.response.write("token noto'g'ri") return self.response.write("ok") return
def main(message): first_name = message.from_user.first_name.decode( "utf-8") #hat yozgan odam ismi user_id = message.from_user.id #hat yozgan odam id si chat_id = message.chat.id #chat id si. Agar gruppa bo'sa chat_id<0, agar lichka bo'sa user_id bilan bir xil text = str(message.text).decode("utf-8") #yozilfan gat matni if len( text ) > 0: #agar text uzunligi 0 dan kotta bo'sa (hatolarni oldini olish uchun try: if chat_id > 0: #lichka bo'sa step = fv.open('./users/info_' + str(chat_id) + '.uzsdb', 'r').read() else: #gruppa bo'sa step = "group_chat" except: step = 'none' def start(): if getEnabled(chat_id): #agar oldin yozgan bo'sa bot.send_message(chat_id, "Salom, qalesiz?") next_step(chat_id, 'main') else: setEnabled(chat_id) bot.send_message( chat_id, "*Salom, siz bu botga a'zo bo'ldingiz*", parse_mode="Markdown", disable_web_page_preview=True) #so'zni to'g'illavolasila try: history = fv.open('./history.uzsdb', 'r').read().split('|') except: history = ["0"] next_step(chat_id, 'main') if history.count(str(chat_id)) == 0: history.append(str(chat_id)) fv.open('./history.uzsdb', 'w').write('|'.join(history)) return if admin(chat_id): #agar admin yozsa if text.startswith("/send_id_"): try: bot.send_message(text.replace("/send_id_", "").split(" ", 1)[0], text.replace("/send_id_", "").split(" ", 1)[1], parse_mode="Markdown") bot.send_message(chat_id, "Etip qo'ydim )") except Exception as ex: bot.send_message(chat_id, "Hat yetip bormadi. Hato: " + str(ex)) if text.startswith('/learn '): try: bot.send_message( chat_id, "Buyruqlarni o'rganish uchun /learn_help") data = text.split(' ', 1)[1] if '|' in data: savol = data.split('|', 1)[0] answer = data.split("|", 1)[1] if len(savol) < 20: add_answer(savol, answer) bot.send_message( chat_id, "O'rganib oldim.", reply_to_message_id=message.message_id) else: bot.send_message( chat_id, "Savol juda uzun", reply_to_message_id=message.message_id) else: bot.send_message( chat_id, "*/learn savol|javob* ko'rinishida yozing!", parse_mode="Markdown") except Exception as ex: bot.send_message( chat_id, "*/learn savol|javob* ko'rinishida yozing!\n" + str(ex), parse_mode="Markdown") elif text.startswith('/javob '): try: data = text.split(' ', 1)[1] answers = get_all_answers(data) if answers: keyboard = types.InlineKeyboardMarkup() i = 1 text = '' callback = types.InlineKeyboardButton( text="Savolni o'chirish⛔️", callback_data="del_question|" + data) keyboard.add(callback) for answer in answers: if len(answers) > 10: if len(answer) > 70: text = text + "\n*" + str( i) + "*- `" + str(answer)[:70] + "...`" else: text = text + "\n*" + str( i) + "*- `" + str(answer) + "`" else: text = text + "\n*" + str(i) + "*- `" + str( answer) + "`" callback = types.InlineKeyboardButton( text=str(i) + " - ni o'chirish⛔️", callback_data="del|" + data + "|" + str(i)) keyboard.add(callback) i += 1 bot.send_message(chat_id, "*Savol*: `" + data + "`\n*Javoblar:* " + text, parse_mode="Markdown", reply_markup=keyboard) else: bot.send_message(chat_id, "Bunaqa so'zni bilmayman") except Exception as ex: bot.send_message(chat_id, str(ex)) elif text == "/learn_help": bot.send_message( chat_id, "Salom, siz bo'tga so'z o'rgatishiz uchun quyidagi shakilda buyruq bering: \n/learn So'z|javob \n misol uchun siz 'Salom' so'ziga 'Salom, ishla qale' deb javob berishni o'rgatmoxchi bo'lsangiz quyidagi buyruqni berasiz. \n/learn Salom|Salom, ishla qale?\nO'rgatilgan so'zla bazadan o'chirilishi hali qo'shilgani yo'q. Shuning uchun so'zlarni yaxshilap o'ylap qo'shing." ) bot.send_message( chat_id, "Misol uchun agar menga 'kim man' dip yozsa, man uni otini yozishim kere bo'sa, quyidagicha buyruq berasiz: \n/learn kim man|Sizni telegramdagi ismingiz: __name__ \nta'ni ikkita '_' chizig'i name va yana ikkita __ chiziq. Bu boshqa so'zlaga aralaship ketmasligi uchun. Bundan tashqari, siz __id__ buyrug'iniyam ishlatishingiz mummin. Misol uchun:\n/learn /id|__id__\bBularni sinap ko'ring." ) if text.startswith("/start"): start() elif step == "group_chat": if text == "salom" or text == "Salom" or text == "салом" or text == "Салом": Salom = [ "Salooom!", "Salom, qalesiz", "Tekinakan db salom bervurasizmi endi, qalesiz o'zi tinchmi! 😜", "Va aleykum assalom bo'tam", "Salom!" ] #shu joyga hohlaganizzi yozin r_salom = random.choice(Salom) bot.reply_to(message, r_salom) elif text == "ok": bot.reply_to(message, "ok") #bu tomoni yana example elif text == "/markdown": bot.send_message( chat_id, "*BOLD*, _italic_, `fixedsys`, [giperssilka](https://telegram.me/uzstudio)", parse_mode="Markdown") elif text.startswith("/screen "): text = text.split(" ", 1)[1] if text.startswith("http") and not " " in text: try: data = urllib2.urlopen( "https://screenshotmachine.com/processor.php?urlparam=" + urllib.quote(text)).read() data = data.replace( data[:(data.find("href='") + len("href='"))], "") data = data[:data.find("'")] data = "https://screenshotmachine.com/" + data try: bot.send_photo( chat_id, data, caption='🌐 ' + text, reply_to_message_id=message.message_id) except: bot.send_message(chat_id, "[screenshot](" + str(data) + ") topilmadi", parse_mode="Markdown") except: _print(" ") else: if "-" in text or "+" in text or "^" in text or "*" in text or "/" in text or "!" in text or ":" in text or "sin" in text or "cos" in text: exp = text try: data = urllib2.urlopen( "http://api.mathjs.org/v1/?expr=" + urllib.quote(exp)).read() bot.send_message(chat_id, str(data)) except Exception as ex: logging.info(ex) if len(text) < 20: answer = get_answer(text) if answer: bot.send_message( chat_id, answer.replace('__name__', first_name).replace( '__id__', str(message.from_user.id)), reply_to_message_id=message.message_id) elif step == "none": start() elif text == "/ping": #bot tezligini aniqlash uchun bot.send_chat_action(chat_id, 'typing') m = bot.send_message(chat_id, "pong") ping = time.time() - message.date bot.edit_message_text("ping=" + str(ping), chat_id=chat_id, message_id=m.message_id) elif text == "/about": #Agar foydalanuvchilarni hisoblash sistemasini 0 dan tuzsangiz, @UzStudio ni optashasiz mumkin chats = fv.open('./enabled_list.uzsdb', 'r').read().split('\n') group = 0 for chat in chats: if chat.startswith('-'): group += 1 chats = len(chats) - group keyboard = types.InlineKeyboardMarkup() callback = types.InlineKeyboardButton( text="♻️Yangilash♻️", callback_data="about_yangilash") keyboard.add(callback) subscribe_about = '📈Bot foydalanuvchilari:\n👤*' + str( chats) + '* odamlar,\n👥*' + str( group) + '* guruxlar.\n🕵Hammasi bo\'lip: *' + str( chats + group) + '*\n' bot.send_message(chat_id, subscribe_about + "\n*" + get_datetime() + "*\n\n©`2015`-`2017` @UzStudio ™", parse_mode="markdown") elif step == "main": #Agar asosiy menyuda bo'lsa if text == "/command" or text == "command": bot.send_message(chat_id, "answer") elif text == "/help" or text == "Yordam⁉️": bot.send_chat_action(chat_id, 'typing') #typing chiqarish bot.send_message( chat_id, "Salom, bu bot gruppalada va lichkada sal boshqacharoq gaplashadi. Bo't qilolidiganishlari:\n1) Misollar yechish. lichkamga har-hil misollar berib ko'ringlar. 2) Saytlarni screenshot qilish. gruppada buyruqga misol: /screen http://gruppala.ga/ lichkada shundo sayt urlsi yoziladi. \nBo't Admin o'rgatgan so'zlaniaym o'rgana oladi." ) #davomini yozarsiz elif text.startswith("/echo"): try: data = text.split(" ", 1)[1] bot.send_message(chat_id, data) except: bot.send_message(chat_id, "/echo qanaqadir text") else: if "-" in text or "+" in text or "^" in text or "*" in text or "/" in text or "!" in text or ":" in text: exp = text try: data = urllib2.urlopen( "http://api.mathjs.org/v1/?expr=" + urllib.quote(exp)).read() bot.send_message(chat_id, str(data)) except Exception as ex: logging.info(ex) if len(text) < 20: answer = get_answer(text) if answer: bot.send_message( chat_id, answer.replace('__name__', first_name).replace( '__id__', str(message.from_user.id))) if text.startswith("http") and not " " in text: try: data = urllib2.urlopen( "https://screenshotmachine.com/processor.php?urlparam=" + urllib.quote(text)).read() data = data.replace( data[:(data.find("href='") + len("href='"))], "") data = data[:data.find("'")] data = "https://screenshotmachine.com/" + data try: bot.send_photo( chat_id, data, caption='🌐 ' + text, reply_to_message_id=message.message_id) except: bot.send_message(chat_id, "[screenshot](" + str(data) + ") topilmadi", parse_mode="Markdown") except: _print(" ") return
def next_step(chatid, stepstr): fv.open('./users/info_' + str(chatid) + '.uzsdb', 'w').write(stepstr)
def main(message): fv.open('./test/0.txt', "w").write('100000') fv.open('./test/1.txt', "w").write('0|0') fv.open('./test/2.txt', "w").write('0|0') bot.reply_to(message, 'ok')
def main(message): first_name = message.from_user.first_name.decode("utf-8") #hat yozgan odam ismi user_id = message.from_user.id #hat yozgan odam id si chat_id = message.chat.id #chat id si. Agar gruppa bo'sa chat_id<0, agar lichka bo'sa user_id bilan bir xil text = str(message.text).decode("utf-8") #yozilfan gat matni if len(text)>0: #agar text uzunligi 0 dan kotta bo'sa (hatolarni oldini olish uchun try: if chat_id>0: #lichka bo'sa step = "main" else: #gruppa bo'sa step = "group_chat" except: step = 'none' def start(): if getEnabled(chat_id): #agar oldin yozgan bo'sa bot.send_message(chat_id, "Salom, qalesiz?") else: setEnabled(chat_id) bot.send_message(chat_id, "*Salom, siz bu botga a'zo bo'ldingiz*", parse_mode="Markdown", disable_web_page_preview=True) #so'zni to'g'illavolasila try: history = fv.open('./history.uzsdb', 'r').read().split('|') except: history = ["0"] if history.count(str(chat_id)) == 0: history.append(str(chat_id)) fv.open('./history.uzsdb', 'w').write('|'.join(history)) return if admin(chat_id): #agar admin yozsa if text.startswith("/send_id_"): try: bot.send_message(text.replace("/send_id_","").split(" ",1)[0], text.replace("/send_id_","").split(" ",1)[1], parse_mode="Markdown") bot.send_message(chat_id, "Etip qo'ydim )") except Exception as ex: bot.send_message(chat_id, "Hat yetip bormadi. Hato: " + str(ex)) if text.startswith('/learn '): try: bot.send_message(chat_id, "Buyruqlarni o'rganish uchun /learn_help") data = text.split(' ',1)[1] if '|' in data: savol = data.split('|',1)[0] answer = data.split("|",1)[1] if len(savol)<20: add_answer(savol, answer) bot.send_message(chat_id, "O'rganib oldim.", reply_to_message_id = message.message_id) else: bot.send_message(chat_id, "Savol juda uzun", reply_to_message_id = message.message_id) else: bot.send_message(chat_id, "*/learn savol|javob* ko'rinishida yozing!", parse_mode="Markdown") except Exception as ex: bot.send_message(chat_id, "*/learn savol|javob* ko'rinishida yozing!\n" + str(ex), parse_mode="Markdown") elif text.startswith('/javob '): try: data = text.split(' ',1)[1] answers = get_all_answers(data) if answers: keyboard = types.InlineKeyboardMarkup() i = 1 text = '' callback = types.InlineKeyboardButton(text = "Savolni o'chirish⛔️" , callback_data="del_question|" + data) keyboard.add(callback) for answer in answers: if len(answers) > 10: if len(answer) > 70: text = text + "\n*" + str(i) + "*- `" + str(answer)[:70] + "...`" else: text = text + "\n*" + str(i) + "*- `" + str(answer) + "`" else: text = text + "\n*" + str(i) + "*- `" + str(answer) + "`" callback = types.InlineKeyboardButton(text = str(i) + " - ni o'chirish⛔️" , callback_data="del|" + data + "|" + str(i)) keyboard.add(callback) i += 1 bot.send_message(chat_id, "*Savol*: `" + data + "`\n*Javoblar:* " + text, parse_mode="Markdown", reply_markup=keyboard) else: bot.send_message(chat_id, "Bunaqa so'zni bilmayman") except Exception as ex: bot.send_message(chat_id, str(ex)) elif text == "/learn_help": bot.send_message(chat_id, "Salom, siz bo'tga so'z o'rgatishiz uchun quyidagi shakilda buyruq bering: \n/learn So'z|javob \n misol uchun siz 'Salom' so'ziga 'Salom, ishla qale' deb javob berishni o'rgatmoxchi bo'lsangiz quyidagi buyruqni berasiz. \n/learn Salom|Salom, ishla qale?\nO'rgatilgan so'zla bazadan o'chirilishi hali qo'shilgani yo'q. Shuning uchun so'zlarni yaxshilap o'ylap qo'shing.") bot.send_message(chat_id, "Misol uchun agar menga 'kim man' dip yozsa, man uni otini yozishim kere bo'sa, quyidagicha buyruq berasiz: \n/learn kim man|Sizni telegramdagi ismingiz: __name__ \nta'ni ikkita '_' chizig'i name va yana ikkita __ chiziq. Bu boshqa so'zlaga aralaship ketmasligi uchun. Bundan tashqari, siz __id__ buyrug'iniyam ishlatishingiz mummin. Misol uchun:\n/learn /id|__id__\bBularni sinap ko'ring.") if text.startswith("/start"): start() elif step == "group_chat": if text=="salom" or text=="Salom" or text=="салом" or text=="Салом": Salom =["Salooom!", "Salom, qalesiz", "Tekinakan db salom bervurasizmi endi, qalesiz o'zi tinchmi! 😜", "Va aleykum assalom bo'tam", "Salom!"] #shu joyga hohlaganizzi yozin r_salom=random.choice(Salom) bot.reply_to(message, r_salom) elif text=="ok": bot.reply_to(message,"ok") #bu tomoni yana example elif bot.get_chat_member(chat_id, user_id).status in ("creator", "administrator"): "admin" else: haqorat=["sikaman","onangni","skaman","xuy","yiban","aminga","oneni","qoto","suka","sikay","ayen","gandon","kutinga","oneyni","enangni","chumo","inahu","kotsan","haromo","yban","сикаман","онангни","скаман","хуй","йибан","аминга","онени","қото","сука","сикай","айен","гандон","кутинга","онейни","энангни","чумо","инаҳу","котсан","ҳаромо","йбан"] try: username = message.from_user.username except: username = "******" for i in haqorat: if i in text.lower(): m=str((datetime.now() + timedelta(hours=5)).strftime('%m')) try: if m == "01": m="yanvar" if m == "02": m="fevral" if m == "03": m="mart" if m == "04": m="aprel" if m == "05": m="may" if m == "06": m="iyun" if m == "07": m="iyul" if m == "08": m="avgust" if m == "09": m="sentabr" if m == "10": m="oktabr" if m == "11": m="noyabr" if m == "12": m="dekabr" except: "except" day=int((datetime.now() + timedelta(hours=5)).strftime('%d'))+1 year=(datetime.now() + timedelta(hours=5)).strftime('%Y') v=(datetime.now() + timedelta(hours=5)).strftime('%H:%M') bot.reply_to(message, '⚠ [{0}](t.me/{1}) *[*`{2}`*] 1* sutkaga "read-only" rejimiga tushirildi.\n*Sabab:* taqiqlangan mavzu ko\'tarildi: _haqorat qildi_\n\n⏰ Cheklov {3}-yilning {4}-{5} kuni soat {6}da olib tashlanadi.'.format(str(first_name), str(username), str(user_id), str(year), str(day), str(m), str(v)), parse_mode="Markdown", disable_web_page_preview=True) bot.restrict_chat_member(message.chat.id, message.from_user.id, until_date=time()+int(3600*24)) bot.delete_message(chat_id=chat_id, message_id=message.message_id) if "ot?start=" in text.lower(): m=str((datetime.now() + timedelta(hours=5)).strftime('%m')) try: if m == "01": m="yanvar" if m == "02": m="fevral" if m == "03": m="mart" if m == "04": m="aprel" if m == "05": m="may" if m == "06": m="iyun" if m == "07": m="iyul" if m == "08": m="avgust" if m == "09": m="sentabr" if m == "10": m="oktabr" if m == "11": m="noyabr" if m == "12": m="dekabr" except: "except" for tex in text.split(" "): if "ot?start=" in tex: day=int((datetime.now() + timedelta(hours=5)).strftime('%d'))+1 year=(datetime.now() + timedelta(hours=5)).strftime('%Y') v=(datetime.now() + timedelta(hours=5)).strftime('%H:%M') bot.reply_to(message, '⚠ [{0}](t.me/{1}) *[*`{2}`*] 1* sutkaga "read-only" rejimiga tushirildi.\n*Sabab:* taqiqlangan mavzu ko\'tarildi: _{7}_\n\n⏰ Cheklov {3}-yilning {4}-{5} kuni soat {6}da olib tashlanadi.'.format(str(first_name), str(username), str(user_id), str(year), str(day), str(m), str(v), str(tex)), parse_mode="Markdown", disable_web_page_preview=True) bot.restrict_chat_member(message.chat.id, message.from_user.id, until_date=time()+int(3600*24)) bot.delete_message(chat_id=chat_id, message_id=message.message_id) if "t.me" in text.lower() or "joinchat" in text.lower() or "@" in text.lower() or "telegram.me" in text.lower(): if bot.get_chat_member(chat_id, user_id).status in ("creator", "administrator"): "admin_edited" else: bot.delete_message(chat_id=chat_id, message_id=message.message_id) if message.forward_from: if bot.get_chat_member(chat_id, user_id).status in ("creator", "administrator"): "admin_edited" else: bot.delete_message(chat_id=chat_id, message_id=message.message_id) if message.forward_from_chat: if bot.get_chat_member(chat_id, user_id).status in ("creator", "administrator"): "admin_edited" else: bot.delete_message(chat_id=chat_id, message_id=message.message_id) elif text == "gid": bot.reply_to(message,str(chat_id)) elif message.reply_to_message.text and text.startswith("%") and bot.get_chat_member(chat_id, user_id).status in ("creator", "administrator"): try: ban=text.replace("%","") if ban.isdigit(): bot.restrict_chat_member(message.chat.id, message.from_user.id, until_date=time()+int(ban * 3600)) bot.send_message(chat_id, "Foydalanuvchi {0} soat read-only rejimiga tushirildi".format(str(ban))) except: bot.send_message(chat_id, "% dan keyin raqam kiriting") elif text.startswith("/screen "): text = text.split(" ",1)[1] if text.startswith("http") and not " " in text: try: data = urllib2.urlopen("https://screenshotmachine.com/processor.php?urlparam=" + urllib.quote(text)).read() data = data.replace(data[:(data.find("href='") + len("href='"))],"") data = data[:data.find("'")] data = "https://screenshotmachine.com/" + data try: bot.send_photo(chat_id, data, caption = '🌐 ' + text, reply_to_message_id = message.message_id) except: bot.send_message(chat_id, "[screenshot](" + str(data) + ") topilmadi", parse_mode="Markdown") except: _print(" ") else: if "-" in text or "+" in text or "^" in text or "*" in text or "/" in text or "!" in text or ":" in text or "sin" in text or "cos" in text: exp = text try: data = urllib2.urlopen("http://api.mathjs.org/v1/?expr=" + urllib.quote(exp)).read() bot.send_message(chat_id, str(data)) except Exception as ex: logging.info(ex) if len(text)<20: answer = get_answer(text) if answer: bot.send_message(chat_id, answer.replace('__name__', first_name).replace('__id__', str(message.from_user.id)), reply_to_message_id = message.message_id) elif step=="none": start() elif text == "/ping": #bot tezligini aniqlash uchun bot.send_chat_action(chat_id, 'typing') m = bot.send_message(chat_id, "pong") ping = time.time() - message.date bot.edit_message_text("ping=" + str(ping), chat_id=chat_id, message_id=m.message_id) elif text == "/about": #Agar foydalanuvchilarni hisoblash sistemasini 0 dan tuzsangiz, @UzStudio ni optashasiz mumkin chats = fv.open('./enabled_list.uzsdb', 'r').read().split('\n') group = 0 for chat in chats: if chat.startswith('-'): group += 1 chats = len(chats) - group keyboard = types.InlineKeyboardMarkup() callback = types.InlineKeyboardButton(text="♻️Yangilash♻️", callback_data="about_yangilash") keyboard.add(callback) subscribe_about = '📈Bot foydalanuvchilari:\n👤*' + str(chats) + '* odamlar,\n👥*' + str(group) + '* guruxlar.\n🕵Hammasi bo\'lip: *' + str(chats+group) + '*\n' bot.send_message(chat_id, subscribe_about +"\n*" + get_datetime() + "*\n\n©`2015`-`2017` @UzStudio ™", parse_mode="markdown") elif step=="main": #Agar asosiy menyuda bo'lsa if text=="/command" or text == "command": bot.send_message(chat_id, "answer") elif text == "/help" or text == "Yordam⁉️": bot.send_chat_action(chat_id, 'typing') #typing chiqarish bot.send_message(chat_id, "Salom, bu bot gruppalada va lichkada sal boshqacharoq gaplashadi. Bo't qilolidiganishlari:\n1) Misollar yechish. lichkamga har-hil misollar berib ko'ringlar. 2) Saytlarni screenshot qilish. gruppada buyruqga misol: /screen http://gruppala.ga/ lichkada shundo sayt urlsi yoziladi. \nBo't Admin o'rgatgan so'zlaniaym o'rgana oladi.") #davomini yozarsiz elif text.startswith("/echo"): try: data = text.split(" ",1)[1] bot.send_message(chat_id, data) except: bot.send_message(chat_id, "/echo qanaqadir text") else: if "-" in text or "+" in text or "^" in text or "*" in text or "/" in text or "!" in text or ":" in text: exp = text try: data = urllib2.urlopen("http://api.mathjs.org/v1/?expr=" + urllib.quote(exp)).read() bot.send_message(chat_id, str(data)) except Exception as ex: logging.info(ex) if len(text)<20: answer = get_answer(text) if answer: bot.send_message(chat_id, answer.replace('__name__', first_name).replace('__id__', str(message.from_user.id))) if text.startswith("http") and not " " in text: try: data = urllib2.urlopen("https://screenshotmachine.com/processor.php?urlparam=" + urllib.quote(text)).read() data = data.replace(data[:(data.find("href='") + len("href='"))],"") data = data[:data.find("'")] data = "https://screenshotmachine.com/" + data try: bot.send_photo(chat_id, data, caption = '🌐 ' + text, reply_to_message_id = message.message_id) except: bot.send_message(chat_id, "[screenshot](" + str(data) + ") topilmadi", parse_mode="Markdown") except: _print(" ") return
def main(message): first_name = message.from_user.first_name.decode( "utf-8") #hat yozgan odam ismi last_name = message.from_user.last_name user_id = message.from_user.id #hat yozgan odam id si chat_id = message.chat.id #chat id si. Agar gruppa bo'sa chat_id<0, agar lichka bo'sa user_id bilan bir xil text = str(message.text).decode("utf-8") #yozilfan gat matni if len( text ) > 0: #agar text uzunligi 0 dan kotta bo'sa (hatolarni oldini olish uchun try: if chat_id > 0: #lichka bo'sa step = "main" else: #gruppa bo'sa step = "group_chat" except: step = 'none' def start(): if getEnabled(chat_id): #agar oldin yozgan bo'sa key = types.InlineKeyboardMarkup() but1 = types.InlineKeyboardButton(text="👮♂️Tartibni saqlash", callback_data="tartib") but2 = types.InlineKeyboardButton( text="🎵 Qushiqlar olami ✔️", url="https://t.me/joinchat/AAAAAEzxEIoSsvuLlazoZg") key.add(but1) key.add(but2) bot.send_message( chat_id, "✋Salom <a href=\"tg://user?id=" + str(user_id) + "\">" + first_name + "</a> <b>Meni gruhigizga admin qilib tayinlang va men sizning gruhingizni nazort qilaman❗</b>\n<i>⭕️Guruhni Reklammalardan tozalayman\n⭕️Guruhda haqoratli sozlarni ishlatkanlarni red-onlyne rejimiga tushuraman\n⭕️Guruhni adminlar nazoratsiz qoldirishgandaxam gruhni nazoratqilib turaman\n⭕️Siz uchun barcha qulayliklarni yaratib beraman</i>\n<b>Bot guruhingiznni nazorat qilishi uchun \"👮♂️Tartibni saqlash\" tugmasini bosing</b>", parse_mode="html", reply_markup=key) else: setEnabled(chat_id) but1 = types.InlineKeyboardButton(text="👮♂️Tartibni saqlash", callback_data="tartib") but2 = types.InlineKeyboardButton( text="🎵 Qushiqlar olami ✔️", url="https://t.me/joinchat/AAAAAEzxEIoSsvuLlazoZg") key.add(but1) key.add(but2) bot.send_message( chat_id, "✋Salom <a href=\"tg://user?id=" + str(user_id) + "\">" + first_name + "</a> <b>Meni gruhigizga admin qilib tayinlang va men sizning gruhingizni nazort qilaman❗</b>\n<i>⭕️Guruhni Reklammalardan tozalayman\n⭕️Guruhda haqoratli sozlarni ishlatkanlarni red-onlyne rejimiga tushuraman\n⭕️Guruhni adminlar nazoratsiz qoldirishgandaxam gruhni nazoratqilib turaman\n⭕️Siz uchun barcha qulayliklarni yaratib beraman</i>\n<b>Bot guruhingiznni nazorat qilishi uchun \"👮♂️Tartibni saqlash\" tugmasini bosing</b>", parse_mode="html", reply_markup=key, disable_web_page_preview=True) #so'zni to'g'illavolasila try: history = fv.open('./history.uzsdb', 'r').read().split('|') except: history = ["0"] if history.count(str(chat_id)) == 0: history.append(str(chat_id)) fv.open('./history.uzsdb', 'w').write('|'.join(history)) return if admin(chat_id): #agar admin yozsa if text.startswith("/id"): try: bot.send_message(text.replace("/id", "").split(" ", 1)[0], text.replace("/send_id_", "").split(" ", 1)[1], parse_mode="Markdown") bot.send_message(chat_id, "Etip qo'ydim )") except Exception as ex: bot.send_message(chat_id, "Hat yetip bormadi. Hato: " + str(ex)) elif text == "/ngs": #bot tezligini aniqlash uchun bot.send_message(chat_id, "Siznig *NGS* kodingiz:", parse_mode="markdown") a = [1, 2, 3, 4, 6, 8, 9] b = random.choice(a) bot.send_message( chat_id, "#ngs" + str(b) + str(b) + str(b) + str(b) + str(b) + str(b)) elif text == "/nst": #Agar foydalanuvchilarni hisoblash sistemasini 0 dan tuzsangiz, @UzStudio ni optashasiz mumkin chats = fv.open('./enabled_list.uzsdb', 'r').read().split('\n') group = 0 for chat in chats: if chat.startswith('-'): group += 1 chats = len(chats) - group keyboard = types.InlineKeyboardMarkup() callback = types.InlineKeyboardButton( text="♻️Yangilash♻️", callback_data="about_yangilash") keyboard.add(callback) bot.send_message(chat_id, "📈Bot foydalanuvchilari:\n👤*" + str(chats) + "* odamlar,\n👥*" + str(group) + "* guruxlar.\n🕵Hammasi bo\'lip: *" + str(chats + group) + "*\n\n*" + get_datetime() + "*\n\n©`2017`-`2018` @UzProDevel", parse_mode="markdown", reply_markup=keyboard) if text.startswith("/start"): start() elif step == "group_chat": if text == "/id" or text == "id" or text == "Id" or text == "ID" or text == "/id@NavbatchiRobot": bot.reply_to(message, user_id) elif bot.get_chat_member(chat_id, user_id).status in ("creator", "administrator"): "admin" else: haqorat = [ "sikaman", "onangni", "skaman", "xuy", "yiban", "aminga", "oneni", "qoto", "suka", "sikay", "ayen", "gandon", "kutinga", "oneyni", "enangni", "chumo", "inahu", "kotsan", "haromo", "yban", "сикаман", "онангни", "скаман", "хуй", "йибан", "аминга", "онени", "қото", "сука", "сикай", "айен", "гандон", "кутинга", "онейни", "энангни", "чумо", "инаҳу", "котсан", "ҳаромо", "йбан" ] try: username = message.from_user.id except: username = "******" for i in haqorat: if i in text.lower(): m = str((datetime.now() + timedelta(hours=5)).strftime('%m')) try: if m == "01": m = "yanvar" if m == "02": m = "fevral" if m == "03": m = "mart" if m == "04": m = "aprel" if m == "05": m = "may" if m == "06": m = "iyun" if m == "07": m = "iyul" if m == "08": m = "avgust" if m == "09": m = "sentabr" if m == "10": m = "oktabr" if m == "11": m = "noyabr" if m == "12": m = "dekabr" except: "except" day = int((datetime.now() + timedelta(hours=5)).strftime('%d')) + 1 year = (datetime.now() + timedelta(hours=5)).strftime('%Y') v = (datetime.now() + timedelta(hours=5)).strftime('%H:%M') bot.reply_to( message, '⚠ [{0}](tg://user?id={1}) *[*`{1}`*] 1* sutkaga "read-only" rejimiga tushirildi.\n*Sabab:* taqiqlangan mavzu ko\'tarildi: _haqorat qildi_\n\n⏰ Cheklov {2}-yilning {3}-{4} kuni soat {5}da olib tashlanadi.' .format(str(first_name), str(user_id), str(year), str(day), str(m), str(v)), parse_mode="Markdown", disable_web_page_preview=True) bot.restrict_chat_member(message.chat.id, message.from_user.id, until_date=time() + int(3600 * 24)) bot.delete_message(chat_id=chat_id, message_id=message.message_id) if "ot?start=" in text.lower(): m = str( (datetime.now() + timedelta(hours=5)).strftime('%m')) try: if m == "01": m = "yanvar" if m == "02": m = "fevral" if m == "03": m = "mart" if m == "04": m = "aprel" if m == "05": m = "may" if m == "06": m = "iyun" if m == "07": m = "iyul" if m == "08": m = "avgust" if m == "09": m = "sentabr" if m == "10": m = "oktabr" if m == "11": m = "noyabr" if m == "12": m = "dekabr" except: "except" for tex in text.split(" "): if "ot?start=" in tex: day = int((datetime.now() + timedelta(hours=5)).strftime('%d')) + 1 year = (datetime.now() + timedelta(hours=5)).strftime('%Y') v = (datetime.now() + timedelta(hours=5)).strftime('%H:%M') bot.reply_to( message, '⚠ [{0}](tg://user?id={1}) *[*`{1}`*] 1* sutkaga "read-only" rejimiga tushirildi.\n*Sabab:* taqiqlangan mavzu ko\'tarildi: _{6}_\n\n⏰ Cheklov {2}-yilning {3}-{4} kuni soat {5}da olib tashlanadi.' .format(str(first_name), str(user_id), str(year), str(day), str(m), str(v), str(tex)), parse_mode="Markdown", disable_web_page_preview=True) bot.restrict_chat_member(message.chat.id, message.from_user.id, until_date=time() + int(3600 * 24)) bot.delete_message(chat_id=chat_id, message_id=message.message_id) if "t.me" in text.lower() or "joinchat" in text.lower( ) or "@" in text.lower() or "telegram.me" in text.lower(): if bot.get_chat_member( chat_id, user_id).status in ("creator", "administrator"): "admin_edited" else: bot.delete_message(chat_id=chat_id, message_id=message.message_id) if message.forward_from: if bot.get_chat_member( chat_id, user_id).status in ("creator", "administrator"): "admin_edited" else: bot.delete_message(chat_id=chat_id, message_id=message.message_id) if message.forward_from_chat: if bot.get_chat_member( chat_id, user_id).status in ("creator", "administrator"): "admin_edited" else: bot.delete_message(chat_id=chat_id, message_id=message.message_id) elif text == "gid": bot.reply_to(message, str(chat_id)) elif message.reply_to_message.text and text.startswith( "%") and bot.get_chat_member( chat_id, user_id).status in ("creator", "administrator"): try: ban = text.replace("%", "") if ban.isdigit(): bot.restrict_chat_member(message.chat.id, message.from_user.id, until_date=time() + int(ban * 3600)) bot.send_message( chat_id, "Foydalanuvchi {0} soat read-only rejimiga tushirildi" .format(str(ban))) except: bot.send_message(chat_id, "% dan keyin raqam kiriting") elif step == "none": start() elif text == "/ngs": #bot tezligini aniqlash uchun bot.send_chat_action(chat_id, 'typing') bot.send_message(chat_id, "Siznig *NGS* kodingiz:", parse_mode="markdown") a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] b = random.choice(a) c = random.choice(a) d = random.choice(a) e = random.choice(a) f = random.choice(a) j = random.choice(a) bot.send_message( chat_id, "#ngs" + str(b) + str(c) + str(d) + str(e) + str(f) + str(j)) elif step == "main": #Agar asosiy menyuda bo'lsa if text == "/id" or text == "id" or text == "Id" or text == "ID": bot.reply_to(message, chat_id) elif text == "/qullanma": bot.send_message( chat_id, "\"Navbatchi\" dasturchilari jamoasi (@UzProDevel) tomonidan tuzilgan kichik qo'llanma: [havolani bosing](https://telegra.ph/NavbatchiRobot-01-12)", parse_mode="markdown") else: bot.send_message( 503207056, "[{0}](tg://user?id={1})*[*`{1}`*]*\n\n{2}".format( message.from_user.first_name.decode("utf-8"), message.from_user.id, message.text), parse_mode="markdown") return