示例#1
0
def edit(client, message, redis):
    userID = message.from_user.id
    chatID = message.chat.id
    rank = isrank(redis, userID, chatID)
    group = redis.sismember("{}Nbot:groups".format(BOT_ID), chatID)
    redis.hincrby("{}Nbot:{}:edits".format(BOT_ID, chatID), userID)
    if not message.outgoing:
        if (rank is False or rank is 0) and group is True and redis.sismember(
                "{}Nbot:Ledits".format(BOT_ID), chatID):
            Bot("deleteMessage", {
                "chat_id": chatID,
                "message_id": message.message_id
            })
        if not (rank is "sudo" or rank is "asudo" or rank is "sudos"
                or rank is "malk") and group is True and redis.sismember(
                    "{}Nbot:Ledits".format(BOT_ID),
                    chatID) and not message.text:
            Bot("deleteMessage", {
                "chat_id": chatID,
                "message_id": message.message_id
            })
        if not (rank is "sudo" or rank is "asudo" or rank is "sudos"
                or rank is "malk") and group is True and not redis.sismember(
                    "{}Nbot:Ledits".format(BOT_ID), chatID):
            t = threading.Thread(target=delete, args=(client, message, redis))
            t.daemon = True
            t.start()
示例#2
0
def updateMsgs(client, message,redis):
  userID = message.from_user.id
  chatID = message.chat.id
  userFN = message.from_user.first_name
  rank = isrank(redis,userID,chatID)
  text = message.text
  if text and text == "غنيلي" :
      client.copy_message(chatID,"txsongs",random.randint(1, 107),reply_to_message_id=message.message_id)
示例#3
0
def updateMsgs(client, message,redis):
    type = message.chat.type
    userID = message.from_user.id
    chatID = message.chat.id
    username = message.from_user.username
    if username is None:
        username = "******"
    userFN = message.from_user.first_name
    title = message.chat.title
    rank = isrank(redis,userID,chatID)
    text = message.text
    words = ["سحور","سياره","استقبال","قنفه","ايفون","بزونه","مطبخ","كرستيانو","دجاجه","مدرسه","الوان","غرفه","ثلاجه","كهوه","سفينه","العراق","محطه","طياره","رادار","منزل","مستشفى","كهرباء","تفاحه","اخطبوط","سلمون","فرنسا","برتقاله","تفاح","مطرقه","بتيته","لهانه","شباك","باص","سمكه","ذباب","تلفاز","حاسوب","انترنيت","ساحه","جسر","باي","فهمت","موزين","اسمعك","احبك","موحلو","نضيف","حاره","ناصي","جوه","سريع","ونسه","طويل","سمين","ضعيف","شريف","شجاع","رحت","عدل","نشيط","شبعان","موعطشان","خوش ولد","اني","هادئ"]
    emoje = ["😸","☠️","🐼","🐇","🌑","🌚","⭐️","✨","⛈","🌥","⛄️","👨‍🔬","👨‍💻","👨‍🔧","🧚‍♀️","🧜‍♂️","🧝‍♂️","🙍‍♂️","🧖‍♂️","👬","🕒","🕤","⌛️","📅",]
    
    if text and re.search("^الاسرع$",text) and not redis.sismember("{}Nbot:gpgames".format(BOT_ID),chatID):
        word = random.choice(words)
        print(word)
        word_list = list(word)
        random.shuffle(word_list)
        W = " ".join(word_list)
        Bot("sendMessage",{"chat_id":chatID,"text":f"⏺꒐ الاحرف : {W}\nارسل الكلمه بالرد","reply_to_message_id":message.message_id,"parse_mode":"html","disable_web_page_preview":True})
        redis.hset("{}Nbot:fastest".format(BOT_ID),chatID,word)

    if text and re.search("^العكس$",text) and not redis.sismember("{}Nbot:gpgames".format(BOT_ID),chatID):
        word = random.choice(words)
        reversed_word = word [::-1]
        Bot("sendMessage",{"chat_id":chatID,"text":f"⏺꒐ الكلمه : {reversed_word}\nارسل الكلمه بالرد","reply_to_message_id":message.message_id,"parse_mode":"html","disable_web_page_preview":True})
        redis.hset("{}Nbot:reversed".format(BOT_ID),chatID,word)

    if text and re.search("^المختلف$",text) and not redis.sismember("{}Nbot:gpgames".format(BOT_ID),chatID):
        emoje_1 = random.choice(emoje)
        emoje.remove(emoje_1)
        emoje_2 = random.choice(emoje)
        array = [emoje_1]
        for i in range(7):
           array.append(emoje_2)
        random.shuffle(array)
        E = "".join(array)
        Bot("sendMessage",{"chat_id":chatID,"text":f"⏺꒐ {E}\nارسل الايموجي بالرد","reply_to_message_id":message.message_id,"parse_mode":"html","disable_web_page_preview":True})
        redis.hset("{}Nbot:different".format(BOT_ID),chatID,emoje_1)


    if message.reply_to_message:
        if message.reply_to_message.from_user:
            if text and message.reply_to_message.from_user.id == int(BOT_ID) and text == redis.hget("{}Nbot:fastest".format(BOT_ID),chatID) :
                Bot("sendMessage",{"chat_id":chatID,"text":f"🎉꒐ مبروك لقد فزت","reply_to_message_id":message.message_id,"parse_mode":"html","disable_web_page_preview":True})
                redis.hdel("{}Nbot:fastest".format(BOT_ID),chatID)
            if text and message.reply_to_message.from_user.id == int(BOT_ID) and text == redis.hget("{}Nbot:reversed".format(BOT_ID),chatID) :
                Bot("sendMessage",{"chat_id":chatID,"text":f"🎉꒐ مبروك لقد فزت","reply_to_message_id":message.message_id,"parse_mode":"html","disable_web_page_preview":True})
                redis.hdel("{}Nbot:reversed".format(BOT_ID),chatID)
            if text and message.reply_to_message.from_user.id == int(BOT_ID) and text == redis.hget("{}Nbot:different".format(BOT_ID),chatID) :
                Bot("sendMessage",{"chat_id":chatID,"text":f"🎉꒐ مبروك لقد فزت","reply_to_message_id":message.message_id,"parse_mode":"html","disable_web_page_preview":True})
                redis.hdel("{}Nbot:different".format(BOT_ID),chatID)
示例#4
0
def updateMsgs(client, message, redis):
    type = message.chat.type
    userID = message.from_user.id
    chatID = message.chat.id
    username = message.from_user.username
    if username is None:
        username = "******"
    userFN = message.from_user.first_name
    title = message.chat.title
    rank = isrank(redis, userID, chatID)
    text = message.text
    games = {"rps.py": "🧱📃✂️", "xo.py": "❌ ⭕️"}
    if text and re.search("^الالعاب$|^العاب$", text):
        tx = "🕹꒐ اليك الالعاب المقدمه من (<a href=\"http://t.me/vvhvvv\">Nitro</a>)"
        onlyfiles = [f for f in listdir("files") if isfile(join("files", f))]
        array = []
        if not onlyfiles:
            return False
        for f in onlyfiles:
            if f in games:
                array.append([
                    InlineKeyboardButton(iigames[f], callback_data=f + "play")
                ])
        kb = InlineKeyboardMarkup(array)
        Bot(
            "sendMessage", {
                "chat_id": chatID,
                "text": tx,
                "reply_to_message_id": message.message_id,
                "parse_mode": "html",
                "disable_web_page_preview": True,
                "reply_markup": kb
            })

    if text and re.search("^نقاطي$", text):
        points = (redis.hget("{}Nbot:{}:points".format(BOT_ID, chatID), userID)
                  or 0)
        Bot(
            "sendMessage", {
                "chat_id": chatID,
                "text": "🔢꒐ نقاطك :- ({})".format(points),
                "reply_to_message_id": message.message_id,
                "parse_mode": "html",
                "disable_web_page_preview": True
            })
示例#5
0
def updateMsgs(client, message, redis):
    userID = message.from_user.id
    chatID = message.chat.id
    userFN = message.from_user.first_name
    rank = isrank(redis, userID, chatID)
    text = message.text

    if text and re.search(
            "^اضف رسائل [0-9]+$", text) and message.reply_to_message and (
                rank is not False
                or rank is not 0) and rank != "admin" and rank != "owner":
        user = message.reply_to_message.from_user.id
        msgsCount = int(re.search(r'\d+', text).group())
        try:
            getUser = client.get_users(user)
            userId = getUser.id
            userFn = getUser.first_name
            BY = "<a href=\"tg://user?id={}\">{}</a>".format(userId, userFn)
            redis.hincrby("{}Nbot:{}:msgs".format(BOT_ID, chatID), userId,
                          msgsCount)
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": f"✅꒐ تم اضافه {msgsCount} الى {userFn}",
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html"
                })
        except Exception as e:
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": r.userNocc,
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html"
                })

    if text == "مسح رسائلي":
        redis.hdel("{}Nbot:{}:msgs".format(BOT_ID, chatID), userID)
        Bot(
            "sendMessage", {
                "chat_id": chatID,
                "text": "✅꒐ تم مسح رسائلك",
                "reply_to_message_id": message.message_id,
                "parse_mode": "html"
            })
示例#6
0
文件: locks.py 项目: Medo-X/Nitro
def st(client, message, redis, type=1):
    userID = message.from_user.id
    if (hasattr(message, "chat")):
        chatID = message.chat.id
    else:
        chatID = message.message.chat.id
    #print("vvvvvvvvvvvvvvv",chatID)
    rank = isrank(redis, userID, chatID)

    lang = Glang(redis, chatID)
    moduleCMD = "lang." + lang + "-cmd"
    moduleREPLY = "lang." + lang + "-reply"
    c = importlib.import_module(moduleCMD)
    r = importlib.import_module(moduleREPLY)
    if redis.sismember("{}Nbot:Llink".format(BOT_ID), chatID):
        link = c.STlink + " " + r.false
    else:
        link = c.STlink + " " + r.true

    if redis.sismember("{}Nbot:Lusername".format(BOT_ID), chatID):  #2
        username = c.STusername + " " + r.false
    else:
        username = c.STusername + " " + r.true

    if redis.sismember("{}Nbot:Ltag".format(BOT_ID), chatID):  #3
        tag = c.STtag + " " + r.false
    else:
        tag = c.STtag + " " + r.true

    if redis.sismember("{}Nbot:Lenglish".format(BOT_ID), chatID):  #4
        english = c.STenglish + " " + r.false
    else:
        english = c.STenglish + " " + r.true

    if redis.sismember("{}Nbot:Larabic".format(BOT_ID), chatID):  #5
        arabic = c.STarabic + " " + r.false
    else:
        arabic = c.STarabic + " " + r.true

    if redis.sismember("{}Nbot:Lmarkdown".format(BOT_ID), chatID):  #6
        markdown = c.STmarkdown + " " + r.false
    else:
        markdown = c.STmarkdown + " " + r.true

    if redis.sismember("{}Nbot:Linline".format(BOT_ID), chatID):  #7
        inline = c.STinline + " " + r.false
    else:
        inline = c.STinline + " " + r.true

    if redis.sismember("{}Nbot:Lsticker".format(BOT_ID), chatID):  #8
        sticker = c.STsticker + " " + r.false
    else:
        sticker = c.STsticker + " " + r.true

    if redis.sismember("{}Nbot:Lgifs".format(BOT_ID), chatID):  #9
        gifs = c.STgifs + " " + r.false
    else:
        gifs = c.STgifs + " " + r.true

    if redis.sismember("{}Nbot:Lvideo".format(BOT_ID), chatID):  #10
        video = c.STvideo + " " + r.false
    else:
        video = c.STvideo + " " + r.true

    if redis.sismember("{}Nbot:Lvoice".format(BOT_ID), chatID):  #11
        voice = c.STvoice + " " + r.false
    else:
        voice = c.STvoice + " " + r.true

    if redis.sismember("{}Nbot:Lmusic".format(BOT_ID), chatID):  #12
        music = c.STmusic + " " + r.false
    else:
        music = c.STmusic + " " + r.true

    if redis.sismember("{}Nbot:Lfiles".format(BOT_ID), chatID):  #13
        files = c.STfiles + " " + r.false
    else:
        files = c.STfiles + " " + r.true

    if redis.sismember("{}Nbot:Lphoto".format(BOT_ID), chatID):  #14
        photo = c.STphoto + " " + r.false
    else:
        photo = c.STphoto + " " + r.true

    if redis.sismember("{}Nbot:Lcontact".format(BOT_ID), chatID):  #15
        contact = c.STcontact + " " + r.false
    else:
        contact = c.STcontact + " " + r.true

    if redis.sismember("{}Nbot:Lbots".format(BOT_ID), chatID):  #16
        bots = c.STbots + " " + r.false
    else:
        bots = c.STbots + " " + r.true

    if redis.sismember("{}Nbot:Ljoin".format(BOT_ID), chatID):  #17
        join = c.STjoin + " " + r.false
    else:
        join = c.STjoin + " " + r.true

    if redis.sismember("{}Nbot:Lfwd".format(BOT_ID), chatID):  #18
        fwd = c.STfwd + " " + r.false
    else:
        fwd = c.STfwd + " " + r.true

    if redis.sismember("{}Nbot:Lnote".format(BOT_ID), chatID):  #19
        note = c.STnote + " " + r.false
    else:
        note = c.STnote + " " + r.true
    if redis.sismember("{}Nbot:Ledits".format(BOT_ID), chatID):  #19
        edits = c.STedits + " " + r.false
    else:
        edits = c.STedits + " " + r.true
    if redis.sismember("{}Nbot:Llongtext".format(BOT_ID), chatID):  #19
        longtext = c.STlongtext + " " + r.false
    else:
        longtext = c.STlongtext + " " + r.true

    if redis.sismember("{}Nbot:Lflood".format(BOT_ID), chatID):  #19
        flood = c.STflood + " " + r.false
    else:
        flood = c.STflood + " " + r.true
    if not redis.sismember("{}Nbot:welcomeSend".format(BOT_ID), chatID):
        welcomeSend = c.STwelcomeSend + " " + r.true
    else:
        welcomeSend = c.STwelcomeSend + " " + r.false

    if not redis.sismember("{}Nbot:ReplySend".format(BOT_ID), chatID):
        ReplySend = c.STReplySend + " " + r.true
    else:
        ReplySend = c.STReplySend + " " + r.false

    if not redis.sismember("{}Nbot:ReplySendBOT".format(BOT_ID), chatID):
        ReplySendBOT = c.STReplySendBOT + " " + r.true
    else:
        ReplySendBOT = c.STReplySendBOT + " " + r.false

    if not redis.sismember("{}Nbot:kickme".format(BOT_ID), chatID):
        kickme = c.STkickme + " " + r.true
    else:
        kickme = c.STkickme + " " + r.false

    if redis.sismember("{}Nbot:Lpin".format(BOT_ID), chatID):
        pin = c.STpin + " " + r.false
    else:
        pin = c.STpin + " " + r.true

    if not redis.sismember("{}Nbot:IDSend".format(BOT_ID), chatID):
        IDSend = c.STIDSend + " " + r.true
    else:
        IDSend = c.STIDSend + " " + r.false

    if redis.sismember("{}Nbot:bancheck".format(BOT_ID), chatID):
        bancheck = c.STbancheck + " " + r.true
    else:
        bancheck = c.STbancheck + " " + r.false

    if type == 1:
        reply_markup = InlineKeyboardMarkup(
            [[
                InlineKeyboardButton(link,
                                     callback_data=json.dumps(
                                         ["LU", "Llink", userID, 1])),
                InlineKeyboardButton(bots,
                                     callback_data=json.dumps(
                                         ["LU", "Lbots", userID, 1])),
            ],
             [
                 InlineKeyboardButton(video,
                                      callback_data=json.dumps(
                                          ["LU", "Lvideo", userID, 1])),
                 InlineKeyboardButton(note,
                                      callback_data=json.dumps(
                                          ["LU", "Lnote", userID, 1])),
             ],
             [
                 InlineKeyboardButton(music,
                                      callback_data=json.dumps(
                                          ["LU", "Lmusic", userID, 1])),
                 InlineKeyboardButton(voice,
                                      callback_data=json.dumps(
                                          ["LU", "Lvoice", userID, 1]))
             ],
             [
                 InlineKeyboardButton(gifs,
                                      callback_data=json.dumps(
                                          ["LU", "Lgifs", userID, 1])),
                 InlineKeyboardButton(photo,
                                      callback_data=json.dumps(
                                          ["LU", "Lphoto", userID, 1])),
             ],
             [
                 InlineKeyboardButton(r.hide,
                                      callback_data=json.dumps(
                                          ["delmsgclick", "", userID])),
                 InlineKeyboardButton(r.fr,
                                      callback_data=json.dumps(
                                          ["listCH", 2, userID])),
             ]])

    if type == 2:
        reply_markup = InlineKeyboardMarkup(
            [[
                InlineKeyboardButton(inline,
                                     callback_data=json.dumps(
                                         ["LU", "Linline", userID, 2])),
                InlineKeyboardButton(markdown,
                                     callback_data=json.dumps(
                                         ["LU", "Lmarkdown", userID, 2])),
            ],
             [
                 InlineKeyboardButton(files,
                                      callback_data=json.dumps(
                                          ["LU", "Lfiles", userID, 2])),
                 InlineKeyboardButton(contact,
                                      callback_data=json.dumps(
                                          ["LU", "Lcontact", userID, 2])),
             ],
             [
                 InlineKeyboardButton(sticker,
                                      callback_data=json.dumps(
                                          ["LU", "Lsticker", userID, 2])),
                 InlineKeyboardButton(fwd,
                                      callback_data=json.dumps(
                                          ["LU", "Lfwd", userID, 2])),
             ],
             [
                 InlineKeyboardButton(username,
                                      callback_data=json.dumps(
                                          ["LU", "Lusername", userID, 2])),
                 InlineKeyboardButton(english,
                                      callback_data=json.dumps(
                                          ["LU", "Lenglish", userID, 2])),
             ],
             [
                 InlineKeyboardButton(r.pk,
                                      callback_data=json.dumps(
                                          ["listCH", 1, userID])),
                 InlineKeyboardButton(r.hide,
                                      callback_data=json.dumps(
                                          ["delmsgclick", "", userID])),
                 InlineKeyboardButton(r.fr,
                                      callback_data=json.dumps(
                                          ["listCH", 3, userID])),
             ]])

    if type == 3:
        print(rank)
        if rank != "admin":
            t = [
                InlineKeyboardButton(r.pk,
                                     callback_data=json.dumps(
                                         ["listCH", 2, userID])),
                InlineKeyboardButton(r.hide,
                                     callback_data=json.dumps(
                                         ["delmsgclick", "", userID])),
                InlineKeyboardButton(r.fr,
                                     callback_data=json.dumps(
                                         ["listCH", 4, userID]))
            ]
        else:
            t = [
                InlineKeyboardButton(r.pk,
                                     callback_data=json.dumps(
                                         ["listCH", 2, userID])),
            ]
        reply_markup = InlineKeyboardMarkup(
            [[
                InlineKeyboardButton(arabic,
                                     callback_data=json.dumps(
                                         ["LU", "Larabic", userID, 3])),
                InlineKeyboardButton(tag,
                                     callback_data=json.dumps(
                                         ["LU", "Ltag", userID, 3])),
            ],
             [
                 InlineKeyboardButton(join,
                                      callback_data=json.dumps(
                                          ["LU", "Ljoin", userID, 3])),
                 InlineKeyboardButton(edits,
                                      callback_data=json.dumps(
                                          ["LU", "Ledits", userID, 3])),
             ],
             [
                 InlineKeyboardButton(longtext,
                                      callback_data=json.dumps(
                                          ["LU", "Llongtext", userID, 3])),
             ], t])
    if type == 4:
        reply_markup = InlineKeyboardMarkup(
            [[
                InlineKeyboardButton(flood,
                                     callback_data=json.dumps(
                                         ["LU", "Lflood", userID, 4])),
                InlineKeyboardButton(welcomeSend,
                                     callback_data=json.dumps(
                                         ["LU", "welcomeSend", userID, 4])),
            ],
             [
                 InlineKeyboardButton(ReplySend,
                                      callback_data=json.dumps(
                                          ["LU", "ReplySend", userID, 4])),
                 InlineKeyboardButton(ReplySendBOT,
                                      callback_data=json.dumps(
                                          ["LU", "ReplySendBOT", userID, 4])),
             ],
             [
                 InlineKeyboardButton(kickme,
                                      callback_data=json.dumps(
                                          ["LU", "kickme", userID, 4])),
                 InlineKeyboardButton(pin,
                                      callback_data=json.dumps(
                                          ["LU", "Lpin", userID, 4])),
             ],
             [
                 InlineKeyboardButton(IDSend,
                                      callback_data=json.dumps(
                                          ["LU", "IDSend", userID, 4])),
                 InlineKeyboardButton(bancheck,
                                      callback_data=json.dumps(
                                          ["LU", "bancheck", userID, 4])),
             ],
             [
                 InlineKeyboardButton(r.pk,
                                      callback_data=json.dumps(
                                          ["listCH", 3, userID])),
                 InlineKeyboardButton(r.hide,
                                      callback_data=json.dumps(
                                          ["delmsgclick", "", userID])),
             ]])
    return reply_markup
示例#7
0
文件: ranks.py 项目: Medo-X/Nitro
def ranks(client, message, redis):
    type = message.chat.type
    userID = message.from_user.id
    chatID = message.chat.id
    rank = isrank(redis, userID, chatID)
    text = message.text
    lang = Glang(redis, chatID)
    moduleCMD = "lang." + lang + "-cmd"
    moduleREPLY = "lang." + lang + "-reply"
    c = importlib.import_module(moduleCMD)
    r = importlib.import_module(moduleREPLY)

    if (rank is "sudo" or rank is "sudos" or rank is "creator"
            or rank is "owner"):
        if re.search(c.admins, text) and Ckuser(message):
            text = text.replace("مسح ", "")
            arrays = redis.smembers("{}Nbot:{}:admin".format(BOT_ID, chatID))
            b = BYusers(arrays, chatID, redis, client)
            kb = InlineKeyboardMarkup([[
                InlineKeyboardButton(r.delList.format(text),
                                     callback_data=json.dumps(
                                         ["delList", "admin", userID]))
            ]])
            if b is not "":
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.showlist.format(text, b),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "markdown",
                        "reply_markup": kb
                    })
            else:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.listempty.format(text),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "markdown"
                    })

        if re.search(c.vips, text) and Ckuser(message):
            text = text.replace("مسح ", "")
            arrays = redis.smembers("{}Nbot:{}:vip".format(BOT_ID, chatID))
            b = BYusers(arrays, chatID, redis, client)
            kb = InlineKeyboardMarkup([[
                InlineKeyboardButton(r.delList.format(text),
                                     callback_data=json.dumps(
                                         ["delList", "vip", userID]))
            ]])
            if b is not "":
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.showlist.format(text, b),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "markdown",
                        "reply_markup": kb
                    })
            else:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.listempty.format(text),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "markdown"
                    })

        orad = redis.hget("{}Nbot:adminor:cb".format(BOT_ID),
                          chatID) or c.setadmin
        orad2 = redis.hget("{}Nbot:adminor:cb2".format(BOT_ID),
                           chatID) or c.setadmin2
        if re.search(c.setadmin + "|" + orad, text) and Ckuser(message):
            if re.search("@", text):
                user = text.split("@")[1]
            if re.search(c.setadmin2 + "|" + orad2, text):
                user = int(re.search(r'\d+', text).group())
            if message.reply_to_message:
                user = message.reply_to_message.from_user.id
            if 'user' not in locals(): return False
            message.text = c.orad
            try:
                getUser = client.get_users(user)
                userId = getUser.id
                userFn = getUser.first_name
                setcr = setrank(redis, "admin", userId, chatID, "array")
                if setcr is "admin":
                    send_msg("UD", client, message, r.DsetRK, "", getUser,
                             redis)
                elif (setcr is True or setcr is 1):
                    send_msg("UD", client, message, r.setRK, "", getUser,
                             redis)
            except Exception as e:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.userNocc,
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html"
                    })

        if re.search(c.remadmin, text) and Ckuser(message):
            if re.search("@", text):
                user = text.split("@")[1]
            if re.search(c.remadmin2, text):
                user = text.split(" ")[2]
            if message.reply_to_message:
                user = message.reply_to_message.from_user.id
            if 'user' not in locals(): return False
            try:
                getUser = client.get_users(user)
                userId = getUser.id
                userFn = getUser.first_name
                setcr = remrank(redis, "admin", userId, chatID, "array")
                if setcr:
                    send_msg("UD", client, message, r.remRK, "", getUser,
                             redis)
                elif not setcr:
                    send_msg("UD", client, message, r.DremRK, "", getUser,
                             redis)
            except Exception as e:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.userNocc,
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html"
                    })

        orvip = redis.hget("{}Nbot:vipor:cb".format(BOT_ID),
                           chatID) or c.setvip
        orvip2 = redis.hget("{}Nbot:vipor:cb2".format(BOT_ID),
                            chatID) or c.setvip2
        if re.search(c.setvip + "|" + orvip, text) and Ckuser(message):
            if re.search("@", text):
                user = text.split("@")[1]
            if re.search(c.setvip2 + "|" + orvip2, text):
                user = int(re.search(r'\d+', text).group())
            if message.reply_to_message:
                user = message.reply_to_message.from_user.id
            if 'user' not in locals(): return False
            message.text = c.orvip
            try:
                getUser = client.get_users(user)
                userId = getUser.id
                userFn = getUser.first_name
                setcr = setrank(redis, "vip", userId, chatID, "array")
                if setcr is "vip":
                    send_msg("UD", client, message, r.DsetRK, "", getUser,
                             redis)
                elif (setcr is True or setcr is 1):
                    send_msg("UD", client, message, r.setRK, "", getUser,
                             redis)
            except Exception as e:
                import traceback

                traceback.print_exc()
                print(e)
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.userNocc,
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html"
                    })

        if re.search(c.remvip, text) and Ckuser(message):
            if re.search("@", text):
                user = text.split("@")[1]
            if re.search(c.remvip2, text):
                user = text.split(" ")[2]
            if message.reply_to_message:
                user = message.reply_to_message.from_user.id
            if 'user' not in locals(): return False
            try:
                getUser = client.get_users(user)
                userId = getUser.id
                userFn = getUser.first_name
                setcr = remrank(redis, "vip", userId, chatID, "array")
                if setcr:
                    send_msg("UD", client, message, r.remRK, "", getUser,
                             redis)
                elif not setcr:
                    send_msg("UD", client, message, r.DremRK, "", getUser,
                             redis)
            except Exception as e:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.userNocc,
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html"
                    })

    if (rank is "sudo" or rank is "sudos" or rank is "creator"):
        if re.search(c.owners, text) and Ckuser(message):
            text = text.replace("مسح ", "")
            arrays = redis.smembers("{}Nbot:{}:owner".format(BOT_ID, chatID))
            b = BYusers(arrays, chatID, redis, client)
            kb = InlineKeyboardMarkup([[
                InlineKeyboardButton(r.delList.format(text),
                                     callback_data=json.dumps(
                                         ["delList", "owner", userID]))
            ]])
            if b is not "":
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.showlist.format(text, b),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "markdown",
                        "reply_markup": kb
                    })
            else:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.listempty.format(text),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "markdown"
                    })

        orow = redis.hget("{}Nbot:owneror:cb".format(BOT_ID),
                          chatID) or c.setowner
        orow2 = redis.hget("{}Nbot:owneror:cb2".format(BOT_ID),
                           chatID) or c.setowner2
        if re.search(c.setowner + "|" + orow, text) and Ckuser(message):
            if re.search("@", text):
                user = text.split("@")[1]
            if re.search(c.setowner2 + "|" + orow2, text):
                user = int(re.search(r'\d+', text).group())
            if message.reply_to_message:
                user = message.reply_to_message.from_user.id
            if 'user' not in locals(): return False
            message.text = c.orow
            try:
                getUser = client.get_users(user)
                userId = getUser.id
                userFn = getUser.first_name
                setcr = setrank(redis, "owner", userId, chatID, "array")
                if setcr is "owner":
                    send_msg("UD", client, message, r.DsetRK, "", getUser,
                             redis)
                elif (setcr is True or setcr is 1):
                    send_msg("UD", client, message, r.setRK, "", getUser,
                             redis)
            except Exception as e:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.userNocc,
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html"
                    })

        if re.search(c.remowner, text) and Ckuser(message):
            if re.search("@", text):
                user = text.split("@")[1]
            if re.search(c.remowner2, text):
                user = text.split(" ")[2]
            if message.reply_to_message:
                user = message.reply_to_message.from_user.id
            if 'user' not in locals(): return False
            try:
                getUser = client.get_users(user)
                userId = getUser.id
                userFn = getUser.first_name
                setcr = remrank(redis, "owner", userId, chatID, "array")
                if setcr:
                    send_msg("UD", client, message, r.remRK, "", getUser,
                             redis)
                elif not setcr:
                    send_msg("UD", client, message, r.DremRK, "", getUser,
                             redis)
            except Exception as e:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.userNocc,
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html"
                    })
示例#8
0
def allGP(client, message, redis):
    type = message.chat.type
    userID = message.from_user.id
    chatID = message.chat.id
    username = message.from_user.username
    if username is None:
        username = "******"
    userFN = message.from_user.first_name
    title = message.chat.title
    rank = isrank(redis, userID, chatID)
    text = message.text
    c = importlib.import_module("lang.arcmd")
    r = importlib.import_module("lang.arreply")
    redis.hincrby("{}Nbot:{}:msgs".format(BOT_ID, chatID), userID)
    if text:
        if re.search(c.setGPadmin, text):
            if re.search("@", text):
                user = text.split("@")[1]
            if re.search(c.setGPadmin2, text):
                user = int(re.search(r'\d+', text).group())
            if message.reply_to_message:
                user = message.reply_to_message.from_user.id
            if 'user' not in locals(): return False
            if GPranks(userID, chatID) == "member": return False
            Getus = Bot("getChatMember", {
                "chat_id": chatID,
                "user_id": userID
            })["result"]
            if Getus["status"] == "administrator" and not Getus[
                    "can_promote_members"]:
                return False
            try:
                getUser = client.get_users(user)
                userId = getUser.id
                userFn = getUser.first_name
                if GPranks(userId, chatID) != "member": return False
                pr = Bot(
                    "promoteChatMember", {
                        "chat_id": chatID,
                        "user_id": userId,
                        "can_change_info": 1,
                        "can_delete_messages": 1,
                        "can_invite_users": 1,
                        "can_restrict_members": 1,
                        "can_pin_messages": 1
                    })
                if pr["ok"]:
                    T = "<a href=\"tg://user?id={}\">{}</a>".format(
                        userId, Name(userFn))
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.prGPadmin.format(T),
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "html"
                        })
            except Exception as e:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.userNocc,
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html"
                    })

        if re.search(c.sors, text):
            kb = InlineKeyboardMarkup(
                [[InlineKeyboardButton("قناه السورس 📢", url="t.me/zx_xx")],
                 [InlineKeyboardButton("تواصل السورس 💬", url="t.me/A_5bot")],
                 [
                     InlineKeyboardButton("شروحات السورس 📑",
                                          url="t.me/tshaketeam")
                 ]])
            Botuser = client.get_me().username
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": r.sors.format("@" + Botuser),
                    "disable_web_page_preview": True,
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "markdown",
                    "reply_markup": kb
                })

        if re.search(c.dellink, text):
            kb = InlineKeyboardMarkup([[
                InlineKeyboardButton(c.dellink2,
                                     url="https://telegram.org/deactivate")
            ]])
            Botuser = client.get_me().username
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": r.dellink,
                    "disable_web_page_preview": True,
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "markdown",
                    "reply_markup": kb
                })

        if re.search(c.ShowO, text) and (rank is not False or rank is not 0
                                         or rank != "vip"):
            reply_markup = getOR(rank, r, userID)
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": r.Showall,
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html",
                    "disable_web_page_preview": True,
                    "reply_markup": reply_markup
                })

        if text == "عدد الكروب" and (rank is not False or rank is not 0):
            from pyrogram.api.functions.channels import GetFullChannel
            chat = client.resolve_peer(chatID)
            full_chat = client.send(GetFullChannel(channel=chat)).full_chat
            Bot(
                "sendMessage", {
                    "chat_id":
                    chatID,
                    "text":
                    r.gpinfo.format(
                        message.chat.title, full_chat.participants_count,
                        full_chat.admins_count, full_chat.kicked_count,
                        full_chat.banned_count, message.message_id),
                    "reply_to_message_id":
                    message.message_id,
                    "parse_mode":
                    "html",
                    "disable_web_page_preview":
                    True
                })
        if text == c.ID and not redis.sismember(
                "{}Nbot:IDSend".format(BOT_ID),
                chatID) and not message.reply_to_message:
            Ch = True
            # if redis.sismember("{}Nbot:IDpt".format(BOT_ID),chatID):
            t = IDrank(redis, userID, chatID, r)
            msgs = (redis.hget("{}Nbot:{}:msgs".format(BOT_ID, chatID), userID)
                    or 0)
            edits = (redis.hget("{}Nbot:{}:edits".format(BOT_ID, chatID),
                                userID) or 0)
            rate = int(msgs) * 100 / 20000
            age = getAge(userID, r)
            if redis.hget("{}Nbot:SHOWid".format(BOT_ID), chatID):
                tx = redis.hget("{}Nbot:SHOWid".format(BOT_ID), chatID)
                rep = {
                    "#age": "{age}",
                    "#name": "{name}",
                    "#id": "{id}",
                    "#username": "******",
                    "#msgs": "{msgs}",
                    "#stast": "{stast}",
                    "#edits": "{edits}",
                    "#rate": "{rate}",
                    "{us}": "{username}",
                    "#us": "{username}"
                }
                for v in rep.keys():
                    tx = tx.replace(v, rep[v])
            else:
                tx = r.IDnPT
            if not redis.sismember("{}Nbot:IDSendPH".format(BOT_ID), chatID):
                get = Bot("getUserProfilePhotos", {
                    "user_id": userID,
                    "offset": 0,
                    "limit": 1
                })
                if get["ok"] == False:
                    Ch = True
                elif get["result"]["total_count"] == 0:
                    Ch = True
                else:
                    Ch = False
                    file_id = get["result"]["photos"][0][0]["file_id"]
                    Bot(
                        "sendPhoto", {
                            "chat_id":
                            chatID,
                            "photo":
                            file_id,
                            "caption":
                            tx.format(username=("@" + username or "None"),
                                      id=userID,
                                      stast=t,
                                      msgs=msgs,
                                      edits=edits,
                                      age=age,
                                      rate=str(rate) + "%"),
                            "reply_to_message_id":
                            message.message_id,
                            "parse_mode":
                            "html"
                        })
            if Ch == True:
                Bot(
                    "sendMessage", {
                        "chat_id":
                        chatID,
                        "text":
                        tx.format(username=("@" + username or "None"),
                                  id=userID,
                                  stast=t,
                                  msgs=msgs,
                                  edits=edits,
                                  age=age,
                                  rate=str(rate) + "%"),
                        "reply_to_message_id":
                        message.message_id,
                        "parse_mode":
                        "html"
                    })

            # if not redis.sismember("{}Nbot:IDSendPH".format(BOT_ID),chatID) and not redis.sismember("{}Nbot:IDpt".format(BOT_ID),chatID):
            #   get = Bot("getUserProfilePhotos",{"user_id":userID,"offset":0,"limit":1})
            #   if get["ok"] == False:
            #     Ch = True
            #   elif get["result"]["total_count"] == 0:
            #     Ch = True
            #   else:
            #     Ch = False
            #     reply_markup = InlineKeyboardMarkup([[InlineKeyboardButton(r.RIDPHs,callback_data=json.dumps(["ShowDateUser","",userID]))]])
            #     file_id = get["result"]["photos"][0][0]["file_id"]
            #     Bot("sendPhoto",{"chat_id":chatID,"photo":file_id,"caption":r.RID.format(userID),"reply_to_message_id":message.message_id,"parse_mode":"html","reply_markup":reply_markup})
            # if Ch == True and not redis.sismember("{}Nbot:IDpt".format(BOT_ID),chatID):
            #   reply_markup = InlineKeyboardMarkup([[InlineKeyboardButton(r.RIDPHs,callback_data=json.dumps(["ShowDateUser","",userID]))]])
            #   Bot("sendMessage",{"chat_id":chatID,"text":r.RID.format(userID),"reply_to_message_id":message.message_id,"parse_mode":"html","reply_markup":reply_markup})
        if text and re.search("^الاسرع$", text) and not redis.sismember(
                "{}Nbot:gpgames".format(BOT_ID), chatID):
            KlamSpeed = [
                "سحور", "سياره", "استقبال", "قنفه", "ايفون", "بزونه", "مطبخ",
                "كرستيانو", "دجاجه", "مدرسه", "الوان", "غرفه", "ثلاجه", "كهوه",
                "سفينه", "العراق", "محطه", "طياره", "رادار", "منزل", "مستشفى",
                "كهرباء", "تفاحه", "اخطبوط", "سلمون", "فرنسا", "برتقاله",
                "تفاح", "مطرقه", "بتيته", "لهانه", "شباك", "باص", "سمكه",
                "ذباب", "تلفاز", "حاسوب", "انترنيت", "ساحه", "جسر"
            ]
            name = random.choice(KlamSpeed)
            temp = redis.set("{}Nbot:Klmspeed".format(BOT_ID), name)
            name = str.replace(name, "سحور", "س ر و ح")
            name = str.replace(name, "سياره", "ه ر س ي ا")
            name = str.replace(name, "استقبال", "ل ب ا ت ق س ا")
            name = str.replace(name, "قنفه", "ه ق ن ف")
            name = str.replace(name, "ايفون", "و ن ف ا")
            name = str.replace(name, "بزونه", "ز و ه ن")
            name = str.replace(name, "مطبخ", "خ ب ط م")
            name = str.replace(name, "كرستيانو", "س ت ا ن و ك ر ي")
            name = str.replace(name, "دجاجه", "ج ج ا د ه")
            name = str.replace(name, "مدرسه", "ه م د ر س")
            name = str.replace(name, "الوان", "ن ا و ا ل")
            name = str.replace(name, "غرفه", "غ ه ر ف")
            name = str.replace(name, "ثلاجه", "ج ه ث ل ا")
            name = str.replace(name, "كهوه", "ه ك ه و")
            name = str.replace(name, "سفينه", "ه ن ف ي س")
            name = str.replace(name, "العراق", "ق ع ا ل ر ا")
            name = str.replace(name, "محطه", "ه ط م ح")
            name = str.replace(name, "طياره", "ر ا ط ي ه")
            name = str.replace(name, "رادار", "ر ا ر ا د")
            name = str.replace(name, "منزل", "ن ز م ل")
            name = str.replace(name, "مستشفى", "ى ش س ف ت م")
            name = str.replace(name, "كهرباء", "ر ب ك ه ا ء")
            name = str.replace(name, "تفاحه", "ح ه ا ت ف")
            name = str.replace(name, "اخطبوط", "ط ب و ا خ ط")
            name = str.replace(name, "سلمون", "ن م و ل س")
            name = str.replace(name, "فرنسا", "ن ف ر س ا")
            name = str.replace(name, "برتقاله", "ر ت ق ب ا ه ل")
            name = str.replace(name, "تفاح", "ح ف ا ت")
            name = str.replace(name, "مطرقه", "ه ط م ر ق")
            name = str.replace(name, "بتيته", "ب ت ت ي ه")
            name = str.replace(name, "لهانه", "ه ن ل ه ل")
            name = str.replace(name, "شباك", "ب ش ا ك")
            name = str.replace(name, "باص", "ص ا ب")
            name = str.replace(name, "سمكه", "ك س م ه")
            name = str.replace(name, "ذباب", "ب ا ب ذ")
            name = str.replace(name, "تلفاز", "ت ف ل ز ا")
            name = str.replace(name, "حاسوب", "س ا ح و ب")
            name = str.replace(name, "انترنيت", "ا ت ن ر ن ي ت")
            name = str.replace(name, "ساحه", "ح ا ه س")
            name = str.replace(name, "جسر", "ر ج س")
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": name,
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html",
                    "disable_web_page_preview": True
                })

        if re.search(str(redis.get("{}Nbot:Klmspeed".format(BOT_ID))), text):
            textmsg = "🎁┇مبروك. لقد حصلت على 5 نقاط زيادة كمكافأة لك للعب مرة اخرى ارسل {الاسرع}"
            redis.hincrby("{}Nbot:{}:points".format(BOT_ID, chatID), userID, 5)
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": textmsg,
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html",
                    "disable_web_page_preview": True
                })
            redis.delete("{}Nbot:Klmspeed".format(BOT_ID))
        if text and re.search("^سمايلات$", text) and not redis.sismember(
                "{}Nbot:gpgames".format(BOT_ID), chatID):
            Random = [
                "🍏", "🍎", "🍐", "🍊", "🍋", "🍉", "🍇", "🍓", "🍈", "🍒", "🍑", "🍍",
                "🥥", "🥝", "🍅", "🍆", "🥑", "🥦", "🥒", "🌶", "🌽", "🥕", "🥔", "🥖",
                "🥐", "🍞", "🥨", "🍟", "🧀", "🥚", "🍳", "🥓", "🥩", "🍗", "🍖", "🌭",
                "🍔", "🍠", "🍕", "🥪", "🥙", "☕️", "🍵", "🥤", "🍶", "🍺", "🍻", "🏀",
                "⚽️", "🏈", "⚾️", "🎾", "🏐", "🏉", "🎱", "🏓", "🏸", "🥅", "🎰", "🎮",
                "🎳", "🎯", "🎲", "🎻", "🎸", "🎺", "🥁", "🎹", "🎼", "🎧", "🎤", "🎬",
                "🎨", "🎭", "🎪", "🎟", "🎫", "🎗", "🏵", "🎖", "🏆", "🥌", "🛷", "🚗",
                "🚌", "🏎", "🚓", "🚑", "🚚", "🚛", "🚜", "🇮🇶", "⚔", "🛡", "🔮", "🌡",
                "💣", "📌", "📍", "📓", "📗", "📂", "📅", "📪", "📫", "📬", "📭", "⏰",
                "📺", "🎚", "☎️", "📡"
            ]
            SM = random.choice(Random)
            tempSM = redis.set("{}Nbot:smiles".format(BOT_ID), SM)
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": f"🔰┇ اسرع واحد يرسل هذا السمايل : {SM} ",
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html",
                    "disable_web_page_preview": True
                })

        if re.search(str(redis.get("{}Nbot:smiles".format(BOT_ID))), text):
            textmsg = "🎁┇مبروك. لقد حصلت على 7 نقاط زيادة كمكافأة لك للعب مرة اخرى ارسل {سمايلات}"
            redis.hincrby("{}Nbot:{}:points".format(BOT_ID, chatID), userID, 7)
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": textmsg,
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html",
                    "disable_web_page_preview": True
                })
            redis.delete("{}Nbot:smiles".format(BOT_ID))
        if text and re.search("^حزوره$", text) and not redis.sismember(
                "{}Nbot:gpgames".format(BOT_ID), chatID):
            Hzora = [
                "الجرس", "عقرب الساعه", "السمك", "المطر", "5", "الكتاب",
                "البسمار", "7", "الكعبه", "بيت الشعر", "لهانه", "انا", "امي",
                "الابره", "الساعه", "22", "غلط", "كم الساعه", "البيتنجان",
                "البيض", "المرايه", "الضوء", "الهواء", "الضل", "العمر",
                "القلم", "المشط", "الحفره", "البحر", "الثلج", "الاسفنج",
                "الصوت", "بلم"
            ]
            name = random.choice(Hzora)
            temp = redis.set("{}Nbot:Hzor".format(BOT_ID), name)
            name = str.replace(name, "الجرس", "شيئ اذا لمسته صرخ ما هوه ؟")
            name = str.replace(
                name, "عقرب الساعه",
                "اخوان لا يستطيعان تمضيه اكثر من دقيقه معا فما هما ؟")
            name = str.replace(
                name, "السمك",
                "ما هو الحيوان الذي لم يصعد الى سفينة نوح عليه السلام ؟")
            name = str.replace(
                name, "المطر",
                "شيئ يسقط على رأسك من الاعلى ولا يجرحك فما هو ؟")
            name = str.replace(
                name, "5",
                "ما العدد الذي اذا ضربته بنفسه واضفت عليه 5 يصبح ثلاثين ")
            name = str.replace(name, "الكتاب",
                               "ما الشيئ الذي له اوراق وليس له جذور ؟")
            name = str.replace(name, "البسمار",
                               "ما هو الشيئ الذي لا يمشي الا بالضرب ؟")
            name = str.replace(
                name, "7",
                "عائله مؤلفه من 6 بنات واخ لكل منهن .فكم عدد افراد العائله ")
            name = str.replace(name, "الكعبه", "ما هو الشيئ الموجود وسط مكة ؟")
            name = str.replace(name, "بيت الشعر",
                               "ما هو البيت الذي ليس فيه ابواب ولا نوافذ ؟ ")
            name = str.replace(name, "لهانه",
                               "وحده حلوه ومغروره تلبس مية تنوره .من هيه ؟ ")
            name = str.replace(
                name, "انا",
                "ابن امك وابن ابيك وليس باختك ولا باخيك فمن يكون ؟")
            name = str.replace(name, "امي", "اخت خالك وليست خالتك من تكون ؟ ")
            name = str.replace(
                name, "الابره",
                "ما هو الشيئ الذي كلما خطا خطوه فقد شيئا من ذيله ؟ ")
            name = str.replace(
                name, "الساعه",
                "ما هو الشيئ الذي يقول الصدق ولكنه اذا جاع كذب ؟")
            name = str.replace(
                name, "22",
                "كم مره ينطبق عقربا الساعه على بعضهما في اليوم الواحد ")
            name = str.replace(name, "غلط",
                               "ما هي الكلمه الوحيده التي تلفض غلط دائما ؟ ")
            name = str.replace(name, "كم الساعه",
                               "ما هو السؤال الذي تختلف اجابته دائما ؟")
            name = str.replace(name, "البيتنجان",
                               "جسم اسود وقلب ابيض وراس اخظر فما هو ؟")
            name = str.replace(name, "البيض",
                               "ماهو الشيئ الذي اسمه على لونه ؟")
            name = str.replace(name, "المرايه",
                               "ارى كل شيئ من دون عيون من اكون ؟ ")
            name = str.replace(name, "الضوء",
                               "ما هو الشيئ الذي يخترق الزجاج ولا يكسره ؟")
            name = str.replace(name, "الهواء",
                               "ما هو الشيئ الذي يسير امامك ولا تراه ؟")
            name = str.replace(name, "الضل",
                               "ما هو الشيئ الذي يلاحقك اينما تذهب ؟ ")
            name = str.replace(name, "العمر",
                               "ما هو الشيء الذي كلما طال قصر ؟ ")
            name = str.replace(name, "القلم",
                               "ما هو الشيئ الذي يكتب ولا يقرأ ؟")
            name = str.replace(name, "المشط", "له أسنان ولا يعض ما هو ؟ ")
            name = str.replace(name, "الحفره",
                               "ما هو الشيئ اذا أخذنا منه ازداد وكبر ؟")
            name = str.replace(
                name, "البحر",
                "ما هو الشيئ الذي يرفع اثقال ولا يقدر يرفع مسمار ؟")
            name = str.replace(
                name, "الثلج",
                "انا ابن الماء فان تركوني في الماء مت فمن انا ؟")
            name = str.replace(name, "الاسفنج",
                               "كلي ثقوب ومع ذالك احفض الماء فمن اكون ؟")
            name = str.replace(
                name, "الصوت",
                "اسير بلا رجلين ولا ادخل الا بالاذنين فمن انا ؟")
            name = str.replace(name, "بلم",
                               "حامل ومحمول نصف ناشف ونصف مبلول فمن اكون ؟ ")
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": f"🔰┇ اسرع واحد يحل الحزوره : {name}",
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html",
                    "disable_web_page_preview": True
                })
        if re.search(str(redis.get("{}Nbot:Hzor".format(BOT_ID))), text):
            textmsg = "🎁┇مبروك. لقد حصلت على 8 نقاط زيادة كمكافأة لك للعب مرة اخرى ارسل {حزوره}"
            redis.hincrby("{}Nbot:{}:points".format(BOT_ID, chatID), userID, 8)
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": textmsg,
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html",
                    "disable_web_page_preview": True
                })
            redis.delete("{}Nbot:Hzor".format(BOT_ID))
        if text and re.search("^معاني$", text) and not redis.sismember(
                "{}Nbot:gpgames".format(BOT_ID), chatID):
            Maany_Rand = [
                "قرد", "دجاجه", "بطريق", "ضفدع", "بومه", "نحله", "ديك", "جمل",
                "بقره", "دولفين", "تمساح", "قرش", "نمر", "اخطبوط", "سمكه",
                "خفاش", "اسد", "فأر", "ذئب", "فراشه", "عقرب", "زرافه", "قنفذ",
                "تفاحه", "باذنجان"
            ]
            name = random.choice(Maany_Rand)
            temp = redis.set("{}Nbot:MaanyRand".format(BOT_ID), name)
            name = str.replace(name, "قرد", "🐒")
            name = str.replace(name, "دجاجه", "🐔")
            name = str.replace(name, "بطريق", "🐧")
            name = str.replace(name, "ضفدع", "🐸")
            name = str.replace(name, "بومه", "🦉")
            name = str.replace(name, "نحله", "🐝")
            name = str.replace(name, "ديك", "🐓")
            name = str.replace(name, "جمل", "🐫")
            name = str.replace(name, "بقره", "🐄")
            name = str.replace(name, "دولفين", "🐬")
            name = str.replace(name, "تمساح", "🐊")
            name = str.replace(name, "قرش", "🦈")
            name = str.replace(name, "نمر", "🐅")
            name = str.replace(name, "اخطبوط", "🐙")
            name = str.replace(name, "سمكه", "🐟")
            name = str.replace(name, "خفاش", "🦇")
            name = str.replace(name, "اسد", "🦁")
            name = str.replace(name, "فأر", "🐭")
            name = str.replace(name, "ذئب", "🐺")
            name = str.replace(name, "فراشه", "🦋")
            name = str.replace(name, "عقرب", "🦂")
            name = str.replace(name, "زرافه", "🦒")
            name = str.replace(name, "قنفذ", "🦔")
            name = str.replace(name, "تفاحه", "🍎")
            name = str.replace(name, "باذنجان", "🍆")
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": f"🔰┇ اسرع واحد يدز معنى السمايل : {name}",
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html",
                    "disable_web_page_preview": True
                })
        if re.search(str(redis.get("{}Nbot:MaanyRand".format(BOT_ID))), text):
            textmsg = "🎁┇مبروك. لقد حصلت على 6 نقاط زيادة كمكافأة لك للعب مرة اخرى ارسل {معاني}"
            redis.hincrby("{}Nbot:{}:points".format(BOT_ID, chatID), userID, 6)
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": textmsg,
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html",
                    "disable_web_page_preview": True
                })
            redis.delete("{}Nbot:MaanyRand".format(BOT_ID))
        if text and re.search("^العكس$", text) and not redis.sismember(
                "{}Nbot:gpgames".format(BOT_ID), chatID):
            katu = [
                "باي", "فهمت", "موزين", "اسمعك", "احبك", "موحلو", "نضيف",
                "حاره", "ناصي", "جوه", "سريع", "ونسه", "طويل", "سمين", "ضعيف",
                "شريف", "شجاع", "رحت", "عدل", "نشيط", "شبعان", "موعطشان",
                "خوش ولد", "اني", "هادئ"
            ]
            name = random.choice(katu)
            temp = redis.set("{}Nbot:opissite".format(BOT_ID), name)
            name = str.replace(name, "باي", "هلو")
            name = str.replace(name, "فهمت", "مافهمت")
            name = str.replace(name, "موزين", "زين")
            name = str.replace(name, "اسمعك", "ماسمعك")
            name = str.replace(name, "احبك", "ماحبك")
            name = str.replace(name, "موحلو", "حلو")
            name = str.replace(name, "نضيف", "وصخ")
            name = str.replace(name, "حاره", "بارده")
            name = str.replace(name, "ناصي", "عالي")
            name = str.replace(name, "جوه", "فوك")
            name = str.replace(name, "سريع", "بطيء")
            name = str.replace(name, "ونسه", "ضوجه")
            name = str.replace(name, "طويل", "قزم")
            name = str.replace(name, "سمين", "ضعيف")
            name = str.replace(name, "ضعيف", "قوي")
            name = str.replace(name, "شريف", "كواد")
            name = str.replace(name, "شجاع", "جبان")
            name = str.replace(name, "رحت", "اجيت")
            name = str.replace(name, "عدل", "ميت")
            name = str.replace(name, "نشيط", "كسول")
            name = str.replace(name, "شبعان", "جوعان")
            name = str.replace(name, "موعطشان", "عطشان")
            name = str.replace(name, "خوش ولد", "موخوش ولد")
            name = str.replace(name, "اني", "مطي")
            name = str.replace(name, "هادئ", "عصبي")
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": f"🔰┇ اسرع واحد يدز العكس : {name}",
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html",
                    "disable_web_page_preview": True
                })

        if re.search(str(redis.get("{}Nbot:opissite".format(BOT_ID))), text):
            textmsg = "🎁┇مبروك. لقد حصلت على 10 نقاط زيادة كمكافأة لك للعب مرة اخرى ارسل {العكس}"
            redis.hincrby("{}Nbot:{}:points".format(BOT_ID, chatID), userID,
                          10)
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": textmsg,
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html",
                    "disable_web_page_preview": True
                })
            redis.delete("{}Nbot:opissite".format(BOT_ID))

        if text and re.search("^امثله$", text) and not redis.sismember(
                "{}Nbot:gpgames".format(BOT_ID), chatID):
            mthal = [
                "جوز", "ضراطه", "الحبل", "الحافي", "شقره", "بيدك", "سلايه",
                "النخله", "الخيل", "حداد", "المبلل", "يركص", "قرد", "العنب",
                "العمه", "الخبز", "بالحصاد", "شهر", "شكه", "يكحله"
            ]
            name = random.choice(mthal)
            temp = redis.set("{}Nbot:amthila".format(BOT_ID), name)
            name = str.replace(name, "جوز", "ينطي____للماعده سنون")
            name = str.replace(name, "ضراطه", "الي يسوق المطي يتحمل___")
            name = str.replace(name, "بيدك", "اكل___محد يفيدك")
            name = str.replace(name, "الحافي", "تجدي من___نعال")
            name = str.replace(name, "شقره", "مع الخيل يا___")
            name = str.replace(name, "النخله", "الطول طول___والعقل عقل الصخلة")
            name = str.replace(name, "سلايه", "بالوجه امراية وبالظهر___")
            name = str.replace(name, "الخيل", "من قلة___شدو على الچلاب سروج")
            name = str.replace(name, "حداد", "موكل من صخم وجهه كال آني___")
            name = str.replace(name, "المبلل", "___ما يخاف من المطر")
            name = str.replace(name, "الحبل",
                               "اللي تلدغة الحية يخاف من جرة___")
            name = str.replace(name, "يركص", "المايعرف___يكول الكاع عوجه")
            name = str.replace(name, "العنب", "المايلوح___يكول حامض")
            name = str.replace(name, "العمه",
                               "___إذا حبت الچنة ابليس يدخل الجنة")
            name = str.replace(name, "الخبز", "انطي___للخباز حتى لو ياكل نصه")
            name = str.replace(name, "باحصاد", "اسمة___ومنجله مكسور")
            name = str.replace(name, "شهر", "امشي__ولا تعبر نهر")
            name = str.replace(name, "شكه",
                               "يامن تعب يامن__يا من على الحاضر لكة")
            name = str.replace(name, "القرد", "__بعين امه غزال")
            name = str.replace(name, "يكحله", "اجه___عماها")
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": f"🔰┇ اسرع واحد يكمل المثل : {name}",
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html",
                    "disable_web_page_preview": True
                })
        if re.search(str(redis.get("{}Nbot:amthila".format(BOT_ID))), text):
            textmsg = "🎁┇مبروك. لقد حصلت على 10 نقاط زيادة كمكافأة لك للعب مرة اخرى ارسل {امثله}"
            redis.hincrby("{}Nbot:{}:points".format(BOT_ID, chatID), userID,
                          10)
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": textmsg,
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html",
                    "disable_web_page_preview": True
                })
            redis.delete("{}Nbot:amthila".format(BOT_ID))
        if text and re.search("بوبي", text):
            namebot = [
                "عمري فداك  بوبي", " ها حبيبي 🌚♥️ ", "كول حبيبي ؟ ",
                " ها حبي وياك مكتب ئلسيد ", " الو الو رد مخنوك ",
                "ها يحلو كول", " عمري الحلو ",
                " صاعد اتصال ويا الحب دقيقة وجيك 😘💘 ", " مشغول حالياً 🌚🌸 ",
                " لابسك لتلح ", " هايروحي؟ "
            ]
            randomresponse = random.choice(namebot)
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": randomresponse,
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html",
                    "disable_web_page_preview": True
                })

        if text and re.search("^بيع نقاطي$", text):
            msgsCount = int(
                (redis.hget("{}Nbot:{}:points".format(BOT_ID, chatID), userID)
                 or 0)) * 2
            if msgsCount == 0:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": f"📮┇عذرا لا يوجد لديك عدد كاف من النقاط ",
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html"
                    })
            else:
                redis.hincrby("{}Nbot:{}:msgs".format(BOT_ID, chatID), userID,
                              msgsCount)
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text":
                        f"✅꒐تم بيع جميع نقاطك مقابل {msgsCount} رسالة ",
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html"
                    })
                redis.delete("{}Nbot:{}:points".format(BOT_ID, chatID), userID)

        if text == "رتبتي":
            t = IDrank(redis, userID, chatID, r)
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": f"⏏️꒐ موقعك : {t}",
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html"
                })
        if text == c.ID and not redis.sismember(
                "{}Nbot:IDSend".format(BOT_ID),
                chatID) and message.reply_to_message:
            us = message.reply_to_message.from_user.id
            rusername = message.reply_to_message.from_user.username
            if rusername is None:
                rusername = "******"
            t = IDrank(redis, us, chatID, r)
            msgs = (redis.hget("{}Nbot:{}:msgs".format(BOT_ID, chatID), us)
                    or 0)
            edits = (redis.hget("{}Nbot:{}:edits".format(BOT_ID, chatID), us)
                     or 0)
            rate = int(msgs) * 100 / 20000
            age = getAge(us, r)
            tx = r.ReIDnPT
            Bot(
                "sendMessage", {
                    "chat_id":
                    chatID,
                    "text":
                    tx.format(Reus=("@" + rusername or "None"),
                              ReID=us,
                              Rerank=t,
                              Remsgs=msgs,
                              Reedits=edits,
                              Rage=age,
                              Rerate=str(rate) + "%"),
                    "reply_to_message_id":
                    message.message_id,
                    "parse_mode":
                    "html"
                })
        if re.search(c.idus, text) and not redis.sismember(
                "{}Nbot:IDSend".format(BOT_ID), chatID):
            user = text.split("@")[1]
            try:
                getUser = client.get_users(user)
                us = getUser.id
                rusername = user
                if rusername is None:
                    rusername = "******"
                age = getAge(us, r)
                t = IDrank(redis, us, chatID, r)
                msgs = (redis.hget("{}Nbot:{}:msgs".format(BOT_ID, chatID), us)
                        or 0)
                edits = (redis.hget("{}Nbot:{}:edits".format(BOT_ID, chatID),
                                    us) or 0)
                rate = int(msgs) * 100 / 20000
                tx = r.ReIDnPT
                Bot(
                    "sendMessage", {
                        "chat_id":
                        chatID,
                        "text":
                        tx.format(Reus=("@" + rusername or "None"),
                                  ReID=us,
                                  Rerank=t,
                                  Remsgs=msgs,
                                  Reedits=edits,
                                  Rage=age,
                                  Rerate=str(rate) + "%"),
                        "reply_to_message_id":
                        message.message_id,
                        "parse_mode":
                        "html"
                    })
            except Exception as e:
                print(e)

        if re.search(c.ShowSudos, text):
            tx = (redis.get("{}Nbot:SHOWsudos".format(BOT_ID)) or "")
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": tx,
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html"
                })
        if text == c.mymsgs:
            get = redis.hget("{}Nbot:{}:msgs".format(BOT_ID, chatID), userID)
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": r.yourmsgs.format((get or 0)),
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html"
                })
        if text == c.link and not redis.sismember(
                "{}Nbot:showlink".format(BOT_ID), chatID):
            get = (redis.hget("{}Nbot:links".format(BOT_ID), chatID)
                   or GetLink(chatID) or "none")
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": r.showGPlk.format(get),
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html",
                    "disable_web_page_preview": True
                })

        if text == c.myedits:
            get = redis.hget("{}Nbot:{}:edits".format(BOT_ID, chatID), userID)
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": r.youredits.format((get or 0)),
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html"
                })

        if text == c.myaddcontact:
            get = redis.hget("{}Nbot:{}:addcontact".format(BOT_ID, chatID),
                             userID)
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": r.youraddcontact.format((get or 0)),
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html"
                })

        if not redis.sismember("{}Nbot:ReplySendBOT".format(BOT_ID), chatID):
            if redis.hexists("{}Nbot:TXreplys".format(BOT_ID), text):
                tx = redis.hget("{}Nbot:TXreplys".format(BOT_ID), text)
                try:
                    rep = {
                        "#cn": "{cn}",
                        "#age": "{age}",
                        "#fn": "{fn}",
                        "#id": "{id}",
                        "#username": "******",
                        "#msgs": "{msgs}",
                        "#stast": "{stast}",
                        "#edits": "{edits}",
                        "#rate": "{rate}",
                        "{us}": "{username}",
                        "#us": "{username}"
                    }
                    for v in rep.keys():
                        tx = tx.replace(v, rep[v])
                    Bot(
                        "sendMessage", {
                            "chat_id":
                            chatID,
                            "text":
                            tx.format(fn=userFN,
                                      username=("@" + username or "n"),
                                      id=userID,
                                      stast=IDrank(redis, userID, chatID, r),
                                      cn=title),
                            "reply_to_message_id":
                            message.message_id,
                            "parse_mode":
                            "html"
                        })
                except Exception as e:
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": tx,
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "html"
                        })

            if redis.hexists("{}Nbot:STreplys".format(BOT_ID), text):
                ID = redis.hget("{}Nbot:STreplys".format(BOT_ID), text)
                Bot(
                    "sendSticker", {
                        "chat_id": chatID,
                        "sticker": ID,
                        "reply_to_message_id": message.message_id
                    })

            if redis.hexists("{}Nbot:GFreplys".format(BOT_ID), text):
                ID = redis.hget("{}Nbot:GFreplys".format(BOT_ID), text)
                Bot(
                    "sendanimation", {
                        "chat_id": chatID,
                        "animation": ID,
                        "reply_to_message_id": message.message_id
                    })

            if redis.hexists("{}Nbot:{}:VOreplys".format(BOT_ID, chatID),
                             text):
                ID = redis.hget("{}Nbot:VOreplys".format(BOT_ID), text)
                Bot(
                    "sendvoice", {
                        "chat_id": chatID,
                        "voice": ID,
                        "reply_to_message_id": message.message_id
                    })

            if redis.hexists("{}Nbot:PHreplys".format(BOT_ID, chatID), text):
                ID = redis.hget("{}Nbot:PHreplys".format(BOT_ID), text)
                Bot(
                    "sendphoto", {
                        "chat_id": chatID,
                        "photo": ID,
                        "reply_to_message_id": message.message_id
                    })

            if redis.hexists("{}Nbot:DOreplys".format(BOT_ID, chatID), text):
                ID = redis.hget("{}Nbot:DOreplys".format(BOT_ID), text)
                Bot(
                    "sendDocument", {
                        "chat_id": chatID,
                        "document": ID,
                        "reply_to_message_id": message.message_id
                    })

        if not redis.sismember("{}Nbot:ReplySend".format(BOT_ID), chatID):
            if redis.hexists("{}Nbot:{}:TXreplys".format(BOT_ID, chatID),
                             text):
                tx = redis.hget("{}Nbot:{}:TXreplys".format(BOT_ID, chatID),
                                text)
                try:
                    rep = {
                        "#cn": "{cn}",
                        "#age": "{age}",
                        "#fn": "{fn}",
                        "#id": "{id}",
                        "#username": "******",
                        "#msgs": "{msgs}",
                        "#stast": "{stast}",
                        "#edits": "{edits}",
                        "#rate": "{rate}",
                        "{us}": "{username}",
                        "#us": "{username}"
                    }
                    for v in rep.keys():
                        tx = tx.replace(v, rep[v])
                    Bot(
                        "sendMessage", {
                            "chat_id":
                            chatID,
                            "text":
                            tx.format(fn=userFN,
                                      username=("@" + username or "n"),
                                      id=userID,
                                      stast=IDrank(redis, userID, chatID, r),
                                      cn=title),
                            "reply_to_message_id":
                            message.message_id,
                            "parse_mode":
                            "html"
                        })
                except Exception as e:
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": tx,
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "html"
                        })

            if redis.hexists("{}Nbot:{}:STreplys".format(BOT_ID, chatID),
                             text):
                ID = redis.hget("{}Nbot:{}:STreplys".format(BOT_ID, chatID),
                                text)
                Bot(
                    "sendSticker", {
                        "chat_id": chatID,
                        "sticker": ID,
                        "reply_to_message_id": message.message_id
                    })

            if redis.hexists("{}Nbot:{}:GFreplys".format(BOT_ID, chatID),
                             text):
                ID = redis.hget("{}Nbot:{}:GFreplys".format(BOT_ID, chatID),
                                text)
                Bot(
                    "sendanimation", {
                        "chat_id": chatID,
                        "animation": ID,
                        "reply_to_message_id": message.message_id
                    })

            if redis.hexists("{}Nbot:{}:VOreplys".format(BOT_ID, chatID),
                             text):
                ID = redis.hget("{}Nbot:{}:VOreplys".format(BOT_ID, chatID),
                                text)
                Bot(
                    "sendvoice", {
                        "chat_id": chatID,
                        "voice": ID,
                        "reply_to_message_id": message.message_id
                    })

            if redis.hexists("{}Nbot:{}:AUreplys".format(BOT_ID, chatID),
                             text):
                ID = redis.hget("{}Nbot:{}:AUreplys".format(BOT_ID, chatID),
                                text)
                Bot(
                    "sendaudio", {
                        "chat_id": chatID,
                        "audio": ID,
                        "reply_to_message_id": message.message_id
                    })

            if redis.hexists("{}Nbot:{}:PHreplys".format(BOT_ID, chatID),
                             text):
                ID = redis.hget("{}Nbot:{}:PHreplys".format(BOT_ID, chatID),
                                text)
                Bot(
                    "sendphoto", {
                        "chat_id": chatID,
                        "photo": ID,
                        "reply_to_message_id": message.message_id
                    })

            if redis.hexists("{}Nbot:{}:DOreplys".format(BOT_ID, chatID),
                             text):
                ID = redis.hget("{}Nbot:{}:DOreplys".format(BOT_ID, chatID),
                                text)
                Bot(
                    "sendDocument", {
                        "chat_id": chatID,
                        "document": ID,
                        "reply_to_message_id": message.message_id
                    })

    if redis.smembers("{}Nbot:botfiles".format(BOT_ID)):
        onlyfiles = [f for f in listdir("files") if isfile(join("files", f))]
        filesR = redis.smembers("{}Nbot:botfiles".format(BOT_ID))
        for f in onlyfiles:
            if f in filesR:
                fi = f.replace(".py", "")
                UpMs = "files." + fi
                try:
                    U = importlib.import_module(UpMs)
                    t = threading.Thread(target=U.updateMsgs,
                                         args=(client, message, redis))
                    t.daemon = True
                    t.start()
                    importlib.reload(U)
                except Exception as e:
                    import traceback
                    traceback.print_exc()
                    print(e)
                    pass
示例#9
0
文件: tr.py 项目: Medo-X/Nitro-files
def updateMsgs(client, message,redis):
  type = message.chat.type
  userID = message.from_user.id
  chatID = message.chat.id
  rank = isrank(redis,userID,chatID)
  text = message.text
  title = message.chat.title
  userFN = message.from_user.first_name
  type = message.chat.type

  if text and text == "نقل البيانات" and rank == "sudo":
    if redis.smembers(BOT_ID+"Tshake:Chek:Groups"):
      Ngp = redis.scard(BOT_ID+"Tshake:Chek:Groups")
      Bot("sendMessage",{"chat_id":chatID,"text":"تم ايجاد ({}) مجموعات خاصه بسورس تشاكي سيتم نقلها الى (<a href=\"http://t.me/vvhvvv\">Nitro</a>)\nقد يستغرق بعض الوقت".format(Ngp),"reply_to_message_id":message.message_id,"parse_mode":"html","disable_web_page_preview":True})
    else:
      Bot("sendMessage",{"chat_id":chatID,"text":"عذراً لا توجد بيانات خاصه بسورس تشاكي","reply_to_message_id":message.message_id,"parse_mode":"html","disable_web_page_preview":True})
      return False

    groups = redis.smembers(BOT_ID+"Tshake:Chek:Groups")
    for gp in groups:
      redis.sadd("{}Nbot:groups".format(BOT_ID),gp)
      ads =redis.smembers(BOT_ID+'Tshake:Mod:User'+gp)
      ows =redis.smembers(BOT_ID+'Tshake:Manager'+gp)
      vps =redis.smembers(BOT_ID+'Tshake:Special:User'+gp)
      cr = Bot("getChatAdministrators",{"chat_id":gp})
      for c in cr['result']:
        userId = c["user"]["id"]
        if c['status'] == "creator":
          setrank(redis,"creator",userId,gp,"one")
          break
      for ad in ads:
        if ad != BOT_ID:
          redis.sadd("{}Nbot:{}:{}".format(BOT_ID,gp,"admin"),ad)

      for ow in ows:
        if ow != BOT_ID:
          redis.sadd("{}Nbot:{}:{}".format(BOT_ID,gp,"owner"),ow)

      for vp in vps:
        if vp != BOT_ID:
          redis.sadd("{}Nbot:{}:{}".format(BOT_ID,gp,"vip"),vp)

      if redis.get(BOT_ID+"Tshake:Lock:tagservr"+gp):
        redis.sadd("{}Nbot:Ltag".format(BOT_ID),gp)
      if redis.get(BOT_ID+"Tshake:Lock:edit"+gp):
        redis.sadd("{}Nbot:Ledits".format(BOT_ID),gp)
      if redis.hget(BOT_ID+"Tshake:flooding:settings:"+gp,"flood"):
        redis.sadd("{}Nbot:Lflood".format(BOT_ID),gp)
      if redis.get(BOT_ID+"Tshake:Lock:Animation"+gp):
        redis.sadd("{}Nbot:Lgifs".format(BOT_ID),gp)
      if redis.get(BOT_ID+"Tshake:Lock:Document"+gp):
        redis.sadd("{}Nbot:Lfiles".format(BOT_ID),gp)
      if redis.get(BOT_ID+"Tshake:Lock:Markdaun"+gp):
        redis.sadd("{}Nbot:Lmarkdown".format(BOT_ID),gp)
      if redis.get(BOT_ID+"Tshake:Lock:Photo"+gp):
        redis.sadd("{}Nbot:Lphoto".format(BOT_ID),gp)
      if redis.get(BOT_ID+"Tshake:Lock:Sticker"+gp):
        redis.sadd("{}Nbot:Lsticker".format(BOT_ID),gp)
      if redis.get(BOT_ID+"Tshake:Lock:Video"+gp):
        redis.sadd("{}Nbot:Lvideo".format(BOT_ID),gp)
      if redis.get(BOT_ID+"Tshake:Lock:Audio"+gp):
        redis.sadd("{}Nbot:Lmusic".format(BOT_ID),gp)
      if redis.get(BOT_ID+"Tshake:Lock:vico"+gp):
        redis.sadd("{}Nbot:Lvoice".format(BOT_ID),gp)
      if redis.get(BOT_ID+"Tshake:Lock:Contact"+gp):
        redis.sadd("{}Nbot:Lcontact".format(BOT_ID),gp)
      if redis.get(BOT_ID+"Tshake:Lock:forward"+gp):
        redis.sadd("{}Nbot:Lfwd".format(BOT_ID),gp)
      if redis.get(BOT_ID+"Tshake:Lock:Link"+gp):
        redis.sadd("{}Nbot:Llink".format(BOT_ID),gp)
      if redis.get(BOT_ID+"Tshake:Lock:User:Name"+gp):
        redis.sadd("{}Nbot:Lusername".format(BOT_ID),gp)

    Bot("sendMessage",{"chat_id":chatID,"text":"تم نقل البيانات من سورس تشاكي الى (<a href=\"http://t.me/vvhvvv\">Nitro</a>)","reply_to_message_id":message.message_id,"parse_mode":"html","disable_web_page_preview":True})
示例#10
0
文件: all.py 项目: zzmmlk/TshakeV2
def allGP(client, message, redis):
    type = message.chat.type
    userID = message.from_user.id
    chatID = message.chat.id
    username = message.from_user.username
    if username is None:
        username = "******"
    userFN = message.from_user.first_name
    title = message.chat.title
    rank = isrank(redis, userID, chatID)
    text = message.text
    c = importlib.import_module("lang.arcmd")
    r = importlib.import_module("lang.arreply")
    redis.hincrby("{}Nbot:{}:msgs".format(BOT_ID, chatID), userID)
    if text:
        if re.search(c.setGPadmin, text):
            if re.search("@", text):
                user = text.split("@")[1]
            if re.search(c.setGPadmin2, text):
                user = int(re.search(r'\d+', text).group())
            if message.reply_to_message:
                user = message.reply_to_message.from_user.id
            if 'user' not in locals(): return False
            if GPranks(userID, chatID) == "member": return False
            Getus = Bot("getChatMember", {
                "chat_id": chatID,
                "user_id": userID
            })["result"]
            if Getus["status"] == "administrator" and not Getus[
                    "can_promote_members"]:
                return False
            try:
                getUser = client.get_users(user)
                userId = getUser.id
                userFn = getUser.first_name
                if GPranks(userId, chatID) != "member": return False
                pr = Bot(
                    "promoteChatMember", {
                        "chat_id": chatID,
                        "user_id": userId,
                        "can_change_info": 1,
                        "can_delete_messages": 1,
                        "can_invite_users": 1,
                        "can_restrict_members": 1,
                        "can_pin_messages": 1
                    })
                if pr["ok"]:
                    T = "<a href=\"tg://user?id={}\">{}</a>".format(
                        userId, Name(userFn))
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.prGPadmin.format(T),
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "html"
                        })
            except Exception as e:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.userNocc,
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html"
                    })

        if re.search(c.sors, text):
            kb = InlineKeyboardMarkup(
                [[InlineKeyboardButton("قناه السورس 📢", url="t.me/zx_xx")],
                 [InlineKeyboardButton("تواصل السورس 💬", url="t.me/A_5bot")],
                 [
                     InlineKeyboardButton("شروحات السورس 📑",
                                          url="t.me/tshaketeam")
                 ]])
            Botuser = client.get_me().username
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": r.sors.format("@" + Botuser),
                    "disable_web_page_preview": True,
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "markdown",
                    "reply_markup": kb
                })

        if re.search(c.dellink, text):
            kb = InlineKeyboardMarkup([[
                InlineKeyboardButton(c.dellink2,
                                     url="https://telegram.org/deactivate")
            ]])
            Botuser = client.get_me().username
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": r.dellink,
                    "disable_web_page_preview": True,
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "markdown",
                    "reply_markup": kb
                })

        if re.search(c.ShowO, text) and (rank is not False or rank is not 0
                                         or rank != "vip"):
            reply_markup = getOR(rank, r, userID)
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": r.Showall,
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html",
                    "disable_web_page_preview": True,
                    "reply_markup": reply_markup
                })

        if text == "عدد الكروب" and (rank is not False or rank is not 0):
            from pyrogram.api.functions.channels import GetFullChannel
            chat = client.resolve_peer(chatID)
            full_chat = client.send(GetFullChannel(channel=chat)).full_chat
            Bot(
                "sendMessage", {
                    "chat_id":
                    chatID,
                    "text":
                    r.gpinfo.format(
                        message.chat.title, full_chat.participants_count,
                        full_chat.admins_count, full_chat.kicked_count,
                        full_chat.banned_count, message.message_id),
                    "reply_to_message_id":
                    message.message_id,
                    "parse_mode":
                    "html",
                    "disable_web_page_preview":
                    True
                })
        if text == c.ID and not redis.sismember(
                "{}Nbot:IDSend".format(BOT_ID),
                chatID) and not message.reply_to_message:
            Ch = True
            # if redis.sismember("{}Nbot:IDpt".format(BOT_ID),chatID):
            t = IDrank(redis, userID, chatID, r)
            msgs = (redis.hget("{}Nbot:{}:msgs".format(BOT_ID, chatID), userID)
                    or 0)
            edits = (redis.hget("{}Nbot:{}:edits".format(BOT_ID, chatID),
                                userID) or 0)
            rate = int(msgs) * 100 / 20000
            age = getAge(userID, r)
            if redis.hget("{}Nbot:SHOWid".format(BOT_ID), chatID):
                tx = redis.hget("{}Nbot:SHOWid".format(BOT_ID), chatID)
                rep = {
                    "#age": "{age}",
                    "#name": "{name}",
                    "#id": "{id}",
                    "#username": "******",
                    "#msgs": "{msgs}",
                    "#stast": "{stast}",
                    "#edits": "{edits}",
                    "#rate": "{rate}",
                    "{us}": "{username}",
                    "#us": "{username}"
                }
                for v in rep.keys():
                    tx = tx.replace(v, rep[v])
            else:
                tx = r.IDnPT
            if not redis.sismember("{}Nbot:IDSendPH".format(BOT_ID), chatID):
                get = Bot("getUserProfilePhotos", {
                    "user_id": userID,
                    "offset": 0,
                    "limit": 1
                })
                if get["ok"] == False:
                    Ch = True
                elif get["result"]["total_count"] == 0:
                    Ch = True
                else:
                    Ch = False
                    file_id = get["result"]["photos"][0][0]["file_id"]
                    Bot(
                        "sendPhoto", {
                            "chat_id":
                            chatID,
                            "photo":
                            file_id,
                            "caption":
                            tx.format(username=("@" + username or "None"),
                                      id=userID,
                                      stast=t,
                                      msgs=msgs,
                                      edits=edits,
                                      age=age,
                                      rate=str(rate) + "%"),
                            "reply_to_message_id":
                            message.message_id,
                            "parse_mode":
                            "html"
                        })
            if Ch == True:
                Bot(
                    "sendMessage", {
                        "chat_id":
                        chatID,
                        "text":
                        tx.format(username=("@" + username or "None"),
                                  id=userID,
                                  stast=t,
                                  msgs=msgs,
                                  edits=edits,
                                  age=age,
                                  rate=str(rate) + "%"),
                        "reply_to_message_id":
                        message.message_id,
                        "parse_mode":
                        "html"
                    })

            # if not redis.sismember("{}Nbot:IDSendPH".format(BOT_ID),chatID) and not redis.sismember("{}Nbot:IDpt".format(BOT_ID),chatID):
            #   get = Bot("getUserProfilePhotos",{"user_id":userID,"offset":0,"limit":1})
            #   if get["ok"] == False:
            #     Ch = True
            #   elif get["result"]["total_count"] == 0:
            #     Ch = True
            #   else:
            #     Ch = False
            #     reply_markup = InlineKeyboardMarkup([[InlineKeyboardButton(r.RIDPHs,callback_data=json.dumps(["ShowDateUser","",userID]))]])
            #     file_id = get["result"]["photos"][0][0]["file_id"]
            #     Bot("sendPhoto",{"chat_id":chatID,"photo":file_id,"caption":r.RID.format(userID),"reply_to_message_id":message.message_id,"parse_mode":"html","reply_markup":reply_markup})
            # if Ch == True and not redis.sismember("{}Nbot:IDpt".format(BOT_ID),chatID):
            #   reply_markup = InlineKeyboardMarkup([[InlineKeyboardButton(r.RIDPHs,callback_data=json.dumps(["ShowDateUser","",userID]))]])
            #   Bot("sendMessage",{"chat_id":chatID,"text":r.RID.format(userID),"reply_to_message_id":message.message_id,"parse_mode":"html","reply_markup":reply_markup})

        if text == "رتبتي":
            t = IDrank(redis, userID, chatID, r)
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": f"⏏️꒐ موقعك : {t}",
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html"
                })
        if text == c.ID and not redis.sismember(
                "{}Nbot:IDSend".format(BOT_ID),
                chatID) and message.reply_to_message:
            us = message.reply_to_message.from_user.id
            rusername = message.reply_to_message.from_user.username
            if rusername is None:
                rusername = "******"
            t = IDrank(redis, us, chatID, r)
            msgs = (redis.hget("{}Nbot:{}:msgs".format(BOT_ID, chatID), us)
                    or 0)
            edits = (redis.hget("{}Nbot:{}:edits".format(BOT_ID, chatID), us)
                     or 0)
            rate = int(msgs) * 100 / 20000
            age = getAge(us, r)
            tx = r.ReIDnPT
            Bot(
                "sendMessage", {
                    "chat_id":
                    chatID,
                    "text":
                    tx.format(Reus=("@" + rusername or "None"),
                              ReID=us,
                              Rerank=t,
                              Remsgs=msgs,
                              Reedits=edits,
                              Rage=age,
                              Rerate=str(rate) + "%"),
                    "reply_to_message_id":
                    message.message_id,
                    "parse_mode":
                    "html"
                })
        if re.search(c.idus, text) and not redis.sismember(
                "{}Nbot:IDSend".format(BOT_ID), chatID):
            user = text.split("@")[1]
            try:
                getUser = client.get_users(user)
                us = getUser.id
                rusername = user
                if rusername is None:
                    rusername = "******"
                age = getAge(us, r)
                t = IDrank(redis, us, chatID, r)
                msgs = (redis.hget("{}Nbot:{}:msgs".format(BOT_ID, chatID), us)
                        or 0)
                edits = (redis.hget("{}Nbot:{}:edits".format(BOT_ID, chatID),
                                    us) or 0)
                rate = int(msgs) * 100 / 20000
                tx = r.ReIDnPT
                Bot(
                    "sendMessage", {
                        "chat_id":
                        chatID,
                        "text":
                        tx.format(Reus=("@" + rusername or "None"),
                                  ReID=us,
                                  Rerank=t,
                                  Remsgs=msgs,
                                  Reedits=edits,
                                  Rage=age,
                                  Rerate=str(rate) + "%"),
                        "reply_to_message_id":
                        message.message_id,
                        "parse_mode":
                        "html"
                    })
            except Exception as e:
                print(e)

        if re.search(c.ShowSudos, text):
            tx = (redis.get("{}Nbot:SHOWsudos".format(BOT_ID)) or "")
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": tx,
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html"
                })
        if text == c.mymsgs:
            get = redis.hget("{}Nbot:{}:msgs".format(BOT_ID, chatID), userID)
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": r.yourmsgs.format((get or 0)),
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html"
                })
        if text == c.link and not redis.sismember(
                "{}Nbot:showlink".format(BOT_ID), chatID):
            get = (redis.hget("{}Nbot:links".format(BOT_ID), chatID)
                   or GetLink(chatID) or "none")
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": r.showGPlk.format(get),
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html",
                    "disable_web_page_preview": True
                })

        if text == c.myedits:
            get = redis.hget("{}Nbot:{}:edits".format(BOT_ID, chatID), userID)
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": r.youredits.format((get or 0)),
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html"
                })

        if text == c.myaddcontact:
            get = redis.hget("{}Nbot:{}:addcontact".format(BOT_ID, chatID),
                             userID)
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": r.youraddcontact.format((get or 0)),
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html"
                })

        if not redis.sismember("{}Nbot:ReplySendBOT".format(BOT_ID), chatID):
            if redis.hexists("{}Nbot:TXreplys".format(BOT_ID), text):
                tx = redis.hget("{}Nbot:TXreplys".format(BOT_ID), text)
                try:
                    rep = {
                        "#cn": "{cn}",
                        "#age": "{age}",
                        "#fn": "{fn}",
                        "#id": "{id}",
                        "#username": "******",
                        "#msgs": "{msgs}",
                        "#stast": "{stast}",
                        "#edits": "{edits}",
                        "#rate": "{rate}",
                        "{us}": "{username}",
                        "#us": "{username}"
                    }
                    for v in rep.keys():
                        tx = tx.replace(v, rep[v])
                    Bot(
                        "sendMessage", {
                            "chat_id":
                            chatID,
                            "text":
                            tx.format(fn=userFN,
                                      username=("@" + username or "n"),
                                      id=userID,
                                      stast=IDrank(redis, userID, chatID, r),
                                      cn=title),
                            "reply_to_message_id":
                            message.message_id,
                            "parse_mode":
                            "html"
                        })
                except Exception as e:
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": tx,
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "html"
                        })

            if redis.hexists("{}Nbot:STreplys".format(BOT_ID), text):
                ID = redis.hget("{}Nbot:STreplys".format(BOT_ID), text)
                Bot(
                    "sendSticker", {
                        "chat_id": chatID,
                        "sticker": ID,
                        "reply_to_message_id": message.message_id
                    })

            if redis.hexists("{}Nbot:GFreplys".format(BOT_ID), text):
                ID = redis.hget("{}Nbot:GFreplys".format(BOT_ID), text)
                Bot(
                    "sendanimation", {
                        "chat_id": chatID,
                        "animation": ID,
                        "reply_to_message_id": message.message_id
                    })

            if redis.hexists("{}Nbot:{}:VOreplys".format(BOT_ID, chatID),
                             text):
                ID = redis.hget("{}Nbot:VOreplys".format(BOT_ID), text)
                Bot(
                    "sendvoice", {
                        "chat_id": chatID,
                        "voice": ID,
                        "reply_to_message_id": message.message_id
                    })

            if redis.hexists("{}Nbot:PHreplys".format(BOT_ID, chatID), text):
                ID = redis.hget("{}Nbot:PHreplys".format(BOT_ID), text)
                Bot(
                    "sendphoto", {
                        "chat_id": chatID,
                        "photo": ID,
                        "reply_to_message_id": message.message_id
                    })

            if redis.hexists("{}Nbot:DOreplys".format(BOT_ID, chatID), text):
                ID = redis.hget("{}Nbot:DOreplys".format(BOT_ID), text)
                Bot(
                    "sendDocument", {
                        "chat_id": chatID,
                        "document": ID,
                        "reply_to_message_id": message.message_id
                    })

        if not redis.sismember("{}Nbot:ReplySend".format(BOT_ID), chatID):
            if redis.hexists("{}Nbot:{}:TXreplys".format(BOT_ID, chatID),
                             text):
                tx = redis.hget("{}Nbot:{}:TXreplys".format(BOT_ID, chatID),
                                text)
                try:
                    rep = {
                        "#cn": "{cn}",
                        "#age": "{age}",
                        "#fn": "{fn}",
                        "#id": "{id}",
                        "#username": "******",
                        "#msgs": "{msgs}",
                        "#stast": "{stast}",
                        "#edits": "{edits}",
                        "#rate": "{rate}",
                        "{us}": "{username}",
                        "#us": "{username}"
                    }
                    for v in rep.keys():
                        tx = tx.replace(v, rep[v])
                    Bot(
                        "sendMessage", {
                            "chat_id":
                            chatID,
                            "text":
                            tx.format(fn=userFN,
                                      username=("@" + username or "n"),
                                      id=userID,
                                      stast=IDrank(redis, userID, chatID, r),
                                      cn=title),
                            "reply_to_message_id":
                            message.message_id,
                            "parse_mode":
                            "html"
                        })
                except Exception as e:
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": tx,
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "html"
                        })

            if redis.hexists("{}Nbot:{}:STreplys".format(BOT_ID, chatID),
                             text):
                ID = redis.hget("{}Nbot:{}:STreplys".format(BOT_ID, chatID),
                                text)
                Bot(
                    "sendSticker", {
                        "chat_id": chatID,
                        "sticker": ID,
                        "reply_to_message_id": message.message_id
                    })

            if redis.hexists("{}Nbot:{}:GFreplys".format(BOT_ID, chatID),
                             text):
                ID = redis.hget("{}Nbot:{}:GFreplys".format(BOT_ID, chatID),
                                text)
                Bot(
                    "sendanimation", {
                        "chat_id": chatID,
                        "animation": ID,
                        "reply_to_message_id": message.message_id
                    })

            if redis.hexists("{}Nbot:{}:VOreplys".format(BOT_ID, chatID),
                             text):
                ID = redis.hget("{}Nbot:{}:VOreplys".format(BOT_ID, chatID),
                                text)
                Bot(
                    "sendvoice", {
                        "chat_id": chatID,
                        "voice": ID,
                        "reply_to_message_id": message.message_id
                    })

            if redis.hexists("{}Nbot:{}:AUreplys".format(BOT_ID, chatID),
                             text):
                ID = redis.hget("{}Nbot:{}:AUreplys".format(BOT_ID, chatID),
                                text)
                Bot(
                    "sendaudio", {
                        "chat_id": chatID,
                        "audio": ID,
                        "reply_to_message_id": message.message_id
                    })

            if redis.hexists("{}Nbot:{}:PHreplys".format(BOT_ID, chatID),
                             text):
                ID = redis.hget("{}Nbot:{}:PHreplys".format(BOT_ID, chatID),
                                text)
                Bot(
                    "sendphoto", {
                        "chat_id": chatID,
                        "photo": ID,
                        "reply_to_message_id": message.message_id
                    })

            if redis.hexists("{}Nbot:{}:DOreplys".format(BOT_ID, chatID),
                             text):
                ID = redis.hget("{}Nbot:{}:DOreplys".format(BOT_ID, chatID),
                                text)
                Bot(
                    "sendDocument", {
                        "chat_id": chatID,
                        "document": ID,
                        "reply_to_message_id": message.message_id
                    })

    if redis.smembers("{}Nbot:botfiles".format(BOT_ID)):
        onlyfiles = [f for f in listdir("files") if isfile(join("files", f))]
        filesR = redis.smembers("{}Nbot:botfiles".format(BOT_ID))
        for f in onlyfiles:
            if f in filesR:
                fi = f.replace(".py", "")
                UpMs = "files." + fi
                try:
                    U = importlib.import_module(UpMs)
                    t = threading.Thread(target=U.updateMsgs,
                                         args=(client, message, redis))
                    t.daemon = True
                    t.start()
                    importlib.reload(U)
                except Exception as e:
                    import traceback
                    traceback.print_exc()
                    print(e)
                    pass
示例#11
0
文件: all.py 项目: NewBotMD/NB
def allGP(client, message,redis):
  type = message.chat.type
  userID = message.from_user.id
  chatID = message.chat.id
  username = message.from_user.username
  if username is None:
    username = "******"
  userFN = message.from_user.first_name
  title = message.chat.title
  rank = isrank(redis,userID,chatID)
  text = message.text

  lang = Glang(redis,chatID)

  moduleCMD = "lang."+lang+"-cmd"
  moduleREPLY = "lang."+lang+"-reply"
  c = importlib.import_module(moduleCMD)
  r = importlib.import_module(moduleREPLY)
  redis.hincrby("{}Nbot:{}:msgs".format(BOT_ID,chatID),userID)
  if text :
    if re.search(c.setGPadmin,text):
      if re.search("@",text):
        user = text.split("@")[1]
      if re.search(c.setGPadmin2,text):
        user = int(re.search(r'\d+', text).group())
      if message.reply_to_message:
        user = message.reply_to_message.from_user.id
      if 'user' not in locals():return False
      if GPranks(userID,chatID) == "member":return False
      Getus = Bot("getChatMember",{"chat_id":chatID,"user_id":userID})["result"]
      if Getus["status"] == "administrator" and not Getus["can_promote_members"]:return False
      try:
        getUser = client.get_users(user)
        userId = getUser.id
        userFn = getUser.first_name
        if GPranks(userId,chatID) != "member":return False
        pr = Bot("promoteChatMember",{"chat_id":chatID,"user_id":userId,"can_change_info":1,"can_delete_messages":1,"can_invite_users":1,"can_restrict_members":1,"can_pin_messages":1})
        if pr["ok"]:
          T ="<a href=\"tg://user?id={}\">{}</a>".format(userId,Name(userFn))
          Bot("sendMessage",{"chat_id":chatID,"text":r.prGPadmin.format(T),"reply_to_message_id":message.message_id,"parse_mode":"html"})
      except Exception as e:
        Bot("sendMessage",{"chat_id":chatID,"text":r.userNocc,"reply_to_message_id":message.message_id,"parse_mode":"html"})

    if re.search(c.sors,text):
      kb = InlineKeyboardMarkup([[InlineKeyboardButton(r.MoreInfo, url="t.me/nbbot")]])
      Botuser = client.get_me().username
      Bot("sendMessage",{"chat_id":chatID,"text":r.sors.format("@"+Botuser),"disable_web_page_preview":True,"reply_to_message_id":message.message_id,"parse_mode":"markdown","reply_markup":kb})
    
    if re.search(c.dellink,text):
      kb = InlineKeyboardMarkup([[InlineKeyboardButton(c.dellink2, url="https://telegram.org/deactivate")]])
      Botuser = client.get_me().username
      Bot("sendMessage",{"chat_id":chatID,"text":r.dellink,"disable_web_page_preview":True,"reply_to_message_id":message.message_id,"parse_mode":"markdown","reply_markup":kb})

    if re.search(c.ShowO,text) and (rank is not False or rank is not  0 or rank != "vip"):
      reply_markup = getOR(rank,r,userID)
      Bot("sendMessage",{"chat_id":chatID,"text":r.Showall,"reply_to_message_id":message.message_id,"parse_mode":"html","disable_web_page_preview":True,"reply_markup":reply_markup})

    if text == c.ID and not redis.sismember("{}Nbot:IDSend".format(BOT_ID),chatID) and not message.reply_to_message:
      Ch = True
      if redis.sismember("{}Nbot:IDpt".format(BOT_ID),chatID):
        t = IDrank(redis,userID,chatID,r)
        msgs = (redis.hget("{}Nbot:{}:msgs".format(BOT_ID,chatID),userID) or 0)
        edits = (redis.hget("{}Nbot:{}:edits".format(BOT_ID,chatID),userID) or 0)
        rate = int(msgs)*100/20000
        age = getAge(userID,r)
        if redis.hget("{}Nbot:SHOWid".format(BOT_ID),chatID):
          tx = redis.hget("{}Nbot:SHOWid".format(BOT_ID),chatID)
        else:
          tx = r.IDnPT
        if not redis.sismember("{}Nbot:IDSendPH".format(BOT_ID),chatID):
          get = Bot("getUserProfilePhotos",{"user_id":userID,"offset":0,"limit":1})
          if get["ok"] == False: 
            Ch = True
          elif get["result"]["total_count"] == 0:
            Ch = True
          else:
            Ch = False
            file_id = get["result"]["photos"][0][0]["file_id"]
            Bot("sendPhoto",{"chat_id":chatID,"photo":file_id,"caption":tx.format(us=("@"+username or "None"),id=userID,rk=t,msgs=msgs,edits=edits,age=age,rate=str(rate)+"%"),"reply_to_message_id":message.message_id,"parse_mode":"html"})
        if Ch == True:
          Bot("sendMessage",{"chat_id":chatID,"text":tx.format(us=("@"+username or "None"),id=userID,rk=t,msgs=msgs,edits=edits,age=age,rate=str(rate)+"%"),"reply_to_message_id":message.message_id,"parse_mode":"html"})

      if not redis.sismember("{}Nbot:IDSendPH".format(BOT_ID),chatID) and not redis.sismember("{}Nbot:IDpt".format(BOT_ID),chatID):
        get = Bot("getUserProfilePhotos",{"user_id":userID,"offset":0,"limit":1})
        if get["ok"] == False: 
          Ch = True
        elif get["result"]["total_count"] == 0:
          Ch = True
        else:
          Ch = False
          reply_markup = InlineKeyboardMarkup([[InlineKeyboardButton(r.RIDPHs,callback_data=json.dumps(["ShowDateUser","",userID]))]])
          file_id = get["result"]["photos"][0][0]["file_id"]
          Bot("sendPhoto",{"chat_id":chatID,"photo":file_id,"caption":r.RID.format(userID),"reply_to_message_id":message.message_id,"parse_mode":"html","reply_markup":reply_markup})
      if Ch == True and not redis.sismember("{}Nbot:IDpt".format(BOT_ID),chatID):
        reply_markup = InlineKeyboardMarkup([[InlineKeyboardButton(r.RIDPHs,callback_data=json.dumps(["ShowDateUser","",userID]))]])
        Bot("sendMessage",{"chat_id":chatID,"text":r.RID.format(userID),"reply_to_message_id":message.message_id,"parse_mode":"html","reply_markup":reply_markup})



    if text == c.ID and not redis.sismember("{}Nbot:IDSend".format(BOT_ID),chatID) and message.reply_to_message:
      us = message.reply_to_message.from_user.id
      rusername = message.reply_to_message.from_user.username
      if rusername is None:
        rusername = "******"
      t = IDrank(redis,us,chatID,r)
      msgs = (redis.hget("{}Nbot:{}:msgs".format(BOT_ID,chatID),us) or 0)
      edits = (redis.hget("{}Nbot:{}:edits".format(BOT_ID,chatID),us) or 0)
      rate = int(msgs)*100/20000
      age = getAge(us,r)
      tx = r.ReIDnPT
      Bot("sendMessage",{"chat_id":chatID,"text":tx.format(Reus=("@"+rusername or "None"),ReID=us,Rerank=t,Remsgs=msgs,Reedits=edits,Rage=age,Rerate=str(rate)+"%"),"reply_to_message_id":message.message_id,"parse_mode":"html"})
    if re.search(c.idus,text) and not redis.sismember("{}Nbot:IDSend".format(BOT_ID),chatID):
      user = text.split("@")[1]
      try:
        getUser = client.get_users(user)
        us = getUser.id
        rusername = user
        if rusername is None:
          rusername = "******"
        age = getAge(us,r)
        t = IDrank(redis,us,chatID,r)
        msgs = (redis.hget("{}Nbot:{}:msgs".format(BOT_ID,chatID),us) or 0)
        edits = (redis.hget("{}Nbot:{}:edits".format(BOT_ID,chatID),us) or 0)
        rate = int(msgs)*100/20000
        tx = r.ReIDnPT
        Bot("sendMessage",{"chat_id":chatID,"text":tx.format(Reus=("@"+rusername or "None"),ReID=us,Rerank=t,Remsgs=msgs,Reedits=edits,Rage=age,Rerate=str(rate)+"%"),"reply_to_message_id":message.message_id,"parse_mode":"html"})
      except Exception as e:
        print(e)

    if re.search(c.ShowSudos, text):
      tx = (redis.get("{}Nbot:SHOWsudos".format(BOT_ID)) or "")
      Bot("sendMessage",{"chat_id":chatID,"text":tx,"reply_to_message_id":message.message_id,"parse_mode":"html"})
    if text == c.mymsgs:
      get = redis.hget("{}Nbot:{}:msgs".format(BOT_ID,chatID),userID)
      Bot("sendMessage",{"chat_id":chatID,"text":r.yourmsgs.format((get or 0)),"reply_to_message_id":message.message_id,"parse_mode":"html"})
    if text == c.link:
      get = (redis.hget("{}Nbot:links".format(BOT_ID),chatID) or GetLink(chatID) or "none")
      Bot("sendMessage",{"chat_id":chatID,"text":r.showGPlk.format(get),"reply_to_message_id":message.message_id,"parse_mode":"html","disable_web_page_preview":True})

    if text == c.myedits:
      get = redis.hget("{}Nbot:{}:edits".format(BOT_ID,chatID),userID)
      Bot("sendMessage",{"chat_id":chatID,"text":r.youredits.format((get or 0)),"reply_to_message_id":message.message_id,"parse_mode":"html"})

    if text == c.myaddcontact:
      get = redis.hget("{}Nbot:{}:addcontact".format(BOT_ID,chatID),userID)
      Bot("sendMessage",{"chat_id":chatID,"text":r.youraddcontact.format((get or 0)),"reply_to_message_id":message.message_id,"parse_mode":"html"})
    
    
    if not redis.sismember("{}Nbot:ReplySendBOT".format(BOT_ID),chatID):
      if redis.hexists("{}Nbot:TXreplys".format(BOT_ID),text):
        tx = redis.hget("{}Nbot:TXreplys".format(BOT_ID),text)
        try:
          Bot("sendMessage",{"chat_id":chatID,"text":tx.format(fn=Name(userFN),us=("@"+username or "n"),id=userID,rk=IDrank(redis,userID,chatID,r),cn=title),"reply_to_message_id":message.message_id,"parse_mode":"html"})
        except Exception as e:
          Bot("sendMessage",{"chat_id":chatID,"text":tx,"reply_to_message_id":message.message_id,"parse_mode":"html"})
          
      if redis.hexists("{}Nbot:STreplys".format(BOT_ID),text):
        ID = redis.hget("{}Nbot:STreplys".format(BOT_ID),text)
        Bot("sendSticker",{"chat_id":chatID,"sticker":ID,"reply_to_message_id":message.message_id})
      
      if redis.hexists("{}Nbot:GFreplys".format(BOT_ID),text):
        ID = redis.hget("{}Nbot:GFreplys".format(BOT_ID),text)
        Bot("sendanimation",{"chat_id":chatID,"animation":ID,"reply_to_message_id":message.message_id})

      if redis.hexists("{}Nbot:{}:VOreplys".format(BOT_ID,chatID),text):
        ID = redis.hget("{}Nbot:VOreplys".format(BOT_ID),text)
        Bot("sendvoice",{"chat_id":chatID,"voice":ID,"reply_to_message_id":message.message_id})

      if redis.hexists("{}Nbot:PHreplys".format(BOT_ID,chatID),text):
        ID = redis.hget("{}Nbot:PHreplys".format(BOT_ID),text)
        Bot("sendphoto",{"chat_id":chatID,"photo":ID,"reply_to_message_id":message.message_id})

      if redis.hexists("{}Nbot:DOreplys".format(BOT_ID,chatID),text):
        ID = redis.hget("{}Nbot:DOreplys".format(BOT_ID),text)
        Bot("sendDocument",{"chat_id":chatID,"document":ID,"reply_to_message_id":message.message_id})



    if not redis.sismember("{}Nbot:ReplySend".format(BOT_ID),chatID):
      if redis.hexists("{}Nbot:{}:TXreplys".format(BOT_ID,chatID),text):
        tx = redis.hget("{}Nbot:{}:TXreplys".format(BOT_ID,chatID),text)
        try:
          Bot("sendMessage",{"chat_id":chatID,"text":tx.format(fn=Name(userFN),us=("@"+username or "n"),id=userID,rk=IDrank(redis,userID,chatID,r),cn=title),"reply_to_message_id":message.message_id,"parse_mode":"html"})
        except Exception as e:
          Bot("sendMessage",{"chat_id":chatID,"text":tx,"reply_to_message_id":message.message_id,"parse_mode":"html"})

      if redis.hexists("{}Nbot:{}:STreplys".format(BOT_ID,chatID),text):
        ID = redis.hget("{}Nbot:{}:STreplys".format(BOT_ID,chatID),text)
        Bot("sendSticker",{"chat_id":chatID,"sticker":ID,"reply_to_message_id":message.message_id})
      
      if redis.hexists("{}Nbot:{}:GFreplys".format(BOT_ID,chatID),text):
        ID = redis.hget("{}Nbot:{}:GFreplys".format(BOT_ID,chatID),text)
        Bot("sendanimation",{"chat_id":chatID,"animation":ID,"reply_to_message_id":message.message_id})

      if redis.hexists("{}Nbot:{}:VOreplys".format(BOT_ID,chatID),text):
        ID = redis.hget("{}Nbot:{}:VOreplys".format(BOT_ID,chatID),text)
        Bot("sendvoice",{"chat_id":chatID,"voice":ID,"reply_to_message_id":message.message_id})
 
      if redis.hexists("{}Nbot:{}:PHreplys".format(BOT_ID,chatID),text):
        ID = redis.hget("{}Nbot:{}:PHreplys".format(BOT_ID,chatID),text)
        Bot("sendphoto",{"chat_id":chatID,"photo":ID,"reply_to_message_id":message.message_id})

      if redis.hexists("{}Nbot:{}:DOreplys".format(BOT_ID,chatID),text):
        ID = redis.hget("{}Nbot:{}:DOreplys".format(BOT_ID,chatID),text)
        Bot("sendDocument",{"chat_id":chatID,"document":ID,"reply_to_message_id":message.message_id})

  if redis.smembers("{}Nbot:botfiles".format(BOT_ID)):
    onlyfiles = [f for f in listdir("files") if isfile(join("files", f))]
    filesR = redis.smembers("{}Nbot:botfiles".format(BOT_ID))
    for f in onlyfiles:
      if f in filesR:
        fi = f.replace(".py","")
        UpMs= "files."+fi
        try:
          U = importlib.import_module(UpMs)
          t = threading.Thread(target=U.updateMsgs,args=(client, message,redis))
          t.daemon = True
          t.start()
          importlib.reload(U)
        except Exception as e:
          pass
示例#12
0
def updateHandlers(client, message, redis):
    if redis.get("{}Nbot:bigM".format(BOT_ID)):
        return False
    type = message.chat.type
    try:
        userID = message.from_user.id
        chatID = message.chat.id
    except Exception as e:
        return 0
    c = importlib.import_module("lang.arcmd")
    r = importlib.import_module("lang.arreply")

    if (type is "supergroup" or type is "group") and message.outgoing != True:
        userID = message.from_user.id
        chatID = message.chat.id
        rank = isrank(redis, userID, chatID)
        group = redis.sismember("{}Nbot:groups".format(BOT_ID), chatID)
        text = message.text
        title = message.chat.title
        if text and group is False:
            if (rank is "sudo" or rank is "sudos" or rank is "asudo") or (
                    redis.get("{}Nbot:autoaddbot".format(BOT_ID))
                    and GPranks(userID, chatID) == "creator"):
                if text == c.add:
                    if redis.get("{}Nbot:autoaddbotN".format(BOT_ID)):
                        auN = int(
                            redis.get("{}Nbot:autoaddbotN".format(BOT_ID)))
                    else:
                        auN = 1
                    if auN >= Bot("getChatMembersCount", {
                            "chat_id": chatID
                    })["result"] and not (rank is "sudo" or rank is "sudos"):
                        Bot(
                            "sendMessage", {
                                "chat_id":
                                chatID,
                                "text":
                                r.Toolow.format((int(
                                    redis.get(
                                        "{}Nbot:autoaddbotN".format(BOT_ID)))
                                                 or 0)),
                                "reply_to_message_id":
                                message.message_id,
                                "parse_mode":
                                "html"
                            })
                        return False
                    GetME = Bot("getChatMember", {
                        "chat_id": chatID,
                        "user_id": BOT_ID
                    })["result"]
                    if (not GetME["can_change_info"]
                            or not GetME["can_delete_messages"]
                            or not GetME["can_invite_users"]
                            or not GetME["can_restrict_members"]
                            or not GetME["can_pin_messages"]
                            or not GetME["can_promote_members"]):
                        Bot(
                            "sendMessage", {
                                "chat_id": chatID,
                                "text": r.GiveMEall,
                                "reply_to_message_id": message.message_id,
                                "parse_mode": "html"
                            })
                        return False

                if text == c.add and not redis.sismember(
                        "{}Nbot:disabledgroups".format(BOT_ID),
                        chatID) and Ckuser(message):
                    locksarray = {
                        'Llink', 'Llongtext', 'Lmarkdown', 'Linline', 'Lfiles',
                        'Lcontact', 'Lbots', 'Lfwd', 'Lnote'
                    }
                    for lock in locksarray:
                        redis.sadd("{}Nbot:{}".format(BOT_ID, lock), chatID)
                    ads = Bot("getChatAdministrators", {"chat_id": chatID})
                    for ad in ads['result']:
                        userId = ad["user"]["id"]
                        userFn = ad["user"]["first_name"]
                        if ad['status'] == "administrator" and int(
                                userId) != int(BOT_ID):
                            setrank(redis, "admin", userId, chatID, "array")
                        if ad['status'] == "creator":
                            setrank(redis, "malk", userId, chatID, "one")
                    add = redis.sadd("{}Nbot:groups".format(BOT_ID), chatID)
                    Bot("exportChatInviteLink", {"chat_id": chatID})
                    kb = InlineKeyboardMarkup([[
                        InlineKeyboardButton(r.MoreInfo,
                                             url="t.me/Source_Luffy")
                    ]])
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.doneadd.format(title),
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "markdown",
                            "reply_markup": kb
                        })
                    sendTO = (redis.get("{}Nbot:sudogp".format(BOT_ID))
                              or SUDO)
                    get = (redis.hget("{}Nbot:links".format(BOT_ID), chatID)
                           or GetLink(chatID) or "t.me/Source_Luffy")
                    kb = InlineKeyboardMarkup(
                        [[InlineKeyboardButton("الرابط 🖇", url=get)]])
                    BY = "<a href=\"tg://user?id={}\">{}</a>".format(
                        userID, message.from_user.first_name)
                    Bot(
                        "sendMessage", {
                            "chat_id": sendTO,
                            "text":
                            f"تم تفعيل مجموعه جديدة ℹ️\nاسم المجموعه : {title}\nايدي المجموعه : {chatID}\nالمنشئ : {BY}\n⎯ ⎯ ⎯ ⎯",
                            "parse_mode": "html",
                            "reply_markup": kb
                        })
                elif text == c.add and redis.sismember(
                        "{}Nbot:disabledgroups".format(BOT_ID),
                        chatID) and Ckuser(message):
                    redis.sadd("{}Nbot:groups".format(BOT_ID), chatID)
                    redis.srem("{}Nbot:disabledgroups".format(BOT_ID), chatID)
                    redis.hdel("{}Nbot:disabledgroupsTIME".format(BOT_ID),
                               chatID)

                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.doneadd2.format(title),
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "markdown"
                        })
                if text == c.disabl and Ckuser(message):
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.disabled.format(title),
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "markdown"
                        })

        if text and group is True:
            if (rank is "sudo" or rank is "sudos" or rank is "asudo") or (
                    redis.get("{}Nbot:autoaddbot".format(BOT_ID))
                    and GPranks(userID, chatID) == "creator"):
                if text == c.add and Ckuser(message):
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.doneadded.format(title),
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "markdown"
                        })
                if text == c.disabl and Ckuser(message):
                    redis.srem("{}Nbot:groups".format(BOT_ID), chatID)
                    redis.sadd("{}Nbot:disabledgroups".format(BOT_ID), chatID)
                    NextDay_Date = datetime.datetime.today(
                    ) + datetime.timedelta(days=1)
                    redis.hset("{}Nbot:disabledgroupsTIME".format(BOT_ID),
                               chatID, str(NextDay_Date))
                    kb = InlineKeyboardMarkup([[
                        InlineKeyboardButton(r.MoreInfo,
                                             url="t.me/Source_Luffy")
                    ]])
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.disabl.format(title),
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "markdown",
                            "reply_markup": kb
                        })
        if group is True:
            t = threading.Thread(target=allGP, args=(client, message, redis))
            t.daemon = True
            t.start()

        if text and group is True:
            x = redis.smembers("{}Nbot:{}:TXoeders".format(BOT_ID, chatID))
            for x in x:
                try:
                    x = x.split("=")
                    if re.search(f"^\{x[0]}$", text) or re.search(
                            f"^\{x[0]} (.*)$", text):
                        text = text.replace(x[0], x[1])
                except Exception as e:
                    print(e)
            message.text = text
        if (rank is "sudo" or rank is "sudos"
                or rank is "asudo") and group is True:
            t = threading.Thread(target=sudo, args=(client, message, redis))
            t.daemon = True
            t.start()

        if text and (rank is "sudo" or rank is "asudo" or rank is "sudos" or
                     rank is "malk" or rank is "acreator" or rank is "creator"
                     or rank is "owner") and group is True:
            t = threading.Thread(target=ranks, args=(client, message, redis))
            t.daemon = True
            t.start()
        if text and (rank is "sudo" or rank is "asudo" or rank is "sudos"
                     or rank is "malk" or rank is "acreator"
                     or rank is "creator" or rank is "owner"
                     or rank is "admin") and group is True and re.search(
                         c.startlock, text):
            if Ckuser(message):
                t = threading.Thread(target=locks,
                                     args=(client, message, redis))
                t.daemon = True
                t.start()
        if (rank is False or rank is 0) and group is True:
            t = threading.Thread(target=delete, args=(client, message, redis))
            t.daemon = True
            t.start()

        if (rank is "sudo" or rank is "asudo" or rank is "sudos"
                or rank is "malk" or rank is "acreator" or rank is "creator"
                or rank is "owner" or rank is "admin") and group is True:
            t = threading.Thread(target=gpcmd, args=(client, message, redis))
            t.daemon = True
            t.start()

    if type is "private" and message.outgoing != True:
        text = message.text
        rank = isrank(redis, userID, chatID)
        if (rank is "sudo" or rank is "asudo" or rank is "sudos"):
            t = threading.Thread(target=sudo, args=(client, message, redis))
            t.daemon = True
            t.start()
        if text and re.search("^/start$", text):
            userID = message.from_user.id
            userFN = message.from_user.first_name
            redis.sadd("{}Nbot:privates".format(BOT_ID), userID)
            if rank == "sudo":
                kb = ReplyKeyboardMarkup(
                    [[r.RKgp, r.RKgpl], [r.RKaf, r.RKrf], [r.RKf],
                     ["جلب نسخه احتياطيه"], [r.RKub]],
                    resize_keyboard=True)
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.sudostart,
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "reply_markup": kb
                    })
                return 0
            getbot = client.get_me()
            kb = InlineKeyboardMarkup([[
                InlineKeyboardButton("Source Luffy", url="t.me/Source_Luffy")
            ]])
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": r.botstart.format(getbot.first_name,
                                              getbot.username),
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html",
                    "reply_markup": kb
                })

        if text and re.search("^/start (.*)$", text):
            tx = text.replace("/start ", "")
            split = tx.split("=")
            order = split[0]
            if order == "showreplylistBOT":
                chatId = split[1]
                userId = split[2]
                TY = split[3]
                rank = isrank(redis, userId, chatId)
                if (rank == "sudo" or rank is "asudo" or rank == "sudos"):
                    li = redis.hkeys("{}Nbot:{}".format(BOT_ID, TY))
                    if li:
                        i = 1
                        words = ""
                        for word in li:
                            words = words + "\n" + str(i) + " - {" + word + "}"
                            i += 1
                            if len(words) > 3000:
                                Bot(
                                    "sendMessage", {
                                        "chat_id": userId,
                                        "text": words,
                                        "reply_to_message_id":
                                        message.message_id,
                                        "parse_mode": "html"
                                    })
                                words = ''
                        Bot(
                            "sendMessage", {
                                "chat_id": userId,
                                "text": words,
                                "reply_to_message_id": message.message_id,
                                "parse_mode": "html"
                            })
                        reply_markup = InlineKeyboardMarkup([[
                            InlineKeyboardButton(
                                r.Delall2R,
                                callback_data=json.dumps(
                                    ["del{}".format(TY + 'BOT'), "", userID])),
                        ]])
                        Bot(
                            "sendMessage", {
                                "chat_id": chatID,
                                "text": r.DelallR,
                                "reply_to_message_id": message.message_id,
                                "disable_web_page_preview": True,
                                "reply_markup": reply_markup
                            })

            if order == "showreplylist":
                chatId = split[1]
                userId = split[2]
                TY = split[3]
                group = redis.sismember("{}Nbot:groups".format(BOT_ID), chatId)
                rank = isrank(redis, userId, chatId)
                if (rank is not False or rank is not 0 or rank != "vip"
                        or rank != "admin") and group is True:
                    li = redis.hkeys("{}Nbot:{}:{}".format(BOT_ID, chatId, TY))
                    if li:
                        i = 1
                        words = ""
                        for word in li:
                            words = words + "\n" + str(i) + " - {" + word + "}"
                            i += 1
                            if len(words) > 3000:
                                Bot(
                                    "sendMessage", {
                                        "chat_id": userId,
                                        "text": words,
                                        "reply_to_message_id":
                                        message.message_id,
                                        "parse_mode": "html"
                                    })
                                words = ''
                        Bot(
                            "sendMessage", {
                                "chat_id": userId,
                                "text": words,
                                "reply_to_message_id": message.message_id,
                                "parse_mode": "html"
                            })
                        reply_markup = InlineKeyboardMarkup([[
                            InlineKeyboardButton(r.Delall2R,
                                                 callback_data=json.dumps([
                                                     "del{}".format(TY),
                                                     chatId, userID
                                                 ])),
                        ]])
                        Bot(
                            "sendMessage", {
                                "chat_id": chatID,
                                "text": r.DelallR,
                                "reply_to_message_id": message.message_id,
                                "disable_web_page_preview": True,
                                "reply_markup": reply_markup
                            })

            if order == "showBlocklist":
                chatId = split[1]
                userId = split[2]
                TY = split[3]
                group = redis.sismember("{}Nbot:groups".format(BOT_ID), chatId)
                rank = isrank(redis, userId, chatId)
                if (rank is not False or rank is not 0
                        or rank != "vip") and group is True:
                    redis.hset("{}Nbot:{}:TXreplys".format(BOT_ID, chatID), tx,
                               text)
                    li = redis.smembers("{}Nbot:{}:{}".format(
                        BOT_ID, chatId, TY))
                    if li:
                        i = 1
                        words = ""
                        for ID in li:
                            reply_markup = InlineKeyboardMarkup([[
                                InlineKeyboardButton(r.Blocklistone,
                                                     callback_data=json.dumps([
                                                         "delfromb", TY,
                                                         userID, chatId
                                                     ])),
                            ]])
                            if TY == "blockanimations":
                                Bot(
                                    "sendAnimation", {
                                        "chat_id": userId,
                                        "animation": ID,
                                        "reply_markup": reply_markup
                                    })
                            if TY == "blockSTICKERs":
                                Bot(
                                    "sendSticker", {
                                        "chat_id": userId,
                                        "sticker": ID,
                                        "reply_markup": reply_markup
                                    })
                            if TY == "blockphotos":
                                Bot(
                                    "sendPhoto", {
                                        "chat_id": userId,
                                        "photo": ID,
                                        "reply_markup": reply_markup
                                    })
                            if TY == "blockTEXTs":
                                words = words + "\n" + str(
                                    i) + " - {" + ID + "}"
                                i += 1
                                print(len(words))
                                if len(words) > 3000:
                                    Bot(
                                        "sendMessage", {
                                            "chat_id": userId,
                                            "text": words,
                                            "reply_to_message_id":
                                            message.message_id,
                                            "parse_mode": "html"
                                        })
                                    words = ''
                        if TY == "blockTEXTs":

                            Bot(
                                "sendMessage", {
                                    "chat_id": userId,
                                    "text": words,
                                    "reply_to_message_id": message.message_id,
                                    "parse_mode": "html"
                                })

                        reply_markup = InlineKeyboardMarkup([[
                            InlineKeyboardButton(r.Delall2,
                                                 callback_data=json.dumps([
                                                     "delBL", TY, userID,
                                                     chatId
                                                 ])),
                        ]])
                        Bot(
                            "sendMessage", {
                                "chat_id": userId,
                                "text": r.Delall,
                                "reply_to_message_id": message.message_id,
                                "parse_mode": "html",
                                "reply_markup": reply_markup
                            })
                    else:
                        Bot(
                            "sendMessage", {
                                "chat_id": userId,
                                "text": r.listempty2,
                                "reply_to_message_id": message.message_id,
                                "parse_mode": "html"
                            })
示例#13
0
def ranks(client, message, redis):
    type = message.chat.type
    userID = message.from_user.id
    chatID = message.chat.id
    rank = isrank(redis, userID, chatID)
    text = message.text
    c = importlib.import_module("lang.arcmd")
    r = importlib.import_module("lang.arreply")

    if (rank is "sudo" or rank is "asudo" or rank is "sudos"
            or rank is "malk"):
        if re.search("^ترتيب الاوامر$", text):
            ar = {
                "ا": "ايدي",
                "م": "رفع مميز",
                "اد": "رفع ادمن",
                "مد": "رفع مدير",
                "من": "رفع منشى",
                "اس": "رفع منشى اساسي",
                "تعط": "تعطيل الايدي بالصورة",
                "تفع": "تفعيل الايدي بالصورة",
            }
            i = 1
            orders = ""
            for tx, text in ar.items():
                ad = f"{tx}={text}"
                if not redis.sismember(
                        "{}Nbot:{}:TXoeders".format(BOT_ID, chatID), ad):
                    redis.sadd("{}Nbot:{}:TXoeders".format(BOT_ID, chatID), ad)
                orders += f"{i} - {text} > {tx}\n"
                i += 1
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text":
                    f"✅꒐ تم اضافه الاوامر الاتيه \n⎯ ⎯ ⎯ ⎯\n{orders}\n⎯ ⎯ ⎯ ⎯",
                    "reply_to_message_id": message.message_id,
                    "disable_web_page_preview": True
                })

        if re.search(c.del_ac, text) and Ckuser(message):
            H = "acreator"
            redis.delete("{}Nbot:{}:{}".format(BOT_ID, chatID, H))
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": r.DoneDelList,
                    "reply_to_message_id": message.message_id,
                    "disable_web_page_preview": True
                })

        if re.search(c.acreators, text) and Ckuser(message):
            arrays = redis.smembers("{}Nbot:{}:acreator".format(
                BOT_ID, chatID))
            if arrays:
                b = BYusers(arrays, chatID, redis, client)
                kb = InlineKeyboardMarkup([[
                    InlineKeyboardButton(r.delList.format(text),
                                         callback_data=json.dumps(
                                             ["delList", "acreator", userID]))
                ]])
                if b is not "":
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.showlist.format(text, b),
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "markdown",
                            "reply_markup": kb
                        })
                else:
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.listempty.format(text),
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "markdown"
                        })
            else:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.listempty.format(text),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "markdown"
                    })

        if re.search(c.setacreator, text) and Ckuser(message):
            if re.search("@", text):
                user = text.split("@")[1]
            if re.search(c.setacreator2, text):
                user = text.split(" ")[2]
            if message.reply_to_message:
                user = message.reply_to_message.from_user.id
            if 'user' not in locals(): return False
            try:
                getUser = client.get_users(user)
                userId = getUser.id
                userFn = getUser.first_name
                setcr = setrank(redis, "acreator", userId, chatID, "array")
                if setcr is "acreator":
                    send_msg("UD", client, message, r.DsetRK, "", getUser,
                             redis)
                elif (setcr is True or setcr is 1):
                    send_msg("UD", client, message, r.setRK, "", getUser,
                             redis)
            except Exception as e:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.userNocc,
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html"
                    })

        if re.search(c.remacreator, text) and Ckuser(message):
            if re.search("@", text):
                user = text.split("@")[1]
            if re.search(c.remacreator2, text):
                user = text.split(" ")[2]
            if message.reply_to_message:
                user = message.reply_to_message.from_user.id
            if 'user' not in locals(): return False
            try:
                getUser = client.get_users(user)
                userId = getUser.id
                userFn = getUser.first_name
                setcr = remrank(redis, "acreator", userId, chatID, "array")
                if setcr:
                    send_msg("UD", client, message, r.remRK, "", getUser,
                             redis)
                elif not setcr:
                    send_msg("UD", client, message, r.DremRK, "", getUser,
                             redis)
            except Exception as e:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.userNocc,
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html"
                    })

    if (rank is "sudo" or rank is "asudo" or rank is "sudos" or rank is "malk"
            or rank is "acreator"):
        if re.search(c.del_cr, text) and Ckuser(message):
            H = "creator"
            redis.delete("{}Nbot:{}:{}".format(BOT_ID, chatID, H))
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": r.DoneDelList,
                    "reply_to_message_id": message.message_id,
                    "disable_web_page_preview": True
                })

        if re.search(c.creators, text) and Ckuser(message):
            arrays = redis.smembers("{}Nbot:{}:creator".format(BOT_ID, chatID))
            if arrays:
                b = BYusers(arrays, chatID, redis, client)
                kb = InlineKeyboardMarkup([[
                    InlineKeyboardButton(r.delList.format(text),
                                         callback_data=json.dumps(
                                             ["delList", "creator", userID]))
                ]])
                if b is not "":
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.showlist.format(text, b),
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "markdown",
                            "reply_markup": kb
                        })
                else:
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.listempty.format(text),
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "markdown"
                        })
            else:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.listempty.format(text),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "markdown"
                    })

        if re.search(c.setcreator, text) and Ckuser(message):
            if re.search("@", text):
                user = text.split("@")[1]
            if re.search(c.setcreator2, text):
                user = text.split(" ")[2]
            if message.reply_to_message:
                user = message.reply_to_message.from_user.id
            if 'user' not in locals(): return False
            try:
                getUser = client.get_users(user)
                userId = getUser.id
                userFn = getUser.first_name
                setcr = setrank(redis, "creator", userId, chatID, "array")
                if setcr is "creator":
                    send_msg("UD", client, message, r.DsetRK, "", getUser,
                             redis)
                elif (setcr is True or setcr is 1):
                    send_msg("UD", client, message, r.setRK, "", getUser,
                             redis)
            except Exception as e:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.userNocc,
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html"
                    })

        if re.search(c.remcreator, text) and Ckuser(message):
            if re.search("@", text):
                user = text.split("@")[1]
            if re.search(c.remcreator2, text):
                user = text.split(" ")[2]
            if message.reply_to_message:
                user = message.reply_to_message.from_user.id
            if 'user' not in locals(): return False
            try:
                getUser = client.get_users(user)
                userId = getUser.id
                userFn = getUser.first_name
                setcr = remrank(redis, "creator", userId, chatID, "array")
                if setcr:
                    send_msg("UD", client, message, r.remRK, "", getUser,
                             redis)
                elif not setcr:
                    send_msg("UD", client, message, r.DremRK, "", getUser,
                             redis)
            except Exception as e:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.userNocc,
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html"
                    })

    if (rank is "sudo" or rank is "asudo" or rank is "sudos" or rank is "malk"
            or rank is "acreator" or rank is "creator" or rank is "owner"):

        if re.search(c.del_ad, text) and Ckuser(message):
            H = "admin"
            redis.delete("{}Nbot:{}:{}".format(BOT_ID, chatID, H))
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": r.DoneDelList,
                    "reply_to_message_id": message.message_id,
                    "disable_web_page_preview": True
                })
        if re.search(c.del_vp, text) and Ckuser(message):
            H = "vip"
            redis.delete("{}Nbot:{}:{}".format(BOT_ID, chatID, H))
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": r.DoneDelList,
                    "reply_to_message_id": message.message_id,
                    "disable_web_page_preview": True
                })

        if re.search(c.admins, text) and Ckuser(message):
            arrays = redis.smembers("{}Nbot:{}:admin".format(BOT_ID, chatID))
            b = BYusers(arrays, chatID, redis, client)
            kb = InlineKeyboardMarkup([[
                InlineKeyboardButton(r.delList.format(text),
                                     callback_data=json.dumps(
                                         ["delList", "admin", userID]))
            ]])
            if b is not "":
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.showlist.format(text, b),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "markdown",
                        "reply_markup": kb
                    })
            else:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.listempty.format(text),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "markdown"
                    })

        if re.search(c.vips, text) and Ckuser(message):

            arrays = redis.smembers("{}Nbot:{}:vip".format(BOT_ID, chatID))
            b = BYusers(arrays, chatID, redis, client)
            kb = InlineKeyboardMarkup([[
                InlineKeyboardButton(r.delList.format(text),
                                     callback_data=json.dumps(
                                         ["delList", "vip", userID]))
            ]])
            if b is not "":
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.showlist.format(text, b),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "markdown",
                        "reply_markup": kb
                    })
            else:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.listempty.format(text),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "markdown"
                    })

        orad = redis.hget("{}Nbot:adminor:cb".format(BOT_ID),
                          chatID) or c.setadmin
        orad2 = redis.hget("{}Nbot:adminor:cb2".format(BOT_ID),
                           chatID) or c.setadmin2
        if re.search(c.setadmin + "|" + orad, text) and Ckuser(message):
            if re.search("@", text):
                user = text.split("@")[1]
            if re.search(c.setadmin2 + "|" + orad2, text):
                user = int(re.search(r'\d+', text).group())
            if message.reply_to_message:
                user = message.reply_to_message.from_user.id
            if 'user' not in locals(): return False
            message.text = c.orad
            try:
                getUser = client.get_users(user)
                userId = getUser.id
                userFn = getUser.first_name
                setcr = setrank(redis, "admin", userId, chatID, "array")
                if setcr is "admin":
                    send_msg("UD", client, message, r.DsetRK, "", getUser,
                             redis)
                elif (setcr is True or setcr is 1):
                    send_msg("UD", client, message, r.setRK, "", getUser,
                             redis)
            except Exception as e:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.userNocc,
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html"
                    })

        if re.search(c.remadmin, text) and Ckuser(message):
            if re.search("@", text):
                user = text.split("@")[1]
            if re.search(c.remadmin2, text):
                user = text.split(" ")[2]
            if message.reply_to_message:
                user = message.reply_to_message.from_user.id
            if 'user' not in locals(): return False
            try:
                getUser = client.get_users(user)
                userId = getUser.id
                userFn = getUser.first_name
                setcr = remrank(redis, "admin", userId, chatID, "array")
                if setcr:
                    send_msg("UD", client, message, r.remRK, "", getUser,
                             redis)
                elif not setcr:
                    send_msg("UD", client, message, r.DremRK, "", getUser,
                             redis)
            except Exception as e:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.userNocc,
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html"
                    })

        orvip = redis.hget("{}Nbot:vipor:cb".format(BOT_ID),
                           chatID) or c.setvip
        orvip2 = redis.hget("{}Nbot:vipor:cb2".format(BOT_ID),
                            chatID) or c.setvip2
        if re.search(c.setvip + "|" + orvip, text) and Ckuser(message):
            if re.search("@", text):
                user = text.split("@")[1]
            if re.search(c.setvip2 + "|" + orvip2, text):
                user = int(re.search(r'\d+', text).group())
            if message.reply_to_message:
                user = message.reply_to_message.from_user.id
            if 'user' not in locals(): return False
            message.text = c.orvip
            try:
                getUser = client.get_users(user)
                userId = getUser.id
                userFn = getUser.first_name
                setcr = setrank(redis, "vip", userId, chatID, "array")
                if setcr is "vip":
                    send_msg("UD", client, message, r.DsetRK, "", getUser,
                             redis)
                elif (setcr is True or setcr is 1):
                    send_msg("UD", client, message, r.setRK, "", getUser,
                             redis)
            except Exception as e:
                import traceback
                traceback.print_exc()
                print(e)
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.userNocc,
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html"
                    })

        if re.search(c.remvip, text) and Ckuser(message):
            if re.search("@", text):
                user = text.split("@")[1]
            if re.search(c.remvip2, text):
                user = text.split(" ")[2]
            if message.reply_to_message:
                user = message.reply_to_message.from_user.id
            if 'user' not in locals(): return False
            try:
                getUser = client.get_users(user)
                userId = getUser.id
                userFn = getUser.first_name
                setcr = remrank(redis, "vip", userId, chatID, "array")
                if setcr:
                    send_msg("UD", client, message, r.remRK, "", getUser,
                             redis)
                elif not setcr:
                    send_msg("UD", client, message, r.DremRK, "", getUser,
                             redis)
            except Exception as e:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.userNocc,
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html"
                    })

    if (rank is "sudo" or rank is "sudos" or rank is "asudo" or rank is "malk"
            or rank is "acreator" or rank is "creator"):
        if re.search(c.del_ow, text) and Ckuser(message):
            H = "owner"
            redis.delete("{}Nbot:{}:{}".format(BOT_ID, chatID, H))
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": r.DoneDelList,
                    "reply_to_message_id": message.message_id,
                    "disable_web_page_preview": True
                })

        if re.search(c.owners, text) and Ckuser(message):
            arrays = redis.smembers("{}Nbot:{}:owner".format(BOT_ID, chatID))
            b = BYusers(arrays, chatID, redis, client)
            kb = InlineKeyboardMarkup([[
                InlineKeyboardButton(r.delList.format(text),
                                     callback_data=json.dumps(
                                         ["delList", "owner", userID]))
            ]])
            if b is not "":
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.showlist.format(text, b),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "markdown",
                        "reply_markup": kb
                    })
            else:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.listempty.format(text),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "markdown"
                    })

        orow = redis.hget("{}Nbot:owneror:cb".format(BOT_ID),
                          chatID) or c.setowner
        orow2 = redis.hget("{}Nbot:owneror:cb2".format(BOT_ID),
                           chatID) or c.setowner2
        if re.search(c.setowner + "|" + orow, text) and Ckuser(message):
            if re.search("@", text):
                user = text.split("@")[1]
            if re.search(c.setowner2 + "|" + orow2, text):
                user = int(re.search(r'\d+', text).group())
            if message.reply_to_message:
                user = message.reply_to_message.from_user.id
            if 'user' not in locals(): return False
            message.text = c.orow
            try:
                getUser = client.get_users(user)
                userId = getUser.id
                userFn = getUser.first_name
                setcr = setrank(redis, "owner", userId, chatID, "array")
                if setcr is "owner":
                    send_msg("UD", client, message, r.DsetRK, "", getUser,
                             redis)
                elif (setcr is True or setcr is 1):
                    send_msg("UD", client, message, r.setRK, "", getUser,
                             redis)
            except Exception as e:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.userNocc,
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html"
                    })

        if re.search(c.remowner, text) and Ckuser(message):
            if re.search("@", text):
                user = text.split("@")[1]
            if re.search(c.remowner2, text):
                user = text.split(" ")[2]
            if message.reply_to_message:
                user = message.reply_to_message.from_user.id
            if 'user' not in locals(): return False
            try:
                getUser = client.get_users(user)
                userId = getUser.id
                userFn = getUser.first_name
                setcr = remrank(redis, "owner", userId, chatID, "array")
                if setcr:
                    send_msg("UD", client, message, r.remRK, "", getUser,
                             redis)
                elif not setcr:
                    send_msg("UD", client, message, r.DremRK, "", getUser,
                             redis)
            except Exception as e:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.userNocc,
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html"
                    })
示例#14
0
def updateCallback(client, callback_query,redis):
  try:
    json.loads(callback_query.data)
  except Exception as e:
    if redis.smembers("{}Nbot:botfiles".format(BOT_ID)):
      onlyfiles = [f for f in listdir("files") if isfile(join("files", f))]
      filesR = redis.smembers("{}Nbot:botfiles".format(BOT_ID))
      for f in onlyfiles:
        if f in filesR:
          fi = f.replace(".py","")
          UpMs= "files."+fi
          try:
            U = importlib.import_module(UpMs)
            t = threading.Thread(target=U.updateCb,args=(client, callback_query,redis))
            t.setDaemon(True)
            t.start()
            importlib.reload(U)
          except Exception as e:
            pass
      return False
    
    
  if callback_query.inline_message_id:
    if redis.smembers("{}Nbot:botfiles".format(BOT_ID)):
      onlyfiles = [f for f in listdir("files") if isfile(join("files", f))]
      filesR = redis.smembers("{}Nbot:botfiles".format(BOT_ID))
      for f in onlyfiles:
        if f in filesR:
          fi = f.replace(".py","")
          UpMs= "files."+fi
          try:
            U = importlib.import_module(UpMs)
            t = threading.Thread(target=U.updateCb,args=(client, callback_query,redis))
            t.setDaemon(True)
            t.start()
            importlib.reload(U)
          except Exception as e:
            pass
    return False
    
  userID = callback_query.from_user.id
  
  chatID = callback_query.message.chat.id
  userFN = callback_query.from_user.first_name
  title = callback_query.message.chat.title
  message_id = callback_query.message.message_id
  date = json.loads(callback_query.data)
  
  group = redis.sismember("{}Nbot:groups".format(BOT_ID),chatID)
  lang = Glang(redis,chatID)
  moduleCMD = "lang."+lang+"-cmd"
  moduleREPLY = "lang."+lang+"-reply"
  c = importlib.import_module(moduleCMD)
  r = importlib.import_module(moduleREPLY)
  

  if date[0] == "Cordertow":
    rank = isrank(redis,userID,chatID)
    if (rank is "sudo" or rank is "sudos" or rank is "creator" or rank is "owner"):
      if redis.sismember("{}Nbot:{}:bans".format(BOT_ID,chatID),date[1]):
        GetGprank = GPranks(date[1],chatID)
        if GetGprank == "kicked":
          Bot("unbanChatMember",{"chat_id":chatID,"user_id":date[1]})
        redis.srem("{}Nbot:{}:bans".format(BOT_ID,chatID),date[1])
        Bot("editMessageText",{"chat_id":chatID,"text":r.doneCO,"message_id":message_id,"disable_web_page_preview":True})
      else:
        Bot("editMessageText",{"chat_id":chatID,"text":r.ARdoneCO,"message_id":message_id,"disable_web_page_preview":True})
    return False
  if date[0] == "delBL":
    Hash = date[1]
    chat = date[3]
    if redis.sismember("{}Nbot:groups".format(BOT_ID),chat):
      redis.delete("{}Nbot:{}:{}".format(BOT_ID,chat,Hash))
      Bot("editMessageText",{"chat_id":chatID,"text":r.DoneDelList,"message_id":message_id,"disable_web_page_preview":True})
  if re.search("del(.*)replys$",date[0]):
    t = date[0].replace("del","")
    if date[1] != "kb":
      redis.delete("{}Nbot:{}:{}".format(BOT_ID,date[1],t))
      Bot("editMessageText",{"chat_id":chatID,"text":r.DoneDelList,"message_id":message_id,"disable_web_page_preview":True})
    else:
      reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("<<",callback_data=json.dumps(["replylist","",userID])),]])
      redis.delete("{}Nbot:{}:{}".format(BOT_ID,chatID,t))
      Bot("editMessageText",{"chat_id":chatID,"text":r.DoneDelList,"message_id":message_id,"disable_web_page_preview":True,"reply_markup":reply_markup})
  
  if re.search("del(.*)replysBOT",date[0]):
    rank = isrank(redis,userID,chatID)
    if rank == "sudo":
      t = date[0].replace("del","")
      t = t.replace("BOT","")
      if date[1] != "kb":
        redis.delete("{}Nbot:{}".format(BOT_ID,t))
        Bot("editMessageText",{"chat_id":chatID,"text":r.DoneDelList,"message_id":message_id,"disable_web_page_preview":True})
      else:
        reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("<<",callback_data=json.dumps(["replylistBOT","",userID])),]])
        redis.delete("{}Nbot:{}".format(BOT_ID,t))
        Bot("editMessageText",{"chat_id":chatID,"text":r.DoneDelList,"message_id":message_id,"disable_web_page_preview":True,"reply_markup":reply_markup})
    else:
      Bot("answerCallbackQuery",{"callback_query_id":callback_query.id,"text":r.SudoOnle,"show_alert":True})
  if date[0] == "delfromb":
    Hash = date[1]
    chat = date[3]
    if redis.sismember("{}Nbot:groups".format(BOT_ID),chat):
      if Hash == "blockanimations":
        ID = callback_query.message.animation.file_id
        redis.srem("{}Nbot:{}:{}".format(BOT_ID,chat,Hash),ID)
        Bot("deleteMessage",{"chat_id":chatID,"message_id":message_id})
      if Hash == "blockSTICKERs":
        ID = callback_query.message.sticker.file_id
        redis.srem("{}Nbot:{}:{}".format(BOT_ID,chat,Hash),ID)
        Bot("deleteMessage",{"chat_id":chatID,"message_id":message_id})
      if Hash == "blockphotos":
        ID = callback_query.message.photo.file_id
        redis.srem("{}Nbot:{}:{}".format(BOT_ID,chat,Hash),ID)
        Bot("deleteMessage",{"chat_id":chatID,"message_id":message_id})

  User_click = int((redis.get("{}Nbot:{}:floodClick".format(BOT_ID,userID)) or 1))
  if User_click > 10:
    BY = "<a href=\"tg://user?id={}\">{}</a>".format(userID,userFN)
    Bot("sendMessage",{"chat_id":chatID,"text":r.banclick.format(BY),"disable_web_page_preview":True,"parse_mode":"html"})
    redis.setex("{}Nbot:floodUsers:{}".format(BOT_ID,userID),60*2,"Ban")
    redis.delete("{}Nbot:{}:floodClick".format(BOT_ID,userID))
  if chatID == userID:
    group = True
  if group is True and int(date[2]) == userID and not redis.get("{}Nbot:floodUsers:{}".format(BOT_ID,userID)):
    if date[0] == "delcheck":
        reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(r.notcertain, callback_data=json.dumps(["kickcheck","",userID])),InlineKeyboardButton(r.certain, callback_data=json.dumps(["certain","",userID]))]])
        random.shuffle(reply_markup.inline_keyboard[0])
        Bot("editMessageText",{"chat_id":chatID,"text":r.ucertain,"message_id":message_id,"disable_web_page_preview":True,"reply_markup":reply_markup})

    if date[0] == "certain":
      Bot("restrictChatMember",{"chat_id": chatID,"user_id":userID,"can_send_messages": 1,"can_send_media_messages": 1,"can_send_other_messages": 1,"can_send_polls": 1,"can_change_info": 1,"can_add_web_page_previews": 1,"can_pin_messages": 1,})
      T ="<a href=\"tg://user?id={}\">{}</a>".format(userID,Name(userFN))
      Bot("editMessageText",{"chat_id":chatID,"text":r.unrestricted.format(T),"message_id":message_id,"disable_web_page_preview":True,"parse_mode":"html"})
      

    if date[0] == "kickcheck":
      Bot("kickChatMember",{"chat_id":chatID,"user_id":userID})
      T ="<a href=\"tg://user?id={}\">{}</a>".format(userID,Name(userFN))
      crid = redis.get("{}Nbot:{}:creator".format(BOT_ID,chatID))
      redis.sadd("{}Nbot:{}:bans".format(BOT_ID,chatID),userID)
      reply_markup = InlineKeyboardMarkup([[InlineKeyboardButton(r.Corder, callback_data=json.dumps(["Cordertow",userID]))]])
      Bot("editMessageText",{"chat_id":chatID,"text":r.bancheck.format(T),"message_id":message_id,"disable_web_page_preview":True,"parse_mode":"html","reply_markup":reply_markup})
      

    if date[0] == "addor":
      cpKey = date[1]
      kbList = {"vip":{
        "cb":"^%(tx)s$|^%(tx)s @(.*)$|%(tx)s [0-9]+$",
        "cb2":"^%(tx)s [0-9]+$",
        "rp":c.orvip,
      },"owner":{
        "cb":"^%(tx)s$|^%(tx)s @(.*)$|%(tx)s [0-9]+$",
        "cb2":"^%(tx)s [0-9]+$",
        "rp":c.orow,
      },"admin":{
        "cb":"^%(tx)s$|^%(tx)s @(.*)$|%(tx)s [0-9]+$",
        "cb2":"^%(tx)s [0-9]+$",
        "rp":c.orad,
      },"ban":{
        "cb":"^%(tx)s$|^%(tx)s @(.*)$|%(tx)s [0-9]+$",
        "cb2":"^%(tx)s [0-9]+$",
        "rp":c.orban,
      },"tk":{
        "cb":"^%(tx)s$|^%(tx)s @(.*)$|%(tx)s [0-9]+$",
        "cb2":"^%(tx)s [0-9]+$",
        "rp":c.ortk,
      }
      }
      cc = re.findall(c.addor,callback_query.message.reply_to_message.text)
      F = kbList[cpKey]
      cb = F["cb"] % {'tx': cc[0]}
      cb2 = F["cb2"] % {'tx': cc[0]}
      print(cb,cb2)
      redis.hset("{}Nbot:{}or:cb".format(BOT_ID,cpKey),chatID,cb)
      redis.hset("{}Nbot:{}or:cb2".format(BOT_ID,cpKey),chatID,cb2)
      callback_query.message.edit_text(r.Daddor.format(cc[0],F["rp"]))

    if date[0] == "delF":
      File = date[1]
      os.system("rm ./files/"+File)
      Bot("editMessageText",{"chat_id":chatID,"text":r.Delfile.format(File),"message_id":message_id,"parse_mode":"html","disable_web_page_preview":True})

    if date[0] == "delFa":
      os.system("rm -rf ./files/*")
      Bot("editMessageText",{"chat_id":chatID,"text":r.Delfiles,"message_id":message_id,"parse_mode":"html","disable_web_page_preview":True})


    if date[0] == "dlf":
      File = date[1]
      os.system("rm ./files/"+File)
      url = "https://raw.githubusercontent.com/NitroMD/NB-files/master/"+File
      out = requests.get(url).text
      f = open("./files/"+File,"w+")
      f.write(out)
      f.close()
      Bot("editMessageText",{"chat_id":chatID,"text":r.Dua.format(File),"message_id":message_id,"parse_mode":"html","disable_web_page_preview":True})

    if date[0] == "au":
      File = date[1]
      if redis.sismember("{}Nbot:botfiles".format(BOT_ID),File):
        redis.srem("{}Nbot:botfiles".format(BOT_ID),File)
      else:
        redis.sadd("{}Nbot:botfiles".format(BOT_ID),File)
      onlyfiles = [f for f in listdir("files") if isfile(join("files", f))]
      filesR = redis.smembers("{}Nbot:botfiles".format(BOT_ID))
      array = []
      for f in onlyfiles:
        if f in filesR:
          s = r.true
        else:
          s = r.false
        array.append([InlineKeyboardButton(f+" "+s,callback_data=json.dumps(["au",f,userID]))])
      kb = InlineKeyboardMarkup(array)
      Bot("editMessageReplyMarkup",{"chat_id":chatID,"message_id":message_id,"disable_web_page_preview":True,"reply_markup":kb})

    if date[0] == "twostepset":
      get = date[1] 
      if get == "eq":
        redis.hset("{}Nbot:bancheck:t".format(BOT_ID),chatID,"two")
        tx = r.Ttwo
        g= "two"
      if get == "two":
        redis.hdel("{}Nbot:bancheck:t".format(BOT_ID),chatID)
        
        g= "eq"
        tx =  r.Teq
      kb = InlineKeyboardMarkup([[InlineKeyboardButton(r.tset.format(tx),callback_data=json.dumps(["twostepset",g,userID]))]])
      Bot("editMessageReplyMarkup",{"chat_id":chatID,"message_id":message_id,"disable_web_page_preview":True,"reply_markup":kb})
      


    if date[0] == "floodset":
      get = date[1] 
      if get == "ban":
        redis.hset("{}Nbot:floodset".format(BOT_ID),chatID,"res")
        tx = r.Tres
        g= "res"
      if get == "res":
        redis.hset("{}Nbot:floodset".format(BOT_ID),chatID,"ban")
        g= "ban"
        tx =  r.Tban
      kb = InlineKeyboardMarkup([[InlineKeyboardButton(r.fset.format(tx),callback_data=json.dumps(["floodset",g,userID]))]])
      Bot("editMessageReplyMarkup",{"chat_id":chatID,"message_id":message_id,"disable_web_page_preview":True,"reply_markup":kb})
      
    if date[0] == "delmsgclick":
      Bot("deleteMessage",{"chat_id":chatID,"message_id":message_id})
      Bot("deleteMessage",{"chat_id":chatID,"message_id":callback_query.message.reply_to_message.message_id})

    if date[0] == "ckGPs":
      rank = isrank(redis,userID,chatID)
      if rank == "sudo":
        Bot("editMessageText",{"chat_id":chatID,"text":r.ckpr,"message_id":message_id,"parse_mode":"html","disable_web_page_preview":True})
        IDS = redis.smembers("{}Nbot:groups".format(BOT_ID))
        i = 0
        for ID in IDS:
          get = Bot("getChat",{"chat_id":ID})
          if get["ok"] == False:
            redis.srem("{}Nbot:groups".format(BOT_ID),ID)
            redis.sadd("{}Nbot:disabledgroups".format(BOT_ID),ID)
            NextDay_Date = datetime.datetime.today() + datetime.timedelta(days=1)
            redis.hset("{}Nbot:disabledgroupsTIME".format(BOT_ID),ID,str(NextDay_Date))
            i+=1
          time.sleep(0.3)
        pr = redis.scard("{}Nbot:privates".format(BOT_ID))
        gp = redis.scard("{}Nbot:groups".format(BOT_ID))
        Bot("editMessageText",{"chat_id":chatID,"text":r.showstats.format(gp,pr)+r.Dckg.format(i),"message_id":message_id,"parse_mode":"html","disable_web_page_preview":True})

      else:
        Bot("answerCallbackQuery",{"callback_query_id":callback_query.id,"text":r.SudoOnle,"show_alert":True})

    if date[0] == "Chlang":
      name = date[1]
      redis.srem("{}Nbot:lang:ar".format(BOT_ID),chatID)
      redis.srem("{}Nbot:lang:arem".format(BOT_ID),chatID)
      redis.srem("{}Nbot:lang:en".format(BOT_ID),chatID)
      redis.sadd("{}Nbot:lang:{}".format(BOT_ID,name),chatID)
      
      Bot("editMessageReplyMarkup",{"chat_id":chatID,"message_id":message_id,"disable_web_page_preview":True,"reply_markup":Clang(client, callback_query,redis,r)})

    if date[0] == "ShowDateUser":
      t = IDrank(redis,userID,chatID,r)
      msgs = (redis.hget("{}Nbot:{}:msgs".format(BOT_ID,chatID),userID) or 0)
      edits = (redis.hget("{}Nbot:{}:edits".format(BOT_ID,chatID),userID) or 0)
      rate = int(msgs)*100/20000
      age = getAge(userID,r)
      reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(Name(userFN),url="t.me/vvhvvv")],[InlineKeyboardButton(r.Rrank.format(t),url="t.me/vvhvvv")],[InlineKeyboardButton(r.Rmsgs.format(msgs),url="t.me/vvhvvv")],[InlineKeyboardButton(r.Rrate.format(str(rate)+"%"),url="t.me/vvhvvv")],[InlineKeyboardButton(r.Redits.format(edits),url="t.me/vvhvvv")],[InlineKeyboardButton(r.Rage.format(age),url="t.me/vvhvvv")]])
      Bot("editMessageReplyMarkup",{"chat_id":chatID,"message_id":message_id,"disable_web_page_preview":True,"reply_markup":reply_markup})
    if re.search("ShowO",date[0]):
      T = date[0].replace("ShowO","")
      rank = isrank(redis,userID,chatID)
      if T == "lock":
        reply_markup = getOR(rank,r,userID)
        tx = r.LockO
      if T == "admin":
        reply_markup = getOR(rank,r,userID)
        tx = r.AdminO

      if T == "owner":
        reply_markup = getOR(rank,r,userID)
        tx = r.OwnerO

      if T == "creator":
        reply_markup = getOR(rank,r,userID)
        tx = r.CreatorO

      if T == "sudos":
        reply_markup = getOR(rank,r,userID)
        tx = r.SudosO
      if T == "sudo":
        reply_markup = getOR(rank,r,userID)
        tx = r.SudoO

      Bot("editMessageText",{"chat_id":chatID,"text":tx,"message_id":message_id,"disable_web_page_preview":True,"reply_markup":reply_markup})
      
    if date[0] == "sendtogroups":
      Bot("editMessageText",{"chat_id":chatID,"text":r.PRsendtoGP,"message_id":message_id,"disable_web_page_preview":True,"parse_mode":"html"})
      done,dont = Sendto(redis,callback_query,"groups")
      Bot("editMessageText",{"chat_id":chatID,"text":r.DsendtoGP.format(done,dont),"message_id":message_id,"disable_web_page_preview":True,"parse_mode":"html"})
      redis.delete("{}Nbot:donesend".format(BOT_ID))
      redis.delete("{}Nbot:dontsend".format(BOT_ID))
      
    if date[0] == "sendtoprivates":
      Bot("editMessageText",{"chat_id":chatID,"text":r.PRsendtoPR,"message_id":message_id,"disable_web_page_preview":True,"parse_mode":"html"})
      done,dont = Sendto(redis,callback_query,"privates")
      Bot("editMessageText",{"chat_id":chatID,"text":r.DsendtoPR.format(done,dont),"message_id":message_id,"disable_web_page_preview":True,"parse_mode":"html"})
      redis.delete("{}Nbot:donesend".format(BOT_ID))
      redis.delete("{}Nbot:dontsend".format(BOT_ID))

    if date[0] == "fwdtogroups":
      Bot("editMessageText",{"chat_id":chatID,"text":r.PRsendtoGP,"message_id":message_id,"disable_web_page_preview":True,"parse_mode":"html"})
      done,dont = fwdto(redis,callback_query,"groups")
      Bot("editMessageText",{"chat_id":chatID,"text":r.DsendtoGP.format(done,dont),"message_id":message_id,"disable_web_page_preview":True,"parse_mode":"html"})
      redis.delete("{}Nbot:donesend".format(BOT_ID))
      redis.delete("{}Nbot:dontsend".format(BOT_ID))
      
    if date[0] == "fwdtoprivates":
      Bot("editMessageText",{"chat_id":chatID,"text":r.PRsendtoPR,"message_id":message_id,"disable_web_page_preview":True,"parse_mode":"html"})
      done,dont = fwdto(redis,callback_query,"privates")
      Bot("editMessageText",{"chat_id":chatID,"text":r.DsendtoPR.format(done,dont),"message_id":message_id,"disable_web_page_preview":True,"parse_mode":"html"})
      redis.delete("{}Nbot:donesend".format(BOT_ID))
      redis.delete("{}Nbot:dontsend".format(BOT_ID))


    if date[0] == "kickme-yes":
      Bot("kickChatMember",{"chat_id":chatID,"user_id":userID})
      Bot("unbanChatMember",{"chat_id":chatID,"user_id":userID})
      Bot("editMessageText",{"chat_id":chatID,"text":r.Dkickme,"message_id":message_id,"disable_web_page_preview":True,"parse_mode":"html"})
    
    if date[0] == "kickme-no":
      Bot("editMessageText",{"chat_id":chatID,"text":r.Nkickme,"message_id":message_id,"disable_web_page_preview":True,"parse_mode":"html"})

    if date[0] == "delfromb":
      Hash = date[1]
      if Hash == "blockanimations":
        ID = callback_query.message.animation.file_id
        redis.srem("{}Nbot:{}:{}".format(BOT_ID,chatId,TY),ID)
        Bot("editMessageText",{"chat_id":chatID,"text":r.DoneUNblock,"message_id":message_id,"disable_web_page_preview":True})

    if date[0] == "Blocklist":
      Botuser = client.get_me().username
      reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(c.STword,callback_data=json.dumps(["showBlocklist","",userID])),InlineKeyboardButton(c.STgifs,url="https://telegram.me/{}?start=showBlocklist={}={}={}".format(Botuser,chatID,userID,"blockanimations")),],[InlineKeyboardButton(c.STphoto,url="https://telegram.me/{}?start=showBlocklist={}={}={}".format(Botuser,chatID,userID,"blockphotos")),InlineKeyboardButton(c.STsticker,url="https://telegram.me/{}?start=showBlocklist={}={}={}".format(Botuser,chatID,userID,"blockSTICKERs")),]])
      Bot("editMessageText",{"chat_id":chatID,"text":r.blocklist.format(r.blocklist2,title),"message_id":message_id,"parse_mode":"html","reply_markup":reply_markup})
    if date[0] == "replylist":
      reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(c.STword,callback_data=json.dumps(["showreplylist","",userID])),InlineKeyboardButton(c.STgifs,callback_data=json.dumps(["showGFreplylist","",userID])),],[InlineKeyboardButton(c.STvoice,callback_data=json.dumps(["showVOreplylist","",userID])),InlineKeyboardButton(c.STsticker,callback_data=json.dumps(["showSTreplylist","",userID])),]])
      Bot("editMessageText",{"chat_id":chatID,"text":r.blocklist.format(r.replylist,title),"message_id":message_id,"parse_mode":"html","reply_markup":reply_markup})
    if date[0] == "replylistBOT":
      reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(c.STword,callback_data=json.dumps(["showreplylistBOT","",userID])),InlineKeyboardButton(c.STgifs,callback_data=json.dumps(["showGFreplylistBOT","",userID])),],[InlineKeyboardButton(c.STvoice,callback_data=json.dumps(["showVOreplylistBOT","",userID])),InlineKeyboardButton(c.STsticker,callback_data=json.dumps(["showSTreplylistBOT","",userID])),]])
      Bot("editMessageText",{"chat_id":chatID,"text":r.blocklist.format(r.replylistBot,title),"message_id":message_id,"parse_mode":"html","reply_markup":reply_markup})
    
    if date[0] == "alllist":
      reply_markup=InlineKeyboardMarkup(
          [[InlineKeyboardButton(c.STbanall,callback_data=json.dumps(["showbanall","",userID]))
          ,InlineKeyboardButton(c.STtkall,callback_data=json.dumps(["showtkall","",userID])),]
          ])
      Bot("editMessageText",{"chat_id":chatID,"text":r.banlist,"message_id":message_id,"parse_mode":"html","reply_markup":reply_markup})
    
    if date[0] == "delallban":
      redis.delete("{}Nbot:bans".format(BOT_ID))
      reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("<<",callback_data=json.dumps(["alllist","",userID])),]])
      Bot("editMessageText",{"chat_id":chatID,"text":r.Ddelbanall,"message_id":message_id,"disable_web_page_preview":True,"parse_mode":"html","reply_markup":reply_markup})

    if date[0] == "delalltk":
      redis.delete("{}Nbot:restricteds".format(BOT_ID))
      reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("<<",callback_data=json.dumps(["alllist","",userID])),]])
      Bot("editMessageText",{"chat_id":chatID,"text":r.Ddeltkall,"message_id":message_id,"disable_web_page_preview":True,"parse_mode":"html","reply_markup":reply_markup})
      
    if date[0] == "showBlocklist":
      li = redis.smembers("{}Nbot:{}:blockTEXTs".format(BOT_ID,chatID))
      if li:
        words = ""
        i = 1
        for word in li:
          words = words+"\n"+str(i)+" - "+word
          i += 1
        reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(r.BlocklistRm,callback_data=json.dumps(["delListblockTEXTs","",userID])),],[InlineKeyboardButton("<<",callback_data=json.dumps(["Blocklist","",userID])),]])
        Bot("editMessageText",{"chat_id":chatID,"text":words,"message_id":message_id,"disable_web_page_preview":True,"reply_markup":reply_markup})
      else:
        reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("<<",callback_data=json.dumps(["Blocklist","",userID])),]])
        Bot("editMessageText",{"chat_id":chatID,"text":r.BlocklistEm,"message_id":message_id,"disable_web_page_preview":True,"reply_markup":reply_markup})
    
    if date[0] == "showbanall":
      arrays = redis.smembers("{}Nbot:bans".format(BOT_ID))
      if arrays:
        b = BYusers(arrays,chatID,redis,client)
        reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(r.allbandel,callback_data=json.dumps(["delallban","",userID])),],[InlineKeyboardButton("<<",callback_data=json.dumps(["alllist","",userID])),]])
        Bot("editMessageText",{"chat_id":chatID,"text":b,"message_id":message_id,"disable_web_page_preview":True,"reply_markup":reply_markup,"parse_mode":"markdown"})
      else:
        reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("<<",callback_data=json.dumps(["alllist","",userID])),]])
        Bot("editMessageText",{"chat_id":chatID,"text":r.allbanE,"message_id":message_id,"disable_web_page_preview":True,"reply_markup":reply_markup})

    if date[0] == "showtkall":
      arrays = redis.smembers("{}Nbot:restricteds".format(BOT_ID))
      if arrays:
        b = BYusers(arrays,chatID,redis,client)
        reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(r.alltkdel,callback_data=json.dumps(["delalltk","",userID])),],[InlineKeyboardButton("<<",callback_data=json.dumps(["alllist","",userID])),]])
        Bot("editMessageText",{"chat_id":chatID,"text":b,"message_id":message_id,"disable_web_page_preview":True,"reply_markup":reply_markup,"parse_mode":"markdown"})
      else:
        reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("<<",callback_data=json.dumps(["alllist","",userID])),]])
        Bot("editMessageText",{"chat_id":chatID,"text":r.alltkE,"message_id":message_id,"disable_web_page_preview":True,"reply_markup":reply_markup})
    
    if date[0] == "showreplylist":
      li = redis.hkeys("{}Nbot:{}:TXreplys".format(BOT_ID,chatID))
      if li:
        words = ""
        i = 1
        for word in li:
          words = words+"\n"+str(i)+" - {"+word+"}"
          i += 1
        if len(words) > 3000:
          Botuser = client.get_me().username
          reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(r.clickTOpv,url="https://telegram.me/{}?start=showreplylist={}={}={}".format(Botuser,chatID,userID,"TXreplys")),],[InlineKeyboardButton("<<",callback_data=json.dumps(["replylist","",userID])),]])
          Bot("editMessageText",{"chat_id":chatID,"text":r.Toolong,"message_id":message_id,"disable_web_page_preview":True,"reply_markup":reply_markup})
        else:
          reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(r.replylistRm,callback_data=json.dumps(["delTXreplys","kb",userID])),],[InlineKeyboardButton("<<",callback_data=json.dumps(["replylist","",userID])),]])
          Bot("editMessageText",{"chat_id":chatID,"text":words,"message_id":message_id,"disable_web_page_preview":True,"reply_markup":reply_markup})
      else:
        reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("<<",callback_data=json.dumps(["replylist","",userID])),]])
        Bot("editMessageText",{"chat_id":chatID,"text":r.replylistEm,"message_id":message_id,"disable_web_page_preview":True,"reply_markup":reply_markup})


    if date[0] == "showSTreplylist":
      li = redis.hkeys("{}Nbot:{}:STreplys".format(BOT_ID,chatID))
      if li:
        words = ""
        i = 1
        for word in li:
          words = words+"\n"+str(i)+" - {"+word+"}"
          i += 1
        if len(words) > 3000:
          Botuser = client.get_me().username
          reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(r.clickTOpv,url="https://telegram.me/{}?start=showreplylist={}={}={}".format(Botuser,chatID,userID,"STreplys")),],[InlineKeyboardButton("<<",callback_data=json.dumps(["replylist","",userID])),]])
          Bot("editMessageText",{"chat_id":chatID,"text":r.Toolong,"message_id":message_id,"disable_web_page_preview":True,"reply_markup":reply_markup})
        else:
          reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(r.STreplylistRm,callback_data=json.dumps(["delSTreplys","kb",userID])),],[InlineKeyboardButton("<<",callback_data=json.dumps(["replylist","",userID])),]])
          Bot("editMessageText",{"chat_id":chatID,"text":words,"message_id":message_id,"disable_web_page_preview":True,"reply_markup":reply_markup})
      else:
        reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("<<",callback_data=json.dumps(["replylist","",userID])),]])
        Bot("editMessageText",{"chat_id":chatID,"text":r.STreplylistEm,"message_id":message_id,"disable_web_page_preview":True,"reply_markup":reply_markup})


    if date[0] == "showGFreplylist":
      li = redis.hkeys("{}Nbot:{}:GFreplys".format(BOT_ID,chatID))
      if li:
        words = ""
        i = 1
        for word in li:
          words = words+"\n"+str(i)+" - {"+word+"}"
          i += 1
        if len(words) > 3000:
          Botuser = client.get_me().username
          reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(r.clickTOpv,url="https://telegram.me/{}?start=showreplylist={}={}={}".format(Botuser,chatID,userID,"GFreplys")),],[InlineKeyboardButton("<<",callback_data=json.dumps(["replylist","",userID])),]])
          Bot("editMessageText",{"chat_id":chatID,"text":r.Toolong,"message_id":message_id,"disable_web_page_preview":True,"reply_markup":reply_markup})
        else:
          reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(r.GFreplylistRm,callback_data=json.dumps(["delGFreplys","kb",userID])),],[InlineKeyboardButton("<<",callback_data=json.dumps(["replylist","",userID])),]])
          Bot("editMessageText",{"chat_id":chatID,"text":words,"message_id":message_id,"disable_web_page_preview":True,"reply_markup":reply_markup})
      else:
        reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("<<",callback_data=json.dumps(["replylist","",userID])),]])
        Bot("editMessageText",{"chat_id":chatID,"text":r.GFreplylistEm,"message_id":message_id,"disable_web_page_preview":True,"reply_markup":reply_markup})

    if date[0] == "showVOreplylist":
      li = redis.hkeys("{}Nbot:{}:VOreplys".format(BOT_ID,chatID))
      if li:
        words = ""
        i = 1
        for word in li:
          words = words+"\n"+str(i)+" - {"+word+"}"
          i += 1
        if len(words) > 3000:
          Botuser = client.get_me().username
          reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(r.clickTOpv,url="https://telegram.me/{}?start=showreplylist={}={}={}".format(Botuser,chatID,userID,"VOreplys")),],[InlineKeyboardButton("<<",callback_data=json.dumps(["replylist","",userID])),]])
          Bot("editMessageText",{"chat_id":chatID,"text":r.Toolong,"message_id":message_id,"disable_web_page_preview":True,"reply_markup":reply_markup})
        else:
          reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(r.VOreplylistRm,callback_data=json.dumps(["delVOreplys","kb",userID])),],[InlineKeyboardButton("<<",callback_data=json.dumps(["replylist","",userID])),]])
          Bot("editMessageText",{"chat_id":chatID,"text":words,"message_id":message_id,"disable_web_page_preview":True,"reply_markup":reply_markup})
      else:
        reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("<<",callback_data=json.dumps(["replylist","",userID])),]])
        Bot("editMessageText",{"chat_id":chatID,"text":r.VOreplylistEm,"message_id":message_id,"disable_web_page_preview":True,"reply_markup":reply_markup})

    if date[0] == "showreplylistBOT":
      li = redis.hkeys("{}Nbot:TXreplys".format(BOT_ID,chatID))
      if li:
        words = ""
        i = 1
        for word in li:
          words = words+"\n"+str(i)+" - {"+word+"}"
          i += 1
        if len(words) > 3000:
          Botuser = client.get_me().username
          reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(r.clickTOpv,url="https://telegram.me/{}?start=showreplylistBOT={}={}={}".format(Botuser,chatID,userID,"TXreplys")),],[InlineKeyboardButton("<<",callback_data=json.dumps(["replylistBOT","",userID])),]])
          Bot("editMessageText",{"chat_id":chatID,"text":r.Toolong,"message_id":message_id,"disable_web_page_preview":True,"reply_markup":reply_markup})
        else:
          reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(r.replylistRm,callback_data=json.dumps(["delTXreplysBOT","kb",userID])),],[InlineKeyboardButton("<<",callback_data=json.dumps(["replylistBOT","",userID])),]])
          Bot("editMessageText",{"chat_id":chatID,"text":words,"message_id":message_id,"disable_web_page_preview":True,"reply_markup":reply_markup})
      else:
        reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("<<",callback_data=json.dumps(["replylistBOT","",userID])),]])
        Bot("editMessageText",{"chat_id":chatID,"text":r.replylistEm,"message_id":message_id,"disable_web_page_preview":True,"reply_markup":reply_markup})


    if date[0] == "showSTreplylistBOT":
      li = redis.hkeys("{}Nbot:STreplys".format(BOT_ID,chatID))
      if li:
        words = ""
        i = 1
        for word in li:
          words = words+"\n"+str(i)+" - {"+word+"}"
          i += 1
        if len(words) > 3000:
          Botuser = client.get_me().username
          reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(r.clickTOpv,url="https://telegram.me/{}?start=showreplylistBOT={}={}={}".format(Botuser,chatID,userID,"STreplys")),],[InlineKeyboardButton("<<",callback_data=json.dumps(["replylistBOT","",userID])),]])
          Bot("editMessageText",{"chat_id":chatID,"text":r.Toolong,"message_id":message_id,"disable_web_page_preview":True,"reply_markup":reply_markup})
        else:
          reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(r.STreplylistRm,callback_data=json.dumps(["delSTreplysBOT","kb",userID])),],[InlineKeyboardButton("<<",callback_data=json.dumps(["replylistBOT","",userID])),]])
          Bot("editMessageText",{"chat_id":chatID,"text":words,"message_id":message_id,"disable_web_page_preview":True,"reply_markup":reply_markup})
      else:
        reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("<<",callback_data=json.dumps(["replylistBOT","",userID])),]])
        Bot("editMessageText",{"chat_id":chatID,"text":r.STreplylistEm,"message_id":message_id,"disable_web_page_preview":True,"reply_markup":reply_markup})


    if date[0] == "showGFreplylistBOT":
      li = redis.hkeys("{}Nbot:GFreplys".format(BOT_ID,chatID))
      if li:
        words = ""
        i = 1
        for word in li:
          words = words+"\n"+str(i)+" - {"+word+"}"
          i += 1
        if len(words) > 3000:
          Botuser = client.get_me().username
          reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(r.clickTOpv,url="https://telegram.me/{}?start=showreplylistBOT={}={}={}".format(Botuser,chatID,userID,"GFreplys")),],[InlineKeyboardButton("<<",callback_data=json.dumps(["replylistBOT","",userID])),]])
          Bot("editMessageText",{"chat_id":chatID,"text":r.Toolong,"message_id":message_id,"disable_web_page_preview":True,"reply_markup":reply_markup})
        else:
          reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(r.GFreplylistRm,callback_data=json.dumps(["delGFreplysBOT","kb",userID])),],[InlineKeyboardButton("<<",callback_data=json.dumps(["replylistBOT","",userID])),]])
          Bot("editMessageText",{"chat_id":chatID,"text":words,"message_id":message_id,"disable_web_page_preview":True,"reply_markup":reply_markup})
      else:
        reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("<<",callback_data=json.dumps(["replylistBOT","",userID])),]])
        Bot("editMessageText",{"chat_id":chatID,"text":r.GFreplylistEm,"message_id":message_id,"disable_web_page_preview":True,"reply_markup":reply_markup})

    if date[0] == "showVOreplylistBOT":
      li = redis.hkeys("{}Nbot:VOreplys".format(BOT_ID,chatID))
      if li:
        words = ""
        i = 1
        for word in li:
          words = words+"\n"+str(i)+" - {"+word+"}"
          i += 1
        if len(words) > 3000:
          Botuser = client.get_me().username
          reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(r.clickTOpv,url="https://telegram.me/{}?start=showreplylistBOT={}={}={}".format(Botuser,chatID,userID,"VOreplys")),],[InlineKeyboardButton("<<",callback_data=json.dumps(["replylistBOT","",userID])),]])
          Bot("editMessageText",{"chat_id":chatID,"text":r.Toolong,"message_id":message_id,"disable_web_page_preview":True,"reply_markup":reply_markup})
        else:
          reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(r.VOreplylistRm,callback_data=json.dumps(["delVOreplysBOT","kb",userID])),],[InlineKeyboardButton("<<",callback_data=json.dumps(["replylistBOT","",userID])),]])
          Bot("editMessageText",{"chat_id":chatID,"text":words,"message_id":message_id,"disable_web_page_preview":True,"reply_markup":reply_markup})
      else:
        reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("<<",callback_data=json.dumps(["replylistBOT","",userID])),]])
        Bot("editMessageText",{"chat_id":chatID,"text":r.VOreplylistEm,"message_id":message_id,"disable_web_page_preview":True,"reply_markup":reply_markup})

    
    if date[0] == "listCH":
      if int(date[1]) != 4:
        Bot("editMessageText",{"chat_id":chatID,"text":r.settings.format(title),"message_id":message_id,"disable_web_page_preview":True,"reply_markup":st(client, callback_query,redis,int(date[1])),"parse_mode":"html"})
        #Bot("editMessageReplyMarkup",{"chat_id":chatID,"message_id":message_id,"reply_markup":st(client, callback_query,redis,int(date[3]))})
      else:
        T = (redis.hget("{}Nbot:time_ck".format(BOT_ID),chatID) or 3)
        m = (redis.hget("{}Nbot:max_msg".format(BOT_ID),chatID) or 10)
        Bot("editMessageText",{"chat_id":chatID,"text":r.st2.format(T,m),"message_id":message_id,"disable_web_page_preview":True,"reply_markup":st(client, callback_query,redis,int(date[1])),"parse_mode":"html"})
    if date[0] == "listCH-res":
      Bot("editMessageReplyMarkup",{"chat_id":chatID,"message_id":message_id,"reply_markup":st_res(client, callback_query,redis,int(date[1]))})


      #Bot("editMessageReplyMarkup",{"chat_id":chatID,"message_id":message_id,"reply_markup":st(client, callback_query,redis,int(date[1]))})
    if date[0] == 'LU-res':
      d = date[1].split("-")
      lock = d[0]
      lockres = d[0]+":"+d[1]
      if redis.sismember("{}Nbot:{}".format(BOT_ID,lockres),chatID):
        redis.srem("{}Nbot:{}".format(BOT_ID,lockres),chatID)
      else:
        redis.sadd("{}Nbot:{}".format(BOT_ID,lockres),chatID)
        redis.sadd("{}Nbot:{}".format(BOT_ID,lock),chatID)
      Bot("editMessageReplyMarkup",{"chat_id":chatID,"message_id":message_id,"reply_markup":st_res(client, callback_query,redis,int(date[3]))})


    
    
    if date[0] == 'LU':
      if redis.sismember("{}Nbot:{}".format(BOT_ID,date[1]),chatID):
        save = redis.srem("{}Nbot:{}".format(BOT_ID,date[1]),chatID)
      else:
        save = redis.sadd("{}Nbot:{}".format(BOT_ID,date[1]),chatID)
      if int(date[3]) != 4:
        Bot("editMessageText",{"chat_id":chatID,"text":r.settings.format(title),"message_id":message_id,"disable_web_page_preview":True,"reply_markup":st(client, callback_query,redis,int(date[3])),"parse_mode":"html"})
        #Bot("editMessageReplyMarkup",{"chat_id":chatID,"message_id":message_id,"reply_markup":st(client, callback_query,redis,int(date[3]))})
      else:
        T = (redis.hget("{}Nbot:time_ck".format(BOT_ID),chatID) or 3)
        m = (redis.hget("{}Nbot:max_msg".format(BOT_ID),chatID) or 10)
        Bot("editMessageText",{"chat_id":chatID,"text":r.st2.format(T,m),"message_id":message_id,"disable_web_page_preview":True,"reply_markup":st(client, callback_query,redis,int(date[3])),"parse_mode":"html"})

    if date[0] == "delListblockTEXTs":
      redis.delete("{}Nbot:{}:blockTEXTs".format(BOT_ID,chatID))
      Bot("editMessageText",{"chat_id":chatID,"text":r.DoneDelList,"message_id":message_id,"disable_web_page_preview":True})

    if date[0] == "delListbans":
      arrays = redis.smembers("{}Nbot:{}:bans".format(BOT_ID,chatID))
      for user in arrays:
        GetGprank = GPranks(user,chatID)
        if GetGprank == "kicked":
          Bot("unbanChatMember",{"chat_id":chatID,"user_id":user})
        redis.srem("{}Nbot:{}:bans".format(BOT_ID,chatID),user)
      Bot("editMessageText",{"chat_id":chatID,"text":r.DoneDelList,"message_id":message_id,"disable_web_page_preview":True})

    if date[0] == "delListrestricteds":
      arrays = redis.smembers("{}Nbot:{}:restricteds".format(BOT_ID,chatID))
      for user in arrays:
        GetGprank = GPranks(user,chatID)
        if GetGprank == "restricted":
          Bot("restrictChatMember",{"chat_id": chatID,"user_id": user,"can_send_messages": 1,"can_send_media_messages": 1,"can_send_other_messages": 1,"can_send_polls": 1,"can_change_info": 1,"can_add_web_page_previews": 1,"can_pin_messages": 1,})
        redis.srem("{}Nbot:{}:restricteds".format(BOT_ID,chatID),user)
      Bot("editMessageText",{"chat_id":chatID,"text":r.DoneDelList,"message_id":message_id,"disable_web_page_preview":True})

    if date[0] == "LandU":
      if date[3] == "LtoU":
        if redis.sismember("{}Nbot:{}".format(BOT_ID,date[1]),chatID):
          redis.srem("{}Nbot:{}".format(BOT_ID,date[1]),chatID)
          Bot("editMessageText",{"chat_id":chatID,"text":r.doneCO,"message_id":message_id,"disable_web_page_preview":True})
        else:
          Bot("editMessageText",{"chat_id":chatID,"text":r.ARdoneCO,"message_id":message_id,"disable_web_page_preview":True})
      if date[3] == "UtoL":
        if redis.sismember("{}Nbot:{}".format(BOT_ID,date[1]),chatID):
          Bot("editMessageText",{"chat_id":chatID,"text":r.ARdoneCO,"message_id":message_id,"disable_web_page_preview":True})
        else:
          redis.sadd("{}Nbot:{}".format(BOT_ID,date[1]),chatID)
          Bot("editMessageText",{"chat_id":chatID,"text":r.doneCO,"message_id":message_id,"disable_web_page_preview":True})
    
    if date[0] == "Corder":
      if date[1] == "bans":
        if date[4] == "UtoB":
          if redis.sismember("{}Nbot:{}:bans".format(BOT_ID,chatID),date[3]):
            Bot("editMessageText",{"chat_id":chatID,"text":r.ARdoneCO,"message_id":message_id,"disable_web_page_preview":True})
          else:
            GetGprank = GPranks(date[3],chatID)
            if GetGprank == "kicked":
              Bot("kickChatMember",{"chat_id":chatID,"user_id":date[3]})
            redis.srem("{}Nbot:{}:bans".format(BOT_ID,chatID),date[3])
            Bot("editMessageText",{"chat_id":chatID,"text":r.doneCO,"message_id":message_id,"disable_web_page_preview":True})
        if date[4] == "BtoU":
          if redis.sismember("{}Nbot:{}:bans".format(BOT_ID,chatID),date[3]):
            GetGprank = GPranks(date[3],chatID)
            if GetGprank == "kicked":
              Bot("unbanChatMember",{"chat_id":chatID,"user_id":date[3]})
            redis.srem("{}Nbot:{}:bans".format(BOT_ID,chatID),date[3])
            Bot("editMessageText",{"chat_id":chatID,"text":r.doneCO,"message_id":message_id,"disable_web_page_preview":True})
          else:
            Bot("editMessageText",{"chat_id":chatID,"text":r.ARdoneCO,"message_id":message_id,"disable_web_page_preview":True})
      
      if date[1] == "restricteds":
        if date[4] == "UtoB":
          if redis.sismember("{}Nbot:{}:restricteds".format(BOT_ID,chatID),date[3]):
            Bot("editMessageText",{"chat_id":chatID,"text":r.ARdoneCO,"message_id":message_id,"disable_web_page_preview":True})
          else:
            GetGprank = GPranks(date[3],chatID)
            if GetGprank == "restricted":
              Bot("restrictChatMember",{"chat_id": chatID,"user_id": date[3],"can_send_messages": 0,"can_send_media_messages": 0,"can_send_other_messages": 0,"can_send_polls": 0,"can_change_info": 0,"can_add_web_page_previews": 0,"can_pin_messages": 0,})
            redis.sadd("{}Nbot:{}:restricteds".format(BOT_ID,chatID),date[3])
            Bot("editMessageText",{"chat_id":chatID,"text":r.doneCO,"message_id":message_id,"disable_web_page_preview":True})
        if date[4] == "BtoU":
          if redis.sismember("{}Nbot:{}:restricteds".format(BOT_ID,chatID),date[3]):
            GetGprank = GPranks(date[3],chatID)
            if GetGprank == "restricted":
              Bot("restrictChatMember",{"chat_id": chatID,"user_id": date[3],"can_send_messages": 1,"can_send_media_messages": 1,"can_send_other_messages": 1,"can_send_polls": 1,"can_change_info": 1,"can_add_web_page_previews": 1,"can_pin_messages": 1,})
            redis.srem("{}Nbot:{}:restricteds".format(BOT_ID,chatID),date[3])
            Bot("editMessageText",{"chat_id":chatID,"text":r.doneCO,"message_id":message_id,"disable_web_page_preview":True})
          else:
            Bot("editMessageText",{"chat_id":chatID,"text":r.ARdoneCO,"message_id":message_id,"disable_web_page_preview":True})
    
    if date[0] == "delList":
      H = date[1]


      if H != "sudos" and H != "creator":
        redis.delete("{}Nbot:{}:{}".format(BOT_ID,chatID,H))
        Bot("editMessageText",{"chat_id":chatID,"text":r.DoneDelList,"message_id":message_id,"disable_web_page_preview":True})
      if H == "sudos":
        redis.delete("{}Nbot:sudos".format(BOT_ID))
        Bot("editMessageText",{"chat_id":chatID,"text":r.DoneDelList,"message_id":message_id,"disable_web_page_preview":True})
      if H == "creator":
        redis.delete("{}Nbot:{}:{}".format(BOT_ID,chatID,H))
        Bot("editMessageText",{"chat_id":chatID,"text":r.DoneDelList,"message_id":message_id,"disable_web_page_preview":True})
    redis.setex("{}Nbot:{}:floodClick".format(BOT_ID,userID), 3, User_click+1)
    Bot("answerCallbackQuery",{"callback_query_id":callback_query.id})
  elif int(date[2]) != userID:
    Bot("answerCallbackQuery",{"callback_query_id":callback_query.id,"text":r.notforyou,"show_alert":True})
    redis.setex("{}Nbot:{}:floodClick".format(BOT_ID,userID), 3, User_click+1)

  if redis.smembers("{}Nbot:botfiles".format(BOT_ID)):
    onlyfiles = [f for f in listdir("files") if isfile(join("files", f))]
    filesR = redis.smembers("{}Nbot:botfiles".format(BOT_ID))
    for f in onlyfiles:
      if f in filesR:
        fi = f.replace(".py","")
        UpMs= "files."+fi
        try:
          U = importlib.import_module(UpMs)
          t = threading.Thread(target=U.updateCb,args=(client, callback_query,redis))
          t.setDaemon(True)
          t.start()
          importlib.reload(U)
        except Exception as e:
          pass
示例#15
0
def gpcmd(client, message,redis):
  type = message.chat.type
  userID = message.from_user.id
  chatID = message.chat.id
  title = message.chat.title
  rank = isrank(redis,userID,chatID)
  text = message.text
  username = message.from_user.username
  if username is None:
    username = "******"
  lang = Glang(redis,chatID)
  moduleCMD = "lang."+lang+"-cmd"
  moduleREPLY = "lang."+lang+"-reply"
  c = importlib.import_module(moduleCMD)
  r = importlib.import_module(moduleREPLY)
  #steps
  if redis.hexists("{}Nbot:step".format(BOT_ID),userID):
    tx = redis.hget("{}Nbot:step".format(BOT_ID),userID)
    if text :
      redis.hset("{}Nbot:{}:TXreplys".format(BOT_ID,chatID),tx,text)
      redis.hdel("{}Nbot:step".format(BOT_ID),userID)
      Bot("sendMessage",{"chat_id":chatID,"text":r.SRtext.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})
    
    if message.sticker:
      ID = message.sticker.file_id
      redis.hset("{}Nbot:{}:STreplys".format(BOT_ID,chatID),tx,ID)
      redis.hdel("{}Nbot:step".format(BOT_ID),userID)
      Bot("sendMessage",{"chat_id":chatID,"text":r.SRst.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})

    if message.animation:
      ID = message.animation.file_id
      redis.hset("{}Nbot:{}:GFreplys".format(BOT_ID,chatID),tx,ID)
      redis.hdel("{}Nbot:step".format(BOT_ID),userID)
      Bot("sendMessage",{"chat_id":chatID,"text":r.SRgf.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})

    if message.voice:
      ID = message.voice.file_id
      redis.hset("{}Nbot:{}:VOreplys".format(BOT_ID,chatID),tx,ID)
      redis.hdel("{}Nbot:step".format(BOT_ID),userID)
      Bot("sendMessage",{"chat_id":chatID,"text":r.SRvo.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})
    
    if message.photo:
      ID = message.photo.file_id
      redis.hset("{}Nbot:{}:PHreplys".format(BOT_ID,chatID),tx,ID)
      redis.hdel("{}Nbot:step".format(BOT_ID),userID)
      Bot("sendMessage",{"chat_id":chatID,"text":r.SRph.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})
    if message.document:
      ID = message.document.file_id
      redis.hset("{}Nbot:{}:DOreplys".format(BOT_ID,chatID),tx,ID)
      redis.hdel("{}Nbot:step".format(BOT_ID),userID)
      Bot("sendMessage",{"chat_id":chatID,"text":r.SRfi.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})



###############
  if text:
    if text == c.delrpmsg and message.reply_to_message:
      Bot("deleteMessage",{"chat_id":chatID,"message_id":message.message_id})
      Bot("deleteMessage",{"chat_id":chatID,"message_id":message.reply_to_message.message_id})

    if text == c.settingsCmd and Ckuser(message):
      kb = st(client, message,redis)
      Bot("sendMessage",{"chat_id":chatID,"text":r.settings.format(title),"reply_to_message_id":message.message_id,"parse_mode":"html","reply_markup":kb})


    if re.search(c.settingsCmdRes, text) and Ckuser(message):
      kb = st_res(client, message,redis)
      Bot("sendMessage",{"chat_id":chatID,"text":r.settingsRes.format(title),"reply_to_message_id":message.message_id,"parse_mode":"html","reply_markup":kb})
    
    
    if re.search(c.bans, text):
      arrays = redis.smembers("{}Nbot:{}:bans".format(BOT_ID,chatID))
      b = BYusers(arrays,chatID,redis,client)
      kb = InlineKeyboardMarkup([[InlineKeyboardButton(r.delList.format(text), callback_data=json.dumps(["delListbans","",userID]))]])
      if  b is not "":
        Bot("sendMessage",{"chat_id":chatID,"text":r.showlist.format(text,b),"reply_to_message_id":message.message_id,"parse_mode":"markdown","reply_markup":kb})
      else:
        Bot("sendMessage",{"chat_id":chatID,"text":r.listempty.format(text),"reply_to_message_id":message.message_id,"parse_mode":"markdown"})

    if re.search(c.restricteds, text):
      arrays = redis.smembers("{}Nbot:{}:restricteds".format(BOT_ID,chatID))
      b = BYusers(arrays,chatID,redis,client)
      kb = InlineKeyboardMarkup([[InlineKeyboardButton(r.delList.format(text), callback_data=json.dumps(["delListrestricteds","",userID]))]])
      if  b is not "":
        Bot("sendMessage",{"chat_id":chatID,"text":r.showlist.format(text,b),"reply_to_message_id":message.message_id,"parse_mode":"markdown","reply_markup":kb})
      else:
        Bot("sendMessage",{"chat_id":chatID,"text":r.listempty.format(text),"reply_to_message_id":message.message_id,"parse_mode":"markdown"})

    orban = redis.hget("{}Nbot:banor:cb".format(BOT_ID),chatID) or c.ban
    orban2 = redis.hget("{}Nbot:banor:cb2".format(BOT_ID),chatID) or c.ban2
    if re.search(c.ban+"|"+orban, text):
      if re.search("@",text):
        user = text.split("@")[1]
      if re.search(c.ban2+"|"+orban2,text):
        user = int(re.search(r'\d+', text).group())
      if message.reply_to_message:
        user = message.reply_to_message.from_user.id
      if 'user' not in locals():return False
      try:
        getUser = client.get_users(user)
        #print(getUser)
        userId = getUser.id
        userFn = getUser.first_name
        Getrank = isrank(redis,userId,chatID)
        GetGprank = GPranks(userId,chatID)
        if Getrank == "bot":return False
        if GetGprank == "NoMember":
          Bot("sendMessage",{"chat_id":chatID,"text":r.NoMember,"reply_to_message_id":message.message_id,"parse_mode":"html"})
        if (GetGprank == "left" or GetGprank == "kicked"):
          Bot("sendMessage",{"chat_id":chatID,"text":r.haveKick,"reply_to_message_id":message.message_id,"parse_mode":"html"})
        elif (GetGprank == "member" or GetGprank == "restricted") and (Getrank is False or Getrank is 0):
          if redis.sismember("{}Nbot:{}:bans".format(BOT_ID,chatID),userId):
            send_msg("BNN",client, message,r.Dban,"bans",getUser,redis)
          else:
            Bot("kickChatMember",{"chat_id":chatID,"user_id":userId})
            redis.sadd("{}Nbot:{}:bans".format(BOT_ID,chatID),userId)
            send_msg("BN",client, message,r.ban,"bans",getUser,redis)
        elif (GetGprank == "creator" or GetGprank == "administrator") or (Getrank != False or Getrank != 0):
          Bot("sendMessage",{"chat_id":chatID,"text":r.haveRank.format(Grank((Getrank or GetGprank),r)),"reply_to_message_id":message.message_id,"parse_mode":"html"})
      except Exception as e:
        Bot("sendMessage",{"chat_id":chatID,"text":r.userNocc,"reply_to_message_id":message.message_id,"parse_mode":"html"})

    if re.search(c.unban, text):
      if re.search("@",text):
        user = text.split("@")[1]
      if re.search(c.unban2,text):
        user = text.split(" ")[1]
      if message.reply_to_message:
        user = message.reply_to_message.from_user.id
      if 'user' not in locals():return False
      try:
        getUser = client.get_users(user)
        userId = getUser.id
        userFn = getUser.first_name
        Getrank = isrank(redis,userId,chatID)
        GetGprank = GPranks(userId,chatID)
        if Getrank == "bot":return False
        if GetGprank == "NoMember":
          Bot("sendMessage",{"chat_id":chatID,"text":r.NoMember,"reply_to_message_id":message.message_id,"parse_mode":"html"})
          return False
        if GetGprank == "kicked":
          Bot("unbanChatMember",{"chat_id":chatID,"user_id":userId})
          redis.srem("{}Nbot:{}:bans".format(BOT_ID,chatID),userId)
          send_msg("BN",client, message,r.unban,"bans",getUser,redis)
        else:
          send_msg("BNN",client, message,r.Dunban,"bans",getUser,redis)
      except Exception as e:
        Bot("sendMessage",{"chat_id":chatID,"text":r.userNocc,"reply_to_message_id":message.message_id,"parse_mode":"html"})
   
    ortk = redis.hget("{}Nbot:tkor:cb".format(BOT_ID),chatID) or c.TK
    ortk2 = redis.hget("{}Nbot:tkor:cb2".format(BOT_ID),chatID) or c.TK2
    if re.search(c.TK+"|"+ortk, text):
      if re.search("@",text):
        user = text.split("@")[1]
      if re.search(c.TK2+"|"+ortk2,text):
        user = int(re.search(r'\d+', text).group())
      if message.reply_to_message:
        user = message.reply_to_message.from_user.id
      if 'user' not in locals():return False
      try:
        getUser = client.get_users(user)
        userId = getUser.id
        userFn = getUser.first_name
        Getrank = isrank(redis,userId,chatID)
        GetGprank = GPranks(userId,chatID)
        if Getrank == "bot":return False
        if GetGprank == "NoMember":
          Bot("sendMessage",{"chat_id":chatID,"text":r.NoMember,"reply_to_message_id":message.message_id,"parse_mode":"html"})
        if (GetGprank == "left" or GetGprank == "kicked"):
          Bot("sendMessage",{"chat_id":chatID,"text":r.haveKick,"reply_to_message_id":message.message_id,"parse_mode":"html"})
        elif (GetGprank == "restricted"):
          send_msg("BNN",client, message,r.haveRc,"restricteds",getUser,redis)
          #Bot("sendMessage",{"chat_id":chatID,"text":r.haveRc,"reply_to_message_id":message.message_id,"parse_mode":"html"})
        elif GetGprank == "member" and (Getrank is False or Getrank is 0):
          if redis.sismember("{}Nbot:{}:restricteds".format(BOT_ID,chatID),userId):
            send_msg("BNN",client, message,r.Drestricted,"restricteds",getUser,redis)
          else:
            Bot("restrictChatMember",{"chat_id": chatID,"user_id": userId,"can_send_messages": 0,"can_send_media_messages": 0,"can_send_other_messages": 0,
            "can_send_polls": 0,"can_change_info": 0,"can_add_web_page_previews": 0,"can_pin_messages": 0,"can_invite_users": 0,})
            redis.sadd("{}Nbot:{}:restricteds".format(BOT_ID,chatID),userId)
            send_msg("BN",client, message,r.restricted,"restricteds",getUser,redis)
        elif (GetGprank == "creator" or GetGprank == "administrator") or (Getrank != False or Getrank != 0):
          Bot("sendMessage",{"chat_id":chatID,"text":r.haveRank.format(Grank((Getrank or GetGprank),r)),"reply_to_message_id":message.message_id,"parse_mode":"html"})
      except Exception as e:
        Bot("sendMessage",{"chat_id":chatID,"text":r.userNocc,"reply_to_message_id":message.message_id,"parse_mode":"html"})

    if re.search(c.unTK, text):
      if re.search("@",text):
        user = text.split("@")[1]
      if re.search(c.unTK2,text):
        user = text.split(" ")[1]
      if message.reply_to_message:
        user = message.reply_to_message.from_user.id
      if 'user' not in locals():return False
      try:
        getUser = client.get_users(user)
        userId = getUser.id
        userFn = getUser.first_name
        Getrank = isrank(redis,userId,chatID)
        GetGprank = GPranks(userId,chatID)
        if Getrank == "bot":return False
        if GetGprank == "NoMember":
          Bot("sendMessage",{"chat_id":chatID,"text":r.NoMember,"reply_to_message_id":message.message_id,"parse_mode":"html"})
          return False
        if GetGprank == "restricted":
          Bot("restrictChatMember",{"chat_id": chatID,"user_id": userId,"can_send_messages": 1,"can_send_media_messages": 1,"can_send_other_messages": 1,"can_send_polls": 1,
          "can_change_info": 1,"can_add_web_page_previews": 1,"can_pin_messages": 1,"can_invite_users": 1,})
          redis.srem("{}Nbot:{}:restricteds".format(BOT_ID,chatID),userId)
          send_msg("BN",client, message,r.unrestricted,"restricteds",getUser,redis)
        else:
          send_msg("BNN",client, message,r.Dunrestricted,"restricteds",getUser,redis)
      except Exception as e:
        Bot("sendMessage",{"chat_id":chatID,"text":r.userNocc,"reply_to_message_id":message.message_id,"parse_mode":"html"})
    
    if rank != "admin":
      if re.search(c.addor,text):
        cc= re.findall(c.addor,text)
        kbList = {"vip":{
          "cb":"^{0}$|^{0} @(.*)$|{0} {0-9}+$",
          "cb2":"^{0}{0-9}+$",
          "rp":c.orvip,
        },"admin":{
          "cb":"^{0}$|^{0} @(.*)$|{0} {0-9}+$",
          "cb2":"^{0}{0-9}+$",
          "rp":c.orad,
        },"ban":{
          "cb":"^{0}$|^{0} @(.*)$|{0} {0-9}+$",
          "cb2":"^{0}{0-9}+$",
          "rp":c.orban,
        },"tk":{
          "cb":"^{0}$|^{0} @(.*)$|{0} {0-9}+$",
          "cb2":"^{0}{0-9}+$",
          "rp":c.ortk,
        }
        }
        if rank == "sudo":
          kbList = {"vip":{
            "cb":"^{0}$|^{0} @(.*)$|{0} {0-9}+$",
            "cb2":"^{0}{0-9}+$",
            "rp":c.orvip,
          },"owner":{
            "cb":"^{0}$|^{0} @(.*)$|{0} {0-9}+$",
            "cb2":"^{0}{0-9}+$",
            "rp":c.orow,
          },"admin":{
            "cb":"^{0}$|^{0} @(.*)$|{0} {0-9}+$",
            "cb2":"^{0}{0-9}+$",
            "rp":c.orad,
          },"ban":{
            "cb":"^{0}$|^{0} @(.*)$|{0} {0-9}+$",
            "cb2":"^{0}{0-9}+$",
            "rp":c.orban,
          },"tk":{
            "cb":"^{0}$|^{0} @(.*)$|{0} {0-9}+$",
            "cb2":"^{0}{0-9}+$",
            "rp":c.ortk,
          }
          } 
        il = []
        for key, value in kbList.items():
          cb = json.dumps(["addor",key,userID])
          rp = value["rp"]
          il.append([InlineKeyboardButton(rp,callback_data=cb)])
        kb = InlineKeyboardMarkup(il)
        message.reply_text(r.addor.format(cc[0]),reply_markup=kb)

      if re.search(c.remallR, text):
        if re.search("@",text):
          user = text.split("@")[1]
        if re.search(c.remallR2,text):
          user = text.split(" ")[1]
        if message.reply_to_message:
          user = message.reply_to_message.from_user.id
        if 'user' not in locals():return False
        try:
          getUser = client.get_users(user)
          userId = getUser.id
          userFn = getUser.first_name
          Rank = isrank(redis,userId,chatID)
          tx = ""
          if (Rank is False or Rank is 0):
            BY = "<a href=\"tg://user?id={}\">{}</a>".format(userId,userFn)
            Bot("sendMessage",{"chat_id":chatID,"text":r.remallN.format(BY),"reply_to_message_id":message.message_id,"parse_mode":"html"})
            
          if rank == "sudo":
            if isrank(redis,userId,chatID) == "sudos":
              t = IDrank(redis,userId,chatID,r)
              tx = tx+t+","
              remsudos(redis,userId)

            if isrank(redis,userId,chatID) == "creator":
              t = IDrank(redis,userId,chatID,r)
              tx = tx+t+","
              remrank(redis,"creator",userId,chatID,"one")

            if isrank(redis,userId,chatID) == "owner":
              t = IDrank(redis,userId,chatID,r)
              tx = tx+t+","
              remrank(redis,"owner",userId,chatID,"array")

            if isrank(redis,userId,chatID) == "admin":
              t = IDrank(redis,userId,chatID,r)
              tx = tx+t+","
              remrank(redis,"admin",userId,chatID,"array")
            if isrank(redis,userId,chatID) == "vip":
              t = IDrank(redis,userId,chatID,r)
              tx = tx+t+","
              remrank(redis,"vip",userId,chatID,"array")
            
          if rank == "sudos":

            if isrank(redis,userId,chatID) == "creator":
              t = IDrank(redis,userId,chatID,r)
              tx = tx+t+","
              remrank(redis,"creator",userId,chatID,"one")

            if isrank(redis,userId,chatID) == "owner":
              t = IDrank(redis,userId,chatID,r)
              tx = tx+t+","
              remrank(redis,"owner",userId,chatID,"array")

            if isrank(redis,userId,chatID) == "admin":
              t = IDrank(redis,userId,chatID,r)
              tx = tx+t+","
              remrank(redis,"admin",userId,chatID,"array")
            if isrank(redis,userId,chatID) == "vip":
              t = IDrank(redis,userId,chatID,r)
              tx = tx+t+","
              remrank(redis,"vip",userId,chatID,"array")
            
          if rank == "creator":
            if isrank(redis,userId,chatID) == "owner":
              t = IDrank(redis,userId,chatID,r)
              tx = tx+t+","
              remrank(redis,"owner",userId,chatID,"array")
            if isrank(redis,userId,chatID) == "admin":
              t = IDrank(redis,userId,chatID,r)
              tx = tx+t+","
              remrank(redis,"admin",userId,chatID,"array")
            if isrank(redis,userId,chatID) == "vip":
              t = IDrank(redis,userId,chatID,r)
              tx = tx+t+","
              remrank(redis,"vip",userId,chatID,"array")
            
          if rank == "owner":
            if isrank(redis,userId,chatID) == "admin":
              t = IDrank(redis,userId,chatID,r)
              tx = tx+t+","
              remrank(redis,"admin",userId,chatID,"array")
            if isrank(redis,userId,chatID) == "vip":
              t = IDrank(redis,userId,chatID,r)
              tx = tx+t+","
              remrank(redis,"vip",userId,chatID,"array")


          if (rank == "owner" or rank == "creator" or rank == "sudos" or rank == "sudo") and (Rank != False or Rank != 0):
            BY = "<a href=\"tg://user?id={}\">{}</a>".format(userId,userFn)
            Bot("sendMessage",{"chat_id":chatID,"text":r.remall.format(BY,tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})



        except Exception as e:
          Bot("sendMessage",{"chat_id":chatID,"text":r.userNocc,"reply_to_message_id":message.message_id,"parse_mode":"html"})
      if re.search(c.floodset, text):
        if redis.hexists("{}Nbot:floodset".format(BOT_ID),chatID):
          get = redis.hget("{}Nbot:floodset".format(BOT_ID),chatID)
        else:
          get = "res"
        if get == "ban":
          tx = r.Tban
        if get == "res":
          tx =  r.Tres
        kb = InlineKeyboardMarkup([[InlineKeyboardButton(r.fset.format(tx),callback_data=json.dumps(["floodset",get,userID]))]])
        Bot("sendMessage",{"chat_id":chatID,"text":r.Tfset,"reply_to_message_id":message.message_id,"parse_mode":"html","reply_markup":kb})

      if re.search(c.twostepset, text):
        if redis.hexists("{}Nbot:bancheck:t".format(BOT_ID),chatID):
          get = redis.hget("{}Nbot:bancheck:t".format(BOT_ID),chatID)
        else:
          get = "eq"
        if get == "eq":
          tx = r.Teq
        if get == "two":
          tx =  r.Ttwo
        kb = InlineKeyboardMarkup([[InlineKeyboardButton(r.tset.format(tx),callback_data=json.dumps(["twostepset",get,userID]))]])
        Bot("sendMessage",{"chat_id":chatID,"text":r.Ttset,"reply_to_message_id":message.message_id,"parse_mode":"html","reply_markup":kb})

      if re.search(c.delIDC, text):
        redis.hdel("{}Nbot:SHOWid".format(BOT_ID),chatID)
        Bot("sendMessage",{"chat_id":chatID,"text":r.Ddelid,"reply_to_message_id":message.message_id,"parse_mode":"html"})
      if re.search("^تعين ايدي$|^تعين ايدي (.*)$|^وضع ايدي$|^وضع ايدي (.*)$",text):
        message.reply_text("""⚠️꒐ يمكنك تغير الايدي بأرسال
⏺꒐ `تعين الايدي النص`

🔽꒐ ويمكنك ايضاً اضافه
{id} - لعرض الايدي
{us} - لعرض المعرف
{rk} - لعرض الرتبه
{msgs} - لعرض عدد الرسائل
{edits} - لعرض عدد السحكات
{rate} - لعرض نسبه التفاعل
⎯ ⎯ ⎯ ⎯""")
      if re.search("^اضف رد$",text):
        message.reply_text(  
"""⚠️꒐ يمكنك اضف رد  بأرسال
⏺꒐ `اضف رد النص`

🔽꒐ ويمكنك ايضاً اضافه html

<b>bold</b>
*bold*

<i>italic</i>
__italic__

<a href=\"https://t.me/mdddd/\">Mohammed</a>
[Mohammed](https://t.me/mdddd/)

<code>inline fixed-width code</code>
`inline fixed-width code`
⎯ ⎯ ⎯ ⎯""",parse_mode="markdown",disable_web_page_preview=True)
      if re.search(c.setIDC, text):
          tx = text.replace(c.RsetIDC,"")
          t = IDrank(redis,userID,chatID,r)
          msgs = (redis.hget("{}Nbot:{}:msgs".format(BOT_ID,chatID),userID) or 0)
          edits = (redis.hget("{}Nbot:{}:edits".format(BOT_ID,chatID),userID) or 0)
          rate = int(msgs)*100/20000
          age = getAge(userID,r)
          v = Bot("sendMessage",{"chat_id":chatID,"text":tx.format(us=("@"+username or "None"),id=userID,rk=t,msgs=msgs,edits=edits,age=age,rate=str(rate)+"%"),"reply_to_message_id":message.message_id,"parse_mode":"html"})
          if v["ok"]:
            redis.hset("{}Nbot:SHOWid".format(BOT_ID),chatID,tx)
            Bot("sendMessage",{"chat_id":chatID,"text":r.DsetIDShow,"reply_to_message_id":message.message_id,"parse_mode":"html"})
          elif v["ok"] == False:
            Bot("sendMessage",{"chat_id":chatID,"text":r.DsetSudosShowE,"reply_to_message_id":message.message_id,"parse_mode":"html"})

      if re.search(c.block, text):
        if re.search(c.block2, text):
          tx = text.replace(c.RPbk,"")
          if redis.sismember("{}Nbot:{}:blockTEXTs".format(BOT_ID,chatID),tx):
            Bot("sendMessage",{"chat_id":chatID,"text":r.Adoneblock.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})
          else:
            redis.sadd("{}Nbot:{}:blockTEXTs".format(BOT_ID,chatID),tx)
            Bot("sendMessage",{"chat_id":chatID,"text":r.Doneblock.format(tx,title),"reply_to_message_id":message.message_id,"parse_mode":"html"})

        if message.reply_to_message:
          if message.reply_to_message.sticker:
            ID = message.reply_to_message.sticker.file_id
            if redis.sismember("{}Nbot:{}:blockSTICKERs".format(BOT_ID,chatID),ID):
              Bot("sendMessage",{"chat_id":chatID,"text":r.StA.format(title),"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html"})
            else:
              redis.sadd("{}Nbot:{}:blockSTICKERs".format(BOT_ID,chatID),ID)
              Bot("sendMessage",{"chat_id":chatID,"text":r.StB.format(title),"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html"})
          
          if message.reply_to_message.photo:
            ID = message.reply_to_message.photo.file_id
            if redis.sismember("{}Nbot:{}:blockphotos".format(BOT_ID,chatID),ID):
              Bot("sendMessage",{"chat_id":chatID,"text":r.PhA.format(title),"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html"})
            else:
              redis.sadd("{}Nbot:{}:blockphotos".format(BOT_ID,chatID),ID)
              Bot("sendMessage",{"chat_id":chatID,"text":r.PhB.format(title),"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html"})
          
          if message.reply_to_message.animation:
            ID = message.reply_to_message.animation.file_id
            if redis.sismember("{}Nbot:{}:blockanimations".format(BOT_ID,chatID),ID):
              Bot("sendMessage",{"chat_id":chatID,"text":r.GfA.format(title),"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html"})
            else:
              redis.sadd("{}Nbot:{}:blockanimations".format(BOT_ID,chatID),ID)
              Bot("sendMessage",{"chat_id":chatID,"text":r.GfB.format(title),"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html"})

      if re.search(c.unblock, text):
        if re.search(c.unblock2, text):
          tx = text.replace(c.RPubk,"")
          if redis.sismember("{}Nbot:{}:blockTEXTs".format(BOT_ID,chatID),tx):
            redis.srem("{}Nbot:{}:blockTEXTs".format(BOT_ID,chatID),tx)
            Bot("sendMessage",{"chat_id":chatID,"text":r.unDoneblock.format(tx,title),"reply_to_message_id":message.message_id,"parse_mode":"html"})
          else:
            Bot("sendMessage",{"chat_id":chatID,"text":r.unAdoneblock.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})

        if message.reply_to_message:
          if message.reply_to_message.sticker:
            ID = message.reply_to_message.sticker.file_id
            if redis.sismember("{}Nbot:{}:blockSTICKERs".format(BOT_ID,chatID),ID):
              redis.srem("{}Nbot:{}:blockSTICKERs".format(BOT_ID,chatID),ID)
              Bot("sendMessage",{"chat_id":chatID,"text":r.unStB.format(title),"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html"})
            else:
              Bot("sendMessage",{"chat_id":chatID,"text":r.unStA.format(title),"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html"})

          if message.reply_to_message.photo:
            ID = message.reply_to_message.photo.file_id
            if redis.sismember("{}Nbot:{}:blockphotos".format(BOT_ID,chatID),ID):
              redis.srem("{}Nbot:{}:blockphotos".format(BOT_ID,chatID),ID)
              Bot("sendMessage",{"chat_id":chatID,"text":r.unPhB.format(title),"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html"})       
            else:
              Bot("sendMessage",{"chat_id":chatID,"text":r.unPhA.format(title),"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html"})
          
          if message.reply_to_message.animation:
            ID = message.reply_to_message.animation.file_id
            if redis.sismember("{}Nbot:{}:blockanimations".format(BOT_ID,chatID),ID):
              redis.srem("{}Nbot:{}:blockanimations".format(BOT_ID,chatID),ID)
              Bot("sendMessage",{"chat_id":chatID,"text":r.unGfB.format(title),"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html"})
            else:
              Bot("sendMessage",{"chat_id":chatID,"text":r.unGfA.format(title),"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html"})

      if re.search(c.Blocklist, text):
        Botuser = client.get_me().username
        reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(c.STword,url="https://telegram.me/{}?start=showBlocklist={}={}={}".format(Botuser,chatID,userID,"blockTEXTs")),InlineKeyboardButton(c.STgifs,url="https://telegram.me/{}?start=showBlocklist={}={}={}".format(Botuser,chatID,userID,"blockanimations")),],[InlineKeyboardButton(c.STphoto,url="https://telegram.me/{}?start=showBlocklist={}={}={}".format(Botuser,chatID,userID,"blockphotos")),InlineKeyboardButton(c.STsticker,url="https://telegram.me/{}?start=showBlocklist={}={}={}".format(Botuser,chatID,userID,"blockSTICKERs")),]])
        Bot("sendMessage",{"chat_id":chatID,"text":r.blocklist.format(r.blocklist2,title),"reply_to_message_id":message.message_id,"reply_markup":reply_markup})

      if re.search(c.Replylist, text):
        reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(c.STword,callback_data=json.dumps(["showreplylist","",userID])),InlineKeyboardButton(c.STgifs,callback_data=json.dumps(["showGFreplylist","",userID])),],[InlineKeyboardButton(c.STvoice,callback_data=json.dumps(["showVOreplylist","",userID])),InlineKeyboardButton(c.STsticker,callback_data=json.dumps(["showSTreplylist","",userID])),]])
        Bot("sendMessage",{"chat_id":chatID,"text":r.blocklist.format(text,title),"reply_to_message_id":message.message_id,"reply_markup":reply_markup})

      if re.search(c.FloodT, text):
        Nu = text.split(" ")[2]
        redis.hset("{}Nbot:time_ck".format(BOT_ID),chatID,Nu)
        Bot("sendMessage",{"chat_id":chatID,"text":r.DoneSet.format(text.split(" ")[0]+" "+text.split(" ")[1],Nu),"reply_to_message_id":message.message_id,"parse_mode":"html"})

      if re.search(c.FloodM, text):
        Nu = text.split(" ")[2]
        redis.hset("{}Nbot:max_msg".format(BOT_ID),chatID,Nu)
        Bot("sendMessage",{"chat_id":chatID,"text":r.DoneSet.format(text.split(" ")[0]+" "+text.split(" ")[1],Nu),"reply_to_message_id":message.message_id,"parse_mode":"html"})

      if re.search(c.STWEL, text):
        Wc = text.replace(c.RPwel,"")
        redis.hset("{}Nbot:welcome".format(BOT_ID),chatID,Wc)
        Bot("sendMessage",{"chat_id":chatID,"text":r.Donewel.format(Wc),"reply_to_message_id":message.message_id,"parse_mode":"html"})


      if re.search(c.STreply, text):
        tx = text.replace(c.RPreply,"")
        if redis.hexists("{}Nbot:{}:TXreplys".format(BOT_ID,chatID),tx):
          Bot("sendMessage",{"chat_id":chatID,"text":r.Yrp.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})
        elif redis.hexists("{}Nbot:{}:STreplys".format(BOT_ID,chatID),tx):
          Bot("sendMessage",{"chat_id":chatID,"text":r.Yrp.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})
        elif redis.hexists("{}Nbot:{}:GFreplys".format(BOT_ID,chatID),tx):
          Bot("sendMessage",{"chat_id":chatID,"text":r.Yrp.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})
        elif redis.hexists("{}Nbot:{}:VOreplys".format(BOT_ID,chatID),tx):
          Bot("sendMessage",{"chat_id":chatID,"text":r.Yrp.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})
        else:
          redis.hset("{}Nbot:step".format(BOT_ID),userID,tx)
          kb = InlineKeyboardMarkup([[InlineKeyboardButton(r.MoreInfo, url="t.me/nbbot")]])
          Bot("sendMessage",{"chat_id":chatID,"text":r.Sendreply % tx,"reply_to_message_id":message.message_id,"parse_mode":"html","reply_markup":kb})

      if re.search(c.DLreply, text):
        tx = text.replace(c.RPdreply,"")
        if redis.hexists("{}Nbot:{}:TXreplys".format(BOT_ID,chatID),tx):
          redis.hdel("{}Nbot:{}:TXreplys".format(BOT_ID,chatID),tx)
          Bot("sendMessage",{"chat_id":chatID,"text":r.Drp.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})
        elif redis.hexists("{}Nbot:{}:STreplys".format(BOT_ID,chatID),tx):
          redis.hdel("{}Nbot:{}:STreplys".format(BOT_ID,chatID),tx)
          Bot("sendMessage",{"chat_id":chatID,"text":r.Drp.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})
        elif redis.hexists("{}Nbot:{}:GFreplys".format(BOT_ID,chatID),tx):
          redis.hdel("{}Nbot:{}:GFreplys".format(BOT_ID,chatID),tx)
          Bot("sendMessage",{"chat_id":chatID,"text":r.Drp.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})
        elif redis.hexists("{}Nbot:{}:VOreplys".format(BOT_ID,chatID),tx):
          redis.hdel("{}Nbot:{}:GFreplys".format(BOT_ID,chatID),tx)
          Bot("sendMessage",{"chat_id":chatID,"text":r.Drp.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})
        else:
          Bot("sendMessage",{"chat_id":chatID,"text":r.Norp.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})
    if re.search(c.setname, text):
      name = text.replace(c.Dsetname,"")
      Bot("setChatTitle",{"chat_id":chatID,"title":name})
      Bot("sendMessage",{"chat_id":chatID,"text":r.Dsetname.format(name),"reply_to_message_id":message.message_id,"parse_mode":"html"})

    if re.search(c.setabout, text):
      about = text.replace(c.Dsetabout,"")
      Bot("setChatDescription",{"chat_id":chatID,"description":about})
      Bot("sendMessage",{"chat_id":chatID,"text":r.Dsetabout.format(about),"reply_to_message_id":message.message_id,"parse_mode":"html"})

    if re.search(c.setphoto, text) and message.reply_to_message and message.reply_to_message.photo:
      ID = message.reply_to_message.photo.file_id
      client.set_chat_photo(chat_id=chatID,photo=ID)
      Bot("sendMessage",{"chat_id":chatID,"text":r.Dsetphoto,"reply_to_message_id":message.message_id,"parse_mode":"html"})
    
    if re.search(c.pinmsg, text) and message.reply_to_message:
      if not redis.sismember("{}Nbot:Lpin".format(BOT_ID),chatID):
        ID = message.reply_to_message.message_id
        Bot("pinChatMessage",{"chat_id":chatID,"message_id":ID})
        redis.hset("{}Nbot:pinmsgs".format(BOT_ID),chatID,ID)
        Bot("sendMessage",{"chat_id":chatID,"text":r.Dpinmsg,"reply_to_message_id":message.message_id,"parse_mode":"html"})
      elif redis.sismember("{}Nbot:Lpin".format(BOT_ID),chatID) and rank == "creator":
        ID = message.reply_to_message.message_id
        Bot("pinChatMessage",{"chat_id":chatID,"message_id":ID})
        redis.hset("{}Nbot:pinmsgs".format(BOT_ID),chatID,ID)
        Bot("sendMessage",{"chat_id":chatID,"text":r.Dpinmsg,"reply_to_message_id":message.message_id,"parse_mode":"html"})

      if re.search(c.unpinmsg, text):
        if not redis.sismember("{}Nbot:Lpin".format(BOT_ID),chatID):
          Bot("unpinChatMessage",{"chat_id":chatID,"message_id":ID})
          Bot("sendMessage",{"chat_id":chatID,"text":r.Dunpinmsg,"reply_to_message_id":message.message_id,"parse_mode":"html"})
        if redis.sismember("{}Nbot:Lpin".format(BOT_ID),chatID) and rank == "creator":
          Bot("unpinChatMessage",{"chat_id":chatID,"message_id":ID})
          Bot("sendMessage",{"chat_id":chatID,"text":r.Dunpinmsg,"reply_to_message_id":message.message_id,"parse_mode":"html"})
      
    if re.search(c.SETlink, text):
      lk = text.replace(c.RPlink,"")
      redis.hset("{}Nbot:links".format(BOT_ID),chatID,lk)
      Bot("sendMessage",{"chat_id":chatID,"text":r.Dsetlk.format(lk),"reply_to_message_id":message.message_id,"parse_mode":"html","disable_web_page_preview":True})

#cre
    if rank != "admin" and rank != "owner":
      if re.search(c.deletebots, text):
        bots = [x for x in client.iter_chat_members(chatID,filter="bots") if x.user.is_bot and x.user.id !=int(BOT_ID) and x.status != "administrator"]
        if bots:
          Bot("sendMessage",{"chat_id":chatID,"text":r.LenBots.format(len(bots)),"reply_to_message_id":message.message_id,"parse_mode":"html"})
          for u in bots:
            Bot("kickChatMember",{"chat_id":chatID,"user_id":u.user.id,"until_date":int(time.time() + 60)})
            time.sleep(0.3)
        else:
          Bot("sendMessage",{"chat_id":chatID,"text":r.NoBots,"reply_to_message_id":message.message_id,"parse_mode":"html"})
      
      if re.search(c.deletebans, text):
        kicked = [x for x in client.iter_chat_members(chatID,filter="kicked")]
        if kicked:
          Bot("sendMessage",{"chat_id":chatID,"text":r.Lenbans.format(len(kicked)),"reply_to_message_id":message.message_id,"parse_mode":"html"})
          for u in kicked:
            Bot("unbanChatMember",{"chat_id":chatID,"user_id":u.user.id})
            redis.srem("{}Nbot:{}:bans".format(BOT_ID,chatID),u.user.id)
            time.sleep(0.3)
        else:
          Bot("sendMessage",{"chat_id":chatID,"text":r.NobansC,"reply_to_message_id":message.message_id,"parse_mode":"html"})
      

      if re.search(c.deleterks, text):
        restricted = [x for x in client.iter_chat_members(chatID,filter="restricted")]
        if restricted:
          Bot("sendMessage",{"chat_id":chatID,"text":r.Lenrks.format(len(restricted)),"reply_to_message_id":message.message_id,"parse_mode":"html"})
          for u in restricted:
            Bot("restrictChatMember",{"chat_id": chatID,"user_id": userId,"can_send_messages": 1,"can_send_media_messages": 1,"can_send_other_messages": 1,"can_send_polls": 1,
          "can_change_info": 1,"can_add_web_page_previews": 1,"can_pin_messages": 1,"can_invite_users": 1,})
            redis.srem("{}Nbot:{}:restricteds".format(BOT_ID,chatID),u.user.id)
            time.sleep(0.3)
        else:
          Bot("sendMessage",{"chat_id":chatID,"text":r.NorksC,"reply_to_message_id":message.message_id,"parse_mode":"html"})
        
      if re.search(c.deleteDeleted, text):
        deleted = [x for x in client.iter_chat_members(chatID) if x.user.is_deleted]
        if deleted:
          Bot("sendMessage",{"chat_id":chatID,"text":r.LenDeleted.format(len(deleted)),"reply_to_message_id":message.message_id,"parse_mode":"html"})
          for u in deleted:
            Bot("kickChatMember",{"chat_id":chatID,"user_id":u.user.id,"until_date":int(time.time() + 60)})
            time.sleep(0.3)
        else:
          Bot("sendMessage",{"chat_id":chatID,"text":r.NoDeleted,"reply_to_message_id":message.message_id,"parse_mode":"html"})
      
      if re.search(c.delmsgs, text):
              lim = text.split(" ")[1]
              ids = []
              if message.reply_to_message:
                nu = message.reply_to_message.message_id
                ids.append(message.message_id)
              elif message.message_id:
                nu = message.message_id
              for i in range(int(lim)):
                ids.append(nu-i)
              client.delete_messages(chatID, ids)
              #print(ids)

      if re.search(c.tagall, text):
        tagall = [x for x in client.iter_chat_members(chatID)]
        if tagall:
          listTag = ""
          i = 1
          for u in tagall:
            if u.user.username:
              listTag = listTag+"\n"+str(i)+" - [@{}]".format(u.user.username)
            else:
              listTag = listTag+"\n"+str(i)+" - [{}](tg://user?id={})".format(u.user.first_name,u.user.id)
            i += 1 
          sendM("NO",listTag,message)
          
      if re.search(c.Chlang, text):
        Bot("sendMessage",{"chat_id":chatID,"text":r.Chlang,"reply_to_message_id":message.message_id,"parse_mode":"html","reply_markup":Clang(client, message,redis,r)})
      if re.search(c.PROadmins, text):
        ads = Bot("getChatAdministrators",{"chat_id":chatID})
        for ad in ads['result']:
          userId = ad["user"]["id"]
          userFn = ad["user"]["first_name"]
          if ad['status'] == "administrator" and int(userId) != int(BOT_ID):
            setrank(redis,"admin",userId,chatID,"array")
        Bot("sendMessage",{"chat_id":chatID,"text":r.DPROadmins,"reply_to_message_id":message.message_id,"parse_mode":"html"})
示例#16
0
文件: nf.py 项目: MetalGhost1/NewBot
def nf(client, message, redis):
    type = message.chat.type
    userID = message.from_user.id
    chatID = message.chat.id
    title = message.chat.title
    rank = isrank(redis, userID, chatID)
    text = message.text
    if redis.sismember("{}Nbot:lang:ar".format(BOT_ID), chatID):
        lang = "ar"
    elif redis.sismember("{}Nbot:lang:en".format(BOT_ID), chatID):
        lang = "en"
    else:
        lang = "ar"
    moduleCMD = "lang." + lang + "-cmd"
    moduleREPLY = "lang." + lang + "-reply"
    c = importlib.import_module(moduleCMD)
    r = importlib.import_module(moduleREPLY)
    group = redis.sismember("{}Nbot:groups".format(BOT_ID), chatID)
    rank = isrank(redis, userID, chatID)
    if group is True:

        if message.new_chat_members:

            if (rank is False or rank is 0) and GPranks(
                    userID,
                    chatID) == "member" and message.new_chat_members[0].is_bot:
                if redis.sismember("{}Nbot:Lbots".format(BOT_ID), chatID):  #16
                    first_name = message.new_chat_members[0].first_name
                    username = message.new_chat_members[0].username
                    Bot(
                        "kickChatMember", {
                            "chat_id": chatID,
                            "user_id": message.new_chat_members[0].id
                        })
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.kickbotadd.format(username, first_name),
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "html"
                        })

            if redis.sismember("{}Nbot:Ljoin".format(BOT_ID), chatID):  #17
                Bot("deleteMessage", {
                    "chat_id": chatID,
                    "message_id": message.message_id
                })

            if redis.sismember("{}Nbot:Lpin".format(BOT_ID),
                               chatID) and rank != "creator":
                ID = redis.hget("{}Nbot:pinmsgs".format(BOT_ID), chatID)
                Bot("pinChatMessage", {"chat_id": chatID, "message_id": ID})

            if message.new_chat_members and not redis.sismember(
                    "{}Nbot:welcomeSend".format(BOT_ID), chatID):
                wl = (redis.hget("{}Nbot:welcome".format(BOT_ID), chatID)
                      or "")
                userId = message.new_chat_members[0].id
                userFn = message.new_chat_members[0].first_name
                T = "<a href=\"tg://user?id={}\">{}</a>".format(
                    userId, Name(userFn))
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": wl.format(us=T),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html"
                    })

            if message.new_chat_members:
                userId = message.new_chat_members[0].id
                if userID != userId:
                    redis.hincrby(
                        "{}Nbot:{}:addcontact".format(BOT_ID, chatID), userID)

            if message.pinned_message:
                if redis.sismember("{}Nbot:Lpin".format(BOT_ID),
                                   chatID) and rank != "creator":
                    ID = redis.hget("{}Nbot:pinmsgs".format(BOT_ID), chatID)
                    Bot("pinChatMessage", {
                        "chat_id": chatID,
                        "message_id": ID
                    })

            if message.new_chat_members:
                chatID = message.chat.id
                userId = message.new_chat_members[0].id
                if redis.sismember("{}Nbot:restricteds".format(BOT_ID),
                                   userId):
                    Bot(
                        "restrictChatMember", {
                            "chat_id": chatID,
                            "user_id": userId,
                            "can_send_messages": 0,
                            "can_send_media_messages": 0,
                            "can_send_other_messages": 0,
                            "can_send_polls": 0,
                            "can_change_info": 0,
                            "can_add_web_page_previews": 0,
                            "can_pin_messages": 0,
                        })
                if redis.sismember("{}Nbot:bans".format(BOT_ID), userId):
                    Bot("kickChatMember", {
                        "chat_id": chatID,
                        "user_id": userId
                    })

        if message.left_chat_member:
            if message.left_chat_member.id == int(BOT_ID):
                redis.srem("{}Nbot:groups".format(BOT_ID), chatID)
                redis.sadd("{}Nbot:disabledgroups".format(BOT_ID), chatID)
                NextDay_Date = datetime.datetime.today() + datetime.timedelta(
                    days=1)
                redis.hset("{}Nbot:disabledgroupsTIME".format(BOT_ID), chatID,
                           str(NextDay_Date))
示例#17
0
文件: nf.py 项目: NewBotMD/NB
def nf(client, message,redis):
  type = message.chat.type
  userID = message.from_user.id
  chatID = message.chat.id
  title = message.chat.title
  rank = isrank(redis,userID,chatID)
  text = message.text
  lang = Glang(redis,chatID)
  moduleCMD = "lang."+lang+"-cmd"
  moduleREPLY = "lang."+lang+"-reply"
  c = importlib.import_module(moduleCMD)
  r = importlib.import_module(moduleREPLY)
  group = redis.sismember("{}Nbot:groups".format(BOT_ID),chatID)
  rank = isrank(redis,userID,chatID)
  if group is True:

    if message.left_chat_member:
      if message.left_chat_member.id == int(BOT_ID):
        redis.srem("{}Nbot:groups".format(BOT_ID),chatID)
        redis.sadd("{}Nbot:disabledgroups".format(BOT_ID),chatID)
        NextDay_Date = datetime.datetime.today() + datetime.timedelta(days=1)
        redis.hset("{}Nbot:disabledgroupsTIME".format(BOT_ID),chatID,str(NextDay_Date))
    if message.pinned_message:
      if redis.sismember("{}Nbot:Lpin".format(BOT_ID),chatID) and rank != "creator":
        ID = redis.hget("{}Nbot:pinmsgs".format(BOT_ID),chatID)
        Bot("pinChatMessage",{"chat_id":chatID,"message_id":ID})
    
    if message.new_chat_members:

      if (rank is False or rank is 0) and GPranks(userID,chatID) == "member" and re.search("is_bot=True",str(message.new_chat_members)):
        if redis.sismember("{}Nbot:Lbots".format(BOT_ID),chatID):
          for mb in message.new_chat_members:
            first_name = mb.first_name
            username = mb.username
            isbot = mb.is_bot
            mbID = mb.id
            if isbot:
              Bot("kickChatMember",{"chat_id":chatID,"user_id":mb.id})

      if message.new_chat_members and redis.sismember("{}Nbot:bancheck".format(BOT_ID),chatID):
        if redis.hget("{}Nbot:bancheck:t".format(BOT_ID),chatID):
          for mb in message.new_chat_members:
            userFn = mb.first_name
            username = mb.username
            isbot = mb.is_bot
            userId = mb.id
            if isbot:return False
            Bot("restrictChatMember",{"chat_id": chatID,"user_id": userId,"can_send_messages": 0,"can_send_media_messages": 0,"can_send_other_messages": 0,
            "can_send_polls": 0,"can_change_info": 0,"can_add_web_page_previews": 0,"can_pin_messages": 0,"can_invite_users": 0,})
            kb = InlineKeyboardMarkup([[InlineKeyboardButton(r.no, callback_data=json.dumps(["kickcheck","",userId])),InlineKeyboardButton(r.yes, callback_data=json.dumps(["delcheck","",userId]))]])
            T ="<a href=\"tg://user?id={}\">{}</a>".format(userId,Name(userFn))
            random.shuffle(kb.inline_keyboard[0])
            Bot("sendMessage",{"chat_id":chatID,"text":r.checkmem.format(T),"reply_to_message_id":message.message_id,"parse_mode":"html","reply_markup":kb})
        else:
          for mb in message.new_chat_members:
            userFn = mb.first_name
            username = mb.username
            isbot = mb.is_bot
            userId = mb.id
            if isbot:return False
            q,aw,r1,r2 = eq()
            Bot("restrictChatMember",{"chat_id": chatID,"user_id": userId,"can_send_messages": 0,"can_send_media_messages": 0,"can_send_other_messages": 0,
            "can_send_polls": 0,"can_change_info": 0,"can_add_web_page_previews": 0,"can_pin_messages": 0,"can_invite_users": 0,})
            kb = InlineKeyboardMarkup([[InlineKeyboardButton(aw, callback_data=json.dumps(["certain","",userId])),InlineKeyboardButton(r1, callback_data=json.dumps(["kickcheck","",userId])),InlineKeyboardButton(r2, callback_data=json.dumps(["kickcheck","",userId]))]])
            random.shuffle(kb.inline_keyboard[0])
            T ="<a href=\"tg://user?id={}\">{}</a>".format(userId,Name(userFn))
            Bot("sendMessage",{"chat_id":chatID,"text":r.checkmem2.format(T,q),"reply_to_message_id":message.message_id,"parse_mode":"html","reply_markup":kb})
  

      if redis.sismember("{}Nbot:Ljoin".format(BOT_ID),chatID):#17
        Bot("deleteMessage",{"chat_id":chatID,"message_id":message.message_id})
        
      if message.new_chat_members and not redis.sismember("{}Nbot:welcomeSend".format(BOT_ID),chatID):
        wl = (redis.hget("{}Nbot:welcome".format(BOT_ID),chatID) or "")
        userId = message.new_chat_members[0].id
        userFn = message.new_chat_members[0].first_name
        T ="<a href=\"tg://user?id={}\">{}</a>".format(userId,Name(userFn))
        Bot("sendMessage",{"chat_id":chatID,"text":wl.format(us=T),"reply_to_message_id":message.message_id,"parse_mode":"html"})
        
      if message.new_chat_members:
        userId = message.new_chat_members[0].id
        if userID != userId:
          redis.hincrby("{}Nbot:{}:addcontact".format(BOT_ID,chatID),userID)

      if message.new_chat_members:
        chatID = message.chat.id
        userId = message.new_chat_members[0].id
        if redis.sismember("{}Nbot:restricteds".format(BOT_ID),userId):
          Bot("restrictChatMember",{"chat_id": chatID,"user_id": userId,"can_send_messages": 0,"can_send_media_messages": 0,"can_send_other_messages": 0,
            "can_send_polls": 0,"can_change_info": 0,"can_add_web_page_previews": 0,"can_pin_messages": 0,"can_invite_users": 0,})
        if redis.sismember("{}Nbot:bans".format(BOT_ID),userId):
          Bot("kickChatMember",{"chat_id":chatID,"user_id":userId})
示例#18
0
文件: locks.py 项目: Medo-X/Nitro
def st_res(client, message, redis, type=1):
    userID = message.from_user.id
    if (hasattr(message, "chat")):
        chatID = message.chat.id
    else:
        chatID = message.message.chat.id
    #print("vvvvvvvvvvvvvvv",chatID)
    rank = isrank(redis, userID, chatID)

    lang = Glang(redis, chatID)
    moduleCMD = "lang." + lang + "-cmd"
    moduleREPLY = "lang." + lang + "-reply"
    c = importlib.import_module(moduleCMD)
    r = importlib.import_module(moduleREPLY)
    if redis.sismember("{}Nbot:Llink:res".format(BOT_ID), chatID):
        link = c.STlink + " " + r.false2
    else:
        link = c.STlink + " " + r.true2

    if redis.sismember("{}Nbot:Lusername:res".format(BOT_ID), chatID):  #2
        username = c.STusername + " " + r.false2
    else:
        username = c.STusername + " " + r.true2

    if redis.sismember("{}Nbot:Ltag:res".format(BOT_ID), chatID):  #3
        tag = c.STtag + " " + r.false2
    else:
        tag = c.STtag + " " + r.true2

    if redis.sismember("{}Nbot:Lenglish:res".format(BOT_ID), chatID):  #4
        english = c.STenglish + " " + r.false2
    else:
        english = c.STenglish + " " + r.true2

    if redis.sismember("{}Nbot:Larabic:res".format(BOT_ID), chatID):  #5
        arabic = c.STarabic + " " + r.false2
    else:
        arabic = c.STarabic + " " + r.true2

    if redis.sismember("{}Nbot:Lmarkdown:res".format(BOT_ID), chatID):  #6
        markdown = c.STmarkdown + " " + r.false2
    else:
        markdown = c.STmarkdown + " " + r.true2

    if redis.sismember("{}Nbot:Linline:res".format(BOT_ID), chatID):  #7
        inline = c.STinline + " " + r.false2
    else:
        inline = c.STinline + " " + r.true2

    if redis.sismember("{}Nbot:Lsticker:res".format(BOT_ID), chatID):  #8
        sticker = c.STsticker + " " + r.false2
    else:
        sticker = c.STsticker + " " + r.true2

    if redis.sismember("{}Nbot:Lgifs:res".format(BOT_ID), chatID):  #9
        gifs = c.STgifs + " " + r.false2
    else:
        gifs = c.STgifs + " " + r.true2

    if redis.sismember("{}Nbot:Lvideo:res".format(BOT_ID), chatID):  #10
        video = c.STvideo + " " + r.false2
    else:
        video = c.STvideo + " " + r.true2

    if redis.sismember("{}Nbot:Lvoice:res".format(BOT_ID), chatID):  #11
        voice = c.STvoice + " " + r.false2
    else:
        voice = c.STvoice + " " + r.true2

    if redis.sismember("{}Nbot:Lmusic:res".format(BOT_ID), chatID):  #12
        music = c.STmusic + " " + r.false2
    else:
        music = c.STmusic + " " + r.true2

    if redis.sismember("{}Nbot:Lfiles:res".format(BOT_ID), chatID):  #13
        files = c.STfiles + " " + r.false2
    else:
        files = c.STfiles + " " + r.true2

    if redis.sismember("{}Nbot:Lphoto:res".format(BOT_ID), chatID):  #14
        photo = c.STphoto + " " + r.false2
    else:
        photo = c.STphoto + " " + r.true2

    if redis.sismember("{}Nbot:Lcontact:res".format(BOT_ID), chatID):  #15
        contact = c.STcontact + " " + r.false2
    else:
        contact = c.STcontact + " " + r.true2

    if redis.sismember("{}Nbot:Lbots:res".format(BOT_ID), chatID):  #16
        bots = c.STbots + " " + r.false2
    else:
        bots = c.STbots + " " + r.true2

    if redis.sismember("{}Nbot:Lfwd:res".format(BOT_ID), chatID):  #18
        fwd = c.STfwd + " " + r.false2
    else:
        fwd = c.STfwd + " " + r.true2

    if redis.sismember("{}Nbot:Lnote:res".format(BOT_ID), chatID):  #19
        note = c.STnote + " " + r.false2
    else:
        note = c.STnote + " " + r.true2
    if redis.sismember("{}Nbot:Ledits:res".format(BOT_ID), chatID):  #19
        edits = c.STedits + " " + r.false2
    else:
        edits = c.STedits + " " + r.true2
    if redis.sismember("{}Nbot:Llongtext:res".format(BOT_ID), chatID):  #19
        longtext = c.STlongtext + " " + r.false2
    else:
        longtext = c.STlongtext + " " + r.true2

    if type == 1:
        reply_markup = InlineKeyboardMarkup([
            [
                InlineKeyboardButton(link,
                                     callback_data=json.dumps(
                                         ["LU-res", "Llink-res", userID, 1])),
                InlineKeyboardButton(bots,
                                     callback_data=json.dumps(
                                         ["LU-res", "Lbots-res", userID, 1])),
            ],
            [
                InlineKeyboardButton(video,
                                     callback_data=json.dumps(
                                         ["LU-res", "Lvideo-res", userID, 1])),
                InlineKeyboardButton(note,
                                     callback_data=json.dumps(
                                         ["LU-res", "Lnote-res", userID, 1])),
            ],
            [
                InlineKeyboardButton(music,
                                     callback_data=json.dumps(
                                         ["LU-res", "Lmusic-res", userID, 1])),
                InlineKeyboardButton(voice,
                                     callback_data=json.dumps(
                                         ["LU-res", "Lvoice-res", userID, 1]))
            ],
            [
                InlineKeyboardButton(gifs,
                                     callback_data=json.dumps(
                                         ["LU-res", "Lgifs-res", userID, 1])),
                InlineKeyboardButton(photo,
                                     callback_data=json.dumps(
                                         ["LU-res", "Lphoto-res", userID, 1])),
            ],
            [
                InlineKeyboardButton(r.hide,
                                     callback_data=json.dumps(
                                         ["delmsgclick", "", userID])),
                InlineKeyboardButton(r.fr,
                                     callback_data=json.dumps(
                                         ["listCH-res", 2, userID])),
            ]
        ])

    if type == 2:
        reply_markup = InlineKeyboardMarkup(
            [[
                InlineKeyboardButton(inline,
                                     callback_data=json.dumps(
                                         ["LU-res", "Linline-res", userID,
                                          2])),
                InlineKeyboardButton(markdown,
                                     callback_data=json.dumps([
                                         "LU-res", "Lmarkdown-res", userID, 2
                                     ])),
            ],
             [
                 InlineKeyboardButton(files,
                                      callback_data=json.dumps(
                                          ["LU-res", "Lfiles-res", userID,
                                           2])),
                 InlineKeyboardButton(contact,
                                      callback_data=json.dumps([
                                          "LU-res", "Lcontact-res", userID, 2
                                      ])),
             ],
             [
                 InlineKeyboardButton(sticker,
                                      callback_data=json.dumps([
                                          "LU-res", "Lsticker-res", userID, 2
                                      ])),
                 InlineKeyboardButton(fwd,
                                      callback_data=json.dumps(
                                          ["LU-res", "Lfwd-res", userID, 2])),
             ],
             [
                 InlineKeyboardButton(username,
                                      callback_data=json.dumps([
                                          "LU-res", "Lusername-res", userID, 2
                                      ])),
                 InlineKeyboardButton(english,
                                      callback_data=json.dumps([
                                          "LU-res", "Lenglish-res", userID, 2
                                      ])),
             ],
             [
                 InlineKeyboardButton(r.pk,
                                      callback_data=json.dumps(
                                          ["listCH-res", 1, userID])),
                 InlineKeyboardButton(r.hide,
                                      callback_data=json.dumps(
                                          ["delmsgclick", "", userID])),
                 InlineKeyboardButton(r.fr,
                                      callback_data=json.dumps(
                                          ["listCH-res", 3, userID])),
             ]])

    if type == 3:

        reply_markup = InlineKeyboardMarkup(
            [[
                InlineKeyboardButton(arabic,
                                     callback_data=json.dumps(
                                         ["LU-res", "Larabic-res", userID,
                                          3])),
                InlineKeyboardButton(tag,
                                     callback_data=json.dumps(
                                         ["LU-res", "Ltag-res", userID, 3])),
            ],
             [
                 InlineKeyboardButton(longtext,
                                      callback_data=json.dumps([
                                          "LU-res", "Llongtext-res", userID, 3
                                      ])),
             ],
             [
                 InlineKeyboardButton(r.pk,
                                      callback_data=json.dumps(
                                          ["listCH-res", 2, userID])),
                 InlineKeyboardButton(r.hide,
                                      callback_data=json.dumps(
                                          ["delmsgclick", "", userID])),
             ]])

    return reply_markup
示例#19
0
def gpcmd(client, message, redis):
    type = message.chat.type
    userID = message.from_user.id
    chatID = message.chat.id
    title = message.chat.title
    rank = isrank(redis, userID, chatID)
    text = message.text
    username = message.from_user.username
    if username is None:
        username = "******"
    if redis.sismember("{}Nbot:lang:ar".format(BOT_ID), chatID):
        lang = "ar"
    elif redis.sismember("{}Nbot:lang:en".format(BOT_ID), chatID):
        lang = "en"
    else:
        lang = "ar"
    moduleCMD = "lang." + lang + "-cmd"
    moduleREPLY = "lang." + lang + "-reply"
    c = importlib.import_module(moduleCMD)
    r = importlib.import_module(moduleREPLY)
    #steps
    if redis.hexists("{}Nbot:step".format(BOT_ID), userID):
        tx = redis.hget("{}Nbot:step".format(BOT_ID), userID)
        if text:
            redis.hset("{}Nbot:{}:TXreplys".format(BOT_ID, chatID), tx, text)
            redis.hdel("{}Nbot:step".format(BOT_ID), userID)
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": r.SRtext.format(tx),
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html"
                })

        if message.sticker:
            ID = message.sticker.file_id
            redis.hset("{}Nbot:{}:STreplys".format(BOT_ID, chatID), tx, ID)
            redis.hdel("{}Nbot:step".format(BOT_ID), userID)
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": r.SRst.format(tx),
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html"
                })

        if message.animation:
            ID = message.animation.file_id
            redis.hset("{}Nbot:{}:GFreplys".format(BOT_ID, chatID), tx, ID)
            redis.hdel("{}Nbot:step".format(BOT_ID), userID)
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": r.SRgf.format(tx),
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html"
                })

        if message.voice:
            ID = message.voice.file_id
            redis.hset("{}Nbot:{}:VOreplys".format(BOT_ID, chatID), tx, ID)
            redis.hdel("{}Nbot:step".format(BOT_ID), userID)
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": r.SRvo.format(tx),
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html"
                })


###############
    if text:

        if text == c.settingsCmd and Ckuser(message):
            kb = st(client, message, redis)
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": r.settings.format(title),
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html",
                    "reply_markup": kb
                })

        if re.search(c.bans, text):
            arrays = redis.smembers("{}Nbot:{}:bans".format(BOT_ID, chatID))
            b = BYusers(arrays, chatID, redis, client)
            kb = InlineKeyboardMarkup([[
                InlineKeyboardButton(r.delList.format(text),
                                     callback_data=json.dumps(
                                         ["delListbans", "", userID]))
            ]])
            if b is not "":
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.showlist.format(text, b),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "markdown",
                        "reply_markup": kb
                    })
            else:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.listempty.format(text),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "markdown"
                    })

        if re.search(c.restricteds, text):
            arrays = redis.smembers("{}Nbot:{}:restricteds".format(
                BOT_ID, chatID))
            b = BYusers(arrays, chatID, redis, client)
            kb = InlineKeyboardMarkup([[
                InlineKeyboardButton(r.delList.format(text),
                                     callback_data=json.dumps(
                                         ["delListrestricteds", "", userID]))
            ]])
            if b is not "":
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.showlist.format(text, b),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "markdown",
                        "reply_markup": kb
                    })
            else:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.listempty.format(text),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "markdown"
                    })

        if re.search(c.ban, text):
            if re.search("@", text):
                user = text.split("@")[1]
            if re.search(c.ban2, text):
                user = text.split(" ")[1]
            if message.reply_to_message:
                user = message.reply_to_message.from_user.id
            if 'user' not in locals(): return False
            try:
                getUser = client.get_users(user)
                #print(getUser)
                userId = getUser.id
                userFn = getUser.first_name
                Getrank = isrank(redis, userId, chatID)
                GetGprank = GPranks(userId, chatID)
                if Getrank == "bot": return False
                if GetGprank == "NoMember":
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.NoMember,
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "html"
                        })
                if (GetGprank == "left" or GetGprank == "kicked"):
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.haveKick,
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "html"
                        })
                elif (GetGprank == "member" or GetGprank
                      == "restricted") and (Getrank is False or Getrank is 0):
                    if redis.sismember("{}Nbot:{}:bans".format(BOT_ID, chatID),
                                       userId):
                        send_msg("BNN", client, message, r.Dban, "bans",
                                 getUser, redis)
                    else:
                        Bot("kickChatMember", {
                            "chat_id": chatID,
                            "user_id": userId
                        })
                        redis.sadd("{}Nbot:{}:bans".format(BOT_ID, chatID),
                                   userId)
                        send_msg("BN", client, message, r.ban, "bans", getUser,
                                 redis)
                elif (GetGprank == "creator"
                      or GetGprank == "administrator") or (Getrank != False
                                                           or Getrank != 0):
                    Bot(
                        "sendMessage", {
                            "chat_id":
                            chatID,
                            "text":
                            r.haveRank.format(Grank(
                                (Getrank or GetGprank), r)),
                            "reply_to_message_id":
                            message.message_id,
                            "parse_mode":
                            "html"
                        })
            except Exception as e:
                print("ccc", e)
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.userNocc,
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html"
                    })

        if re.search(c.unban, text):
            if re.search("@", text):
                user = text.split("@")[1]
            if re.search(c.unban2, text):
                user = text.split(" ")[1]
            if message.reply_to_message:
                user = message.reply_to_message.from_user.id
            if 'user' not in locals(): return False
            try:
                getUser = client.get_users(user)
                userId = getUser.id
                userFn = getUser.first_name
                Getrank = isrank(redis, userId, chatID)
                GetGprank = GPranks(userId, chatID)
                if Getrank == "bot": return False
                if GetGprank == "NoMember":
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.NoMember,
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "html"
                        })
                    return False
                if GetGprank == "kicked":
                    Bot("unbanChatMember", {
                        "chat_id": chatID,
                        "user_id": userId
                    })
                    redis.srem("{}Nbot:{}:bans".format(BOT_ID, chatID), userId)
                    send_msg("BN", client, message, r.unban, "bans", getUser,
                             redis)
                else:
                    send_msg("BNN", client, message, r.Dunban, "bans", getUser,
                             redis)
            except Exception as e:
                print(e)
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.userNocc,
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html"
                    })

        if re.search(c.TK, text):
            if re.search("@", text):
                user = text.split("@")[1]
            if re.search(c.TK2, text):
                user = text.split(" ")[1]
            if message.reply_to_message:
                user = message.reply_to_message.from_user.id
            if 'user' not in locals(): return False
            try:
                getUser = client.get_users(user)
                userId = getUser.id
                userFn = getUser.first_name
                Getrank = isrank(redis, userId, chatID)
                GetGprank = GPranks(userId, chatID)
                if Getrank == "bot": return False
                if GetGprank == "NoMember":
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.NoMember,
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "html"
                        })
                if (GetGprank == "left" or GetGprank == "kicked"):
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.haveKick,
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "html"
                        })
                elif (GetGprank == "restricted"):
                    send_msg("BNN", client, message, r.haveRc, "restricteds",
                             getUser, redis)
                    #Bot("sendMessage",{"chat_id":chatID,"text":r.haveRc,"reply_to_message_id":message.message_id,"parse_mode":"html"})
                elif GetGprank == "member" and (Getrank is False
                                                or Getrank is 0):
                    if redis.sismember(
                            "{}Nbot:{}:restricteds".format(BOT_ID, chatID),
                            userId):
                        send_msg("BNN", client, message, r.Drestricted,
                                 "restricteds", getUser, redis)
                    else:
                        Bot(
                            "restrictChatMember", {
                                "chat_id": chatID,
                                "user_id": userId,
                                "can_send_messages": 0,
                                "can_send_media_messages": 0,
                                "can_send_other_messages": 0,
                                "can_send_polls": 0,
                                "can_change_info": 0,
                                "can_add_web_page_previews": 0,
                                "can_pin_messages": 0,
                            })
                        redis.sadd(
                            "{}Nbot:{}:restricteds".format(BOT_ID, chatID),
                            userId)
                        send_msg("BN", client, message, r.restricted,
                                 "restricteds", getUser, redis)
                elif (GetGprank == "creator"
                      or GetGprank == "administrator") or (Getrank != False
                                                           or Getrank != 0):
                    Bot(
                        "sendMessage", {
                            "chat_id":
                            chatID,
                            "text":
                            r.haveRank.format(Grank(
                                (Getrank or GetGprank), r)),
                            "reply_to_message_id":
                            message.message_id,
                            "parse_mode":
                            "html"
                        })
            except Exception as e:
                print(e)
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.userNocc,
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html"
                    })

        if re.search(c.unTK, text):
            if re.search("@", text):
                user = text.split("@")[1]
            if re.search(c.unTK2, text):
                user = text.split(" ")[1]
            if message.reply_to_message:
                user = message.reply_to_message.from_user.id
            if 'user' not in locals(): return False
            try:
                getUser = client.get_users(user)
                userId = getUser.id
                userFn = getUser.first_name
                Getrank = isrank(redis, userId, chatID)
                GetGprank = GPranks(userId, chatID)
                if Getrank == "bot": return False
                if GetGprank == "NoMember":
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.NoMember,
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "html"
                        })
                    return False
                if GetGprank == "restricted":
                    Bot(
                        "restrictChatMember", {
                            "chat_id": chatID,
                            "user_id": userId,
                            "can_send_messages": 1,
                            "can_send_media_messages": 1,
                            "can_send_other_messages": 1,
                            "can_send_polls": 1,
                            "can_change_info": 1,
                            "can_add_web_page_previews": 1,
                            "can_pin_messages": 1,
                        })
                    redis.srem("{}Nbot:{}:restricteds".format(BOT_ID, chatID),
                               userId)
                    send_msg("BN", client, message, r.unrestricted,
                             "restricteds", getUser, redis)
                else:
                    send_msg("BNN", client, message, r.Dunrestricted,
                             "restricteds", getUser, redis)
            except Exception as e:
                print(e)
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.userNocc,
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html"
                    })
        if rank != "admin":
            if re.search(c.delIDC, text):
                redis.hdel("{}Nbot:SHOWid".format(BOT_ID), chatID)
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.Ddelid,
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html"
                    })
            if re.search(c.setIDC, text):
                tx = text.replace(c.RsetIDC, "")
                t = IDrank(redis, userID, chatID, r)
                msgs = (redis.hget("{}Nbot:{}:msgs".format(BOT_ID, chatID),
                                   userID) or 0)
                edits = (redis.hget("{}Nbot:{}:edits".format(BOT_ID, chatID),
                                    userID) or 0)
                rate = int(msgs) * 100 / 20000
                v = Bot(
                    "sendMessage", {
                        "chat_id":
                        chatID,
                        "text":
                        tx.format(us=("@" + username or "None"),
                                  id=userID,
                                  rank=t,
                                  msgs=msgs,
                                  edits=edits,
                                  rate=str(rate) + "%"),
                        "reply_to_message_id":
                        message.message_id,
                        "parse_mode":
                        "html"
                    })
                if v["ok"]:
                    redis.hset("{}Nbot:SHOWid".format(BOT_ID), chatID, tx)
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.DsetIDShow,
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "html"
                        })
                elif v["ok"] == False:
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.DsetSudosShowE,
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "html"
                        })

            if re.search(c.block, text):
                if re.search(c.block2, text):
                    tx = text.replace(c.RPbk, "")
                    if redis.sismember(
                            "{}Nbot:{}:blockTEXTs".format(BOT_ID, chatID), tx):
                        Bot(
                            "sendMessage", {
                                "chat_id": chatID,
                                "text": r.Adoneblock.format(tx),
                                "reply_to_message_id": message.message_id,
                                "parse_mode": "html"
                            })
                    else:
                        redis.sadd(
                            "{}Nbot:{}:blockTEXTs".format(BOT_ID, chatID), tx)
                        Bot(
                            "sendMessage", {
                                "chat_id": chatID,
                                "text": r.Doneblock.format(tx, title),
                                "reply_to_message_id": message.message_id,
                                "parse_mode": "html"
                            })

                if message.reply_to_message:
                    if message.reply_to_message.sticker:
                        ID = message.reply_to_message.sticker.file_id
                        if redis.sismember(
                                "{}Nbot:{}:blockSTICKERs".format(
                                    BOT_ID, chatID), ID):
                            Bot(
                                "sendMessage", {
                                    "chat_id":
                                    chatID,
                                    "text":
                                    r.StA.format(title),
                                    "reply_to_message_id":
                                    message.reply_to_message.message_id,
                                    "parse_mode":
                                    "html"
                                })
                        else:
                            redis.sadd(
                                "{}Nbot:{}:blockSTICKERs".format(
                                    BOT_ID, chatID), ID)
                            Bot(
                                "sendMessage", {
                                    "chat_id":
                                    chatID,
                                    "text":
                                    r.StB.format(title),
                                    "reply_to_message_id":
                                    message.reply_to_message.message_id,
                                    "parse_mode":
                                    "html"
                                })

                    if message.reply_to_message.photo:
                        ID = message.reply_to_message.photo.file_id
                        if redis.sismember(
                                "{}Nbot:{}:blockphotos".format(BOT_ID, chatID),
                                ID):
                            Bot(
                                "sendMessage", {
                                    "chat_id":
                                    chatID,
                                    "text":
                                    r.PhA.format(title),
                                    "reply_to_message_id":
                                    message.reply_to_message.message_id,
                                    "parse_mode":
                                    "html"
                                })
                        else:
                            redis.sadd(
                                "{}Nbot:{}:blockphotos".format(BOT_ID, chatID),
                                ID)
                            Bot(
                                "sendMessage", {
                                    "chat_id":
                                    chatID,
                                    "text":
                                    r.PhB.format(title),
                                    "reply_to_message_id":
                                    message.reply_to_message.message_id,
                                    "parse_mode":
                                    "html"
                                })

                    if message.reply_to_message.animation:
                        ID = message.reply_to_message.animation.file_id
                        if redis.sismember(
                                "{}Nbot:{}:blockanimations".format(
                                    BOT_ID, chatID), ID):
                            Bot(
                                "sendMessage", {
                                    "chat_id":
                                    chatID,
                                    "text":
                                    r.GfA.format(title),
                                    "reply_to_message_id":
                                    message.reply_to_message.message_id,
                                    "parse_mode":
                                    "html"
                                })
                        else:
                            redis.sadd(
                                "{}Nbot:{}:blockanimations".format(
                                    BOT_ID, chatID), ID)
                            Bot(
                                "sendMessage", {
                                    "chat_id":
                                    chatID,
                                    "text":
                                    r.GfB.format(title),
                                    "reply_to_message_id":
                                    message.reply_to_message.message_id,
                                    "parse_mode":
                                    "html"
                                })

            if re.search(c.unblock, text):
                if re.search(c.unblock2, text):
                    tx = text.replace(c.RPubk, "")
                    if redis.sismember(
                            "{}Nbot:{}:blockTEXTs".format(BOT_ID, chatID), tx):
                        redis.srem(
                            "{}Nbot:{}:blockTEXTs".format(BOT_ID, chatID), tx)
                        Bot(
                            "sendMessage", {
                                "chat_id": chatID,
                                "text": r.unDoneblock.format(tx, title),
                                "reply_to_message_id": message.message_id,
                                "parse_mode": "html"
                            })
                    else:
                        Bot(
                            "sendMessage", {
                                "chat_id": chatID,
                                "text": r.unAdoneblock.format(tx),
                                "reply_to_message_id": message.message_id,
                                "parse_mode": "html"
                            })

                if message.reply_to_message:
                    if message.reply_to_message.sticker:
                        ID = message.reply_to_message.sticker.file_id
                        if redis.sismember(
                                "{}Nbot:{}:blockSTICKERs".format(
                                    BOT_ID, chatID), ID):
                            redis.srem(
                                "{}Nbot:{}:blockSTICKERs".format(
                                    BOT_ID, chatID), ID)
                            Bot(
                                "sendMessage", {
                                    "chat_id":
                                    chatID,
                                    "text":
                                    r.unStB.format(title),
                                    "reply_to_message_id":
                                    message.reply_to_message.message_id,
                                    "parse_mode":
                                    "html"
                                })
                        else:
                            Bot(
                                "sendMessage", {
                                    "chat_id":
                                    chatID,
                                    "text":
                                    r.unStA.format(title),
                                    "reply_to_message_id":
                                    message.reply_to_message.message_id,
                                    "parse_mode":
                                    "html"
                                })

                    if message.reply_to_message.photo:
                        ID = message.reply_to_message.photo.file_id
                        if redis.sismember(
                                "{}Nbot:{}:blockphotos".format(BOT_ID, chatID),
                                ID):
                            redis.srem(
                                "{}Nbot:{}:blockphotos".format(BOT_ID, chatID),
                                ID)
                            Bot(
                                "sendMessage", {
                                    "chat_id":
                                    chatID,
                                    "text":
                                    r.unPhB.format(title),
                                    "reply_to_message_id":
                                    message.reply_to_message.message_id,
                                    "parse_mode":
                                    "html"
                                })
                        else:
                            Bot(
                                "sendMessage", {
                                    "chat_id":
                                    chatID,
                                    "text":
                                    r.unPhA.format(title),
                                    "reply_to_message_id":
                                    message.reply_to_message.message_id,
                                    "parse_mode":
                                    "html"
                                })

                    if message.reply_to_message.animation:
                        ID = message.reply_to_message.animation.file_id
                        if redis.sismember(
                                "{}Nbot:{}:blockanimations".format(
                                    BOT_ID, chatID), ID):
                            redis.srem(
                                "{}Nbot:{}:blockanimations".format(
                                    BOT_ID, chatID), ID)
                            Bot(
                                "sendMessage", {
                                    "chat_id":
                                    chatID,
                                    "text":
                                    r.unGfB.format(title),
                                    "reply_to_message_id":
                                    message.reply_to_message.message_id,
                                    "parse_mode":
                                    "html"
                                })
                        else:
                            Bot(
                                "sendMessage", {
                                    "chat_id":
                                    chatID,
                                    "text":
                                    r.unGfA.format(title),
                                    "reply_to_message_id":
                                    message.reply_to_message.message_id,
                                    "parse_mode":
                                    "html"
                                })

            if re.search(c.Blocklist, text):
                Botuser = client.get_me().username
                reply_markup = InlineKeyboardMarkup([
                    [
                        InlineKeyboardButton(
                            c.STword,
                            url=
                            "https://telegram.me/{}?start=showBlocklist={}={}={}"
                            .format(Botuser, chatID, userID, "blockTEXTs")),
                        InlineKeyboardButton(
                            c.STgifs,
                            url=
                            "https://telegram.me/{}?start=showBlocklist={}={}={}"
                            .format(Botuser, chatID, userID,
                                    "blockanimations")),
                    ],
                    [
                        InlineKeyboardButton(
                            c.STphoto,
                            url=
                            "https://telegram.me/{}?start=showBlocklist={}={}={}"
                            .format(Botuser, chatID, userID, "blockphotos")),
                        InlineKeyboardButton(
                            c.STsticker,
                            url=
                            "https://telegram.me/{}?start=showBlocklist={}={}={}"
                            .format(Botuser, chatID, userID, "blockSTICKERs")),
                    ]
                ])
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.blocklist.format(r.blocklist2, title),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "reply_markup": reply_markup
                    })

            if re.search(c.Replylist, text):
                reply_markup = InlineKeyboardMarkup(
                    [[
                        InlineKeyboardButton(c.STword,
                                             callback_data=json.dumps(
                                                 ["showreplylist", "",
                                                  userID])),
                        InlineKeyboardButton(c.STgifs,
                                             callback_data=json.dumps([
                                                 "showGFreplylist", "", userID
                                             ])),
                    ],
                     [
                         InlineKeyboardButton(c.STvoice,
                                              callback_data=json.dumps([
                                                  "showVOreplylist", "", userID
                                              ])),
                         InlineKeyboardButton(c.STsticker,
                                              callback_data=json.dumps([
                                                  "showSTreplylist", "", userID
                                              ])),
                     ]])
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.blocklist.format(text, title),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "reply_markup": reply_markup
                    })

            if re.search(c.FloodT, text):
                Nu = text.split(" ")[2]
                redis.hset("{}Nbot:time_ck".format(BOT_ID), chatID, Nu)
                Bot(
                    "sendMessage", {
                        "chat_id":
                        chatID,
                        "text":
                        r.DoneSet.format(
                            text.split(" ")[0] + " " + text.split(" ")[1], Nu),
                        "reply_to_message_id":
                        message.message_id,
                        "parse_mode":
                        "html"
                    })

            if re.search(c.FloodM, text):
                Nu = text.split(" ")[2]
                redis.hset("{}Nbot:max_msg".format(BOT_ID), chatID, Nu)
                Bot(
                    "sendMessage", {
                        "chat_id":
                        chatID,
                        "text":
                        r.DoneSet.format(
                            text.split(" ")[0] + " " + text.split(" ")[1], Nu),
                        "reply_to_message_id":
                        message.message_id,
                        "parse_mode":
                        "html"
                    })

            if re.search(c.STWEL, text):
                Wc = text.replace(c.RPwel, "")
                redis.hset("{}Nbot:welcome".format(BOT_ID), chatID, Wc)
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.Donewel.format(Wc),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html"
                    })

            if re.search(c.STreply, text):
                tx = text.replace(c.RPreply, "")
                if redis.hexists("{}Nbot:{}:TXreplys".format(BOT_ID, chatID),
                                 tx):
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.Yrp.format(tx),
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "html"
                        })
                elif redis.hexists("{}Nbot:{}:STreplys".format(BOT_ID, chatID),
                                   tx):
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.Yrp.format(tx),
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "html"
                        })
                elif redis.hexists("{}Nbot:{}:GFreplys".format(BOT_ID, chatID),
                                   tx):
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.Yrp.format(tx),
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "html"
                        })
                elif redis.hexists("{}Nbot:{}:VOreplys".format(BOT_ID, chatID),
                                   tx):
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.Yrp.format(tx),
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "html"
                        })
                else:
                    redis.hset("{}Nbot:step".format(BOT_ID), userID, tx)
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.Sendreply % tx,
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "html"
                        })

            if re.search(c.DLreply, text):
                tx = text.replace(c.RPdreply, "")
                if redis.hexists("{}Nbot:{}:TXreplys".format(BOT_ID, chatID),
                                 tx):
                    redis.hdel("{}Nbot:{}:TXreplys".format(BOT_ID, chatID), tx)
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.Drp.format(tx),
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "html"
                        })
                elif redis.hexists("{}Nbot:{}:STreplys".format(BOT_ID, chatID),
                                   tx):
                    redis.hdel("{}Nbot:{}:STreplys".format(BOT_ID, chatID), tx)
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.Drp.format(tx),
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "html"
                        })
                elif redis.hexists("{}Nbot:{}:GFreplys".format(BOT_ID, chatID),
                                   tx):
                    redis.hdel("{}Nbot:{}:GFreplys".format(BOT_ID, chatID), tx)
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.Drp.format(tx),
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "html"
                        })
                elif redis.hexists("{}Nbot:{}:VOreplys".format(BOT_ID, chatID),
                                   tx):
                    redis.hdel("{}Nbot:{}:GFreplys".format(BOT_ID, chatID), tx)
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.Drp.format(tx),
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "html"
                        })
                else:
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.Norp.format(tx),
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "html"
                        })
        if re.search(c.setname, text):
            name = text.replace(c.Dsetname, "")
            Bot("setChatTitle", {"chat_id": chatID, "title": name})
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": r.Dsetname.format(name),
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html"
                })

        if re.search(c.setabout, text):
            about = text.replace(c.Dsetabout, "")
            Bot("setChatDescription", {
                "chat_id": chatID,
                "description": about
            })
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": r.Dsetabout.format(about),
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html"
                })

        if re.search(
                c.setphoto, text
        ) and message.reply_to_message and message.reply_to_message.photo:
            ID = message.reply_to_message.photo.file_id
            client.set_chat_photo(chat_id=chatID, photo=ID)
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": r.Dsetphoto,
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html"
                })

        if re.search(c.pinmsg, text) and message.reply_to_message:
            if not redis.sismember("{}Nbot:Lpin".format(BOT_ID), chatID):
                ID = message.reply_to_message.message_id
                Bot("pinChatMessage", {"chat_id": chatID, "message_id": ID})
                redis.hset("{}Nbot:pinmsgs".format(BOT_ID), chatID, ID)
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.Dpinmsg,
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html"
                    })
            elif redis.sismember("{}Nbot:Lpin".format(BOT_ID),
                                 chatID) and rank == "creator":
                ID = message.reply_to_message.message_id
                Bot("pinChatMessage", {"chat_id": chatID, "message_id": ID})
                redis.hset("{}Nbot:pinmsgs".format(BOT_ID), chatID, ID)
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.Dpinmsg,
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html"
                    })

            if re.search(c.unpinmsg, text):
                if not redis.sismember("{}Nbot:Lpin".format(BOT_ID), chatID):
                    Bot("unpinChatMessage", {
                        "chat_id": chatID,
                        "message_id": ID
                    })
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.Dunpinmsg,
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "html"
                        })
                if redis.sismember("{}Nbot:Lpin".format(BOT_ID),
                                   chatID) and rank == "creator":
                    Bot("unpinChatMessage", {
                        "chat_id": chatID,
                        "message_id": ID
                    })
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.Dunpinmsg,
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "html"
                        })

        if re.search(c.SETlink, text):
            lk = text.replace(c.RPlink, "")
            redis.hset("{}Nbot:links".format(BOT_ID), chatID, lk)
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": r.Dsetlk.format(lk),
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html",
                    "disable_web_page_preview": True
                })

        if rank != "admin" and rank != "owner":
            if re.search(c.deletebots, text):
                bots = [
                    x for x in client.iter_chat_members(chatID)
                    if x.user.is_bot and x.user.id != int(BOT_ID)
                    and x.status != "administrator"
                ]
                if bots:
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.LenBots.format(len(bots)),
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "html"
                        })
                    for u in bots:
                        Bot(
                            "kickChatMember", {
                                "chat_id": chatID,
                                "user_id": u.user.id,
                                "until_date": int(time.time() + 60)
                            })
                        time.sleep(0.3)
                else:
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.NoBots,
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "html"
                        })

            if re.search(c.deleteDeleted, text):
                deleted = [
                    x for x in client.iter_chat_members(chatID)
                    if x.user.is_deleted
                ]
                if deleted:
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.LenDeleted.format(len(deleted)),
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "html"
                        })
                    for u in deleted:
                        Bot(
                            "kickChatMember", {
                                "chat_id": chatID,
                                "user_id": u.user.id,
                                "until_date": int(time.time() + 60)
                            })
                        time.sleep(0.3)
                else:
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.NoDeleted,
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "html"
                        })

            if re.search(c.Chlang, text):
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.Chlang,
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "reply_markup": Clang(client, message, redis, r)
                    })
            if re.search(c.PROadmins, text):
                ads = Bot("getChatAdministrators", {"chat_id": chatID})
                for ad in ads['result']:
                    userId = ad["user"]["id"]
                    userFn = ad["user"]["first_name"]
                    if ad['status'] == "administrator" and int(userId) != int(
                            BOT_ID):
                        setrank(redis, "admin", userId, chatID, "array")
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.DPROadmins,
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html"
                    })
示例#20
0
def locks(client, message, redis):
    type = message.chat.type
    userID = message.from_user.id
    userFN = Name(message.from_user.first_name)
    chatID = message.chat.id
    rank = isrank(redis, userID, chatID)
    text = message.text
    title = message.chat.title
    lang = Glang(redis, chatID)
    moduleCMD = "lang." + lang + "-cmd"
    moduleREPLY = "lang." + lang + "-reply"
    c = importlib.import_module(moduleCMD)
    r = importlib.import_module(moduleREPLY)
    T = text.split(" ")[1]
    if text == c.Lurl:
        get = redis.sismember("{}Nbot:Llink".format(BOT_ID), chatID)
        if get:
            send_msg("LUN", client, message, r.locked, "Llink", T, redis)
        else:
            save = redis.sadd("{}Nbot:Llink".format(BOT_ID), chatID)
            send_msg("LU", client, message, r.lock, "Llink", T, redis)

    if text == c.Uurl:
        get = redis.sismember("{}Nbot:Llink".format(BOT_ID), chatID)
        if get:
            save = redis.srem("{}Nbot:Llink".format(BOT_ID), chatID)
            send_msg("LU", client, message, r.unlock, "Llink", T, redis)
        else:
            send_msg("LUN", client, message, r.unlocked, "Llink", T, redis)

    if text == c.Lphoto:
        get = redis.sismember("{}Nbot:Lphoto".format(BOT_ID), chatID)
        if get:
            send_msg("LUN", client, message, r.locked, "Lphoto", T, redis)
        else:
            save = redis.sadd("{}Nbot:Lphoto".format(BOT_ID), chatID)
            send_msg("LU", client, message, r.lock, "Lphoto", T, redis)

    if text == c.Uphoto:
        get = redis.sismember("{}Nbot:Lphoto".format(BOT_ID), chatID)
        if get:
            save = redis.srem("{}Nbot:Lphoto".format(BOT_ID), chatID)
            send_msg("LU", client, message, r.unlock, "Lphoto", T, redis)
        else:
            send_msg("LUN", client, message, r.unlocked, "Lphoto", T, redis)

    if text == c.Lusername:
        get = redis.sismember("{}Nbot:Lusername".format(BOT_ID), chatID)
        if get:
            send_msg("LUN", client, message, r.locked, "Lusername", T, redis)
        else:
            save = redis.sadd("{}Nbot:Lusername".format(BOT_ID), chatID)
            send_msg("LU", client, message, r.lock, "Lusername", T, redis)

    if text == c.Uusername:
        get = redis.sismember("{}Nbot:Lusername".format(BOT_ID), chatID)
        if get:
            save = redis.srem("{}Nbot:Lusername".format(BOT_ID), chatID)
            send_msg("LU", client, message, r.unlock, "Lusername", T, redis)
        else:
            send_msg("LUN", client, message, r.unlocked, "Lusername", T, redis)

    if text == c.Ltag:
        get = redis.sismember("{}Nbot:Ltag".format(BOT_ID), chatID)
        if get:
            send_msg("LUN", client, message, r.locked, "Ltag", T, redis)
        else:
            save = redis.sadd("{}Nbot:Ltag".format(BOT_ID), chatID)
            send_msg("LU", client, message, r.lock, "Ltag", T, redis)

    if text == c.Utag:
        get = redis.sismember("{}Nbot:Ltag".format(BOT_ID), chatID)
        if get:
            save = redis.srem("{}Nbot:Ltag".format(BOT_ID), chatID)
            send_msg("LU", client, message, r.unlock, "Ltag", T, redis)
        else:
            send_msg("LUN", client, message, r.unlocked, "Ltag", T, redis)

    if text == c.Lvideo:
        get = redis.sismember("{}Nbot:Lvideo".format(BOT_ID), chatID)
        if get:
            send_msg("LUN", client, message, r.locked, "Lvideo", T, redis)
        else:
            save = redis.sadd("{}Nbot:Lvideo".format(BOT_ID), chatID)
            send_msg("LU", client, message, r.lock, "Lvideo", T, redis)

    if text == c.Uvideo:
        get = redis.sismember("{}Nbot:Lvideo".format(BOT_ID), chatID)
        if get:
            save = redis.srem("{}Nbot:Lvideo".format(BOT_ID), chatID)
            send_msg("LU", client, message, r.unlock, "Lvideo", T, redis)
        else:
            send_msg("LUN", client, message, r.unlocked, "Lvideo", T, redis)

    if text == c.Lgifs:
        get = redis.sismember("{}Nbot:Lgifs".format(BOT_ID), chatID)
        if get:
            send_msg("LUN", client, message, r.locked, "Lgifs", T, redis)
        else:
            save = redis.sadd("{}Nbot:Lgifs".format(BOT_ID), chatID)
            send_msg("LU", client, message, r.lock, "Lgifs", T, redis)

    if text == c.Ugifs:
        get = redis.sismember("{}Nbot:Lgifs".format(BOT_ID), chatID)
        if get:
            save = redis.srem("{}Nbot:Lgifs".format(BOT_ID), chatID)
            send_msg("LU", client, message, r.unlock, "Lgifs", T, redis)
        else:
            send_msg("LUN", client, message, r.unlocked, "Lgifs", T, redis)

    if text == c.Lsticker:
        get = redis.sismember("{}Nbot:Lsticker".format(BOT_ID), chatID)
        if get:
            send_msg("LUN", client, message, r.locked, "Lsticker", T, redis)
        else:
            save = redis.sadd("{}Nbot:Lsticker".format(BOT_ID), chatID)
            send_msg("LU", client, message, r.lock, "Lsticker", T, redis)

    if text == c.Usticker:
        get = redis.sismember("{}Nbot:Lsticker".format(BOT_ID), chatID)
        if get:
            save = redis.srem("{}Nbot:Lsticker".format(BOT_ID), chatID)
            send_msg("LU", client, message, r.unlock, "Lsticker", T, redis)
        else:
            send_msg("LUN", client, message, r.unlocked, "Lsticker", T, redis)

    if text == c.Lfiles:
        get = redis.sismember("{}Nbot:Lfiles".format(BOT_ID), chatID)
        if get:
            send_msg("LUN", client, message, r.locked, "Lfiles", T, redis)
        else:
            save = redis.sadd("{}Nbot:Lfiles".format(BOT_ID), chatID)
            send_msg("LU", client, message, r.lock, "Lfiles", T, redis)

    if text == c.Ufiles:
        get = redis.sismember("{}Nbot:Lfiles".format(BOT_ID), chatID)
        if get:
            save = redis.srem("{}Nbot:Lfiles".format(BOT_ID), chatID)
            send_msg("LU", client, message, r.unlock, "Lfiles", T, redis)
        else:
            send_msg("LUN", client, message, r.unlocked, "Lfiles", T, redis)

    if text == c.Lmusic:
        get = redis.sismember("{}Nbot:Lmusic".format(BOT_ID), chatID)
        if get:
            send_msg("LUN", client, message, r.locked, "Lmusic", T, redis)
        else:
            save = redis.sadd("{}Nbot:Lmusic".format(BOT_ID), chatID)
            send_msg("LU", client, message, r.lock, "Lmusic", T, redis)

    if text == c.Umusic:
        get = redis.sismember("{}Nbot:Lmusic".format(BOT_ID), chatID)
        if get:
            save = redis.srem("{}Nbot:Lmusic".format(BOT_ID), chatID)
            send_msg("LU", client, message, r.unlock, "Lmusic", T, redis)
        else:
            send_msg("LUN", client, message, r.unlocked, "Lmusic", T, redis)

    if text == c.Lfwd:
        get = redis.sismember("{}Nbot:Lfwd".format(BOT_ID), chatID)
        if get:
            send_msg("LUN", client, message, r.locked, "Lfwd", T, redis)
        else:
            save = redis.sadd("{}Nbot:Lfwd".format(BOT_ID), chatID)
            send_msg("LU", client, message, r.lock, "Lfwd", T, redis)

    if text == c.Ufwd:
        get = redis.sismember("{}Nbot:Lfwd".format(BOT_ID), chatID)
        if get:
            save = redis.srem("{}Nbot:Lfwd".format(BOT_ID), chatID)
            send_msg("LU", client, message, r.unlock, "Lfwd", T, redis)
        else:
            send_msg("LUN", client, message, r.unlocked, "Lfwd", T, redis)

    if text == c.Lvoice:
        get = redis.sismember("{}Nbot:Lvoice".format(BOT_ID), chatID)
        if get:
            send_msg("LUN", client, message, r.locked, "Lvoice", T, redis)
        else:
            save = redis.sadd("{}Nbot:Lvoice".format(BOT_ID), chatID)
            send_msg("LU", client, message, r.lock, "Lvoice", T, redis)

    if text == c.Uvoice:
        get = redis.sismember("{}Nbot:Lvoice".format(BOT_ID), chatID)
        if get:
            save = redis.srem("{}Nbot:Lvoice".format(BOT_ID), chatID)
            send_msg("LU", client, message, r.unlock, "Lvoice", T, redis)
        else:
            send_msg("LUN", client, message, r.unlocked, "Lvoice", T, redis)

    if text == c.Lcontact:
        get = redis.sismember("{}Nbot:Lcontact".format(BOT_ID), chatID)
        if get:
            send_msg("LUN", client, message, r.locked, "Lcontact", T, redis)
        else:
            save = redis.sadd("{}Nbot:Lcontact".format(BOT_ID), chatID)
            send_msg("LU", client, message, r.lock, "Lcontact", T, redis)

    if text == c.Ucontact:
        get = redis.sismember("{}Nbot:Lcontact".format(BOT_ID), chatID)
        if get:
            save = redis.srem("{}Nbot:Lcontact".format(BOT_ID), chatID)
            send_msg("LU", client, message, r.unlock, "Lcontact", T, redis)
        else:
            send_msg("LUN", client, message, r.unlocked, "Lcontact", T, redis)

    if text == c.Lmarkdown:
        get = redis.sismember("{}Nbot:Lmarkdown".format(BOT_ID), chatID)
        if get:
            send_msg("LUN", client, message, r.locked, "Lmarkdown", T, redis)
        else:
            save = redis.sadd("{}Nbot:Lmarkdown".format(BOT_ID), chatID)
            send_msg("LU", client, message, r.lock, "Lmarkdown", T, redis)

    if text == c.Umarkdown:
        get = redis.sismember("{}Nbot:Lmarkdown".format(BOT_ID), chatID)
        if get:
            save = redis.srem("{}Nbot:Lmarkdown".format(BOT_ID), chatID)
            send_msg("LU", client, message, r.unlock, "Lmarkdown", T, redis)
        else:
            send_msg("LUN", client, message, r.unlocked, "Lmarkdown", T, redis)

    if text == c.Lbots:
        get = redis.sismember("{}Nbot:Lbots".format(BOT_ID), chatID)
        if get:
            send_msg("LUN", client, message, r.locked, "Lbots", T, redis)
        else:
            save = redis.sadd("{}Nbot:Lbots".format(BOT_ID), chatID)
            send_msg("LU", client, message, r.lock, "Lbots", T, redis)

    if text == c.Ubots:
        get = redis.sismember("{}Nbot:Lbots".format(BOT_ID), chatID)
        if get:
            save = redis.srem("{}Nbot:Lbots".format(BOT_ID), chatID)
            send_msg("LU", client, message, r.unlock, "Lbots", T, redis)
        else:
            send_msg("LUN", client, message, r.unlocked, "Lbots", T, redis)

    if text == c.Ledits:
        get = redis.sismember("{}Nbot:Ledits".format(BOT_ID), chatID)
        if get:
            send_msg("LUN", client, message, r.locked, "Ledits", T, redis)
        else:
            save = redis.sadd("{}Nbot:Ledits".format(BOT_ID), chatID)
            send_msg("LU", client, message, r.lock, "Ledits", T, redis)

    if text == c.Uedits:
        get = redis.sismember("{}Nbot:Ledits".format(BOT_ID), chatID)
        if get:
            save = redis.srem("{}Nbot:Ledits".format(BOT_ID), chatID)
            send_msg("LU", client, message, r.unlock, "Ledits", T, redis)
        else:
            send_msg("LUN", client, message, r.unlocked, "Ledits", T, redis)

    if text == c.Larabic:
        get = redis.sismember("{}Nbot:Larabic".format(BOT_ID), chatID)
        if get:
            send_msg("LUN", client, message, r.locked, "Larabic", T, redis)
        else:
            save = redis.sadd("{}Nbot:Larabic".format(BOT_ID), chatID)
            send_msg("LU", client, message, r.lock, "Larabic", T, redis)

    if text == c.Uarabic:
        get = redis.sismember("{}Nbot:Larabic".format(BOT_ID), chatID)
        if get:
            save = redis.srem("{}Nbot:Larabic".format(BOT_ID), chatID)
            send_msg("LU", client, message, r.unlock, "Larabic", T, redis)
        else:
            send_msg("LUN", client, message, r.unlocked, "Larabic", T, redis)

    if text == c.Lenglish:
        get = redis.sismember("{}Nbot:Lenglish".format(BOT_ID), chatID)
        if get:
            send_msg("LUN", client, message, r.locked, "Lenglish", T, redis)
        else:
            save = redis.sadd("{}Nbot:Lenglish".format(BOT_ID), chatID)
            send_msg("LU", client, message, r.lock, "Lenglish", T, redis)

    if text == c.Uenglish:
        get = redis.sismember("{}Nbot:Lenglish".format(BOT_ID), chatID)
        if get:
            save = redis.srem("{}Nbot:Lenglish".format(BOT_ID), chatID)
            send_msg("LU", client, message, r.unlock, "Lenglish", T, redis)
        else:
            send_msg("LUN", client, message, r.unlocked, "Lenglish", T, redis)

    if text == c.Linline:
        get = redis.sismember("{}Nbot:Linline".format(BOT_ID), chatID)
        if get:
            send_msg("LUN", client, message, r.locked, "Linline", T, redis)
        else:
            save = redis.sadd("{}Nbot:Linline".format(BOT_ID), chatID)
            send_msg("LU", client, message, r.lock, "Linline", T, redis)

    if text == c.Uinline:
        get = redis.sismember("{}Nbot:Linline".format(BOT_ID), chatID)
        if get:
            save = redis.srem("{}Nbot:Linline".format(BOT_ID), chatID)
            send_msg("LU", client, message, r.unlock, "Linline", T, redis)
        else:
            send_msg("LUN", client, message, r.unlocked, "Linline", T, redis)

    if text == c.Lchat:
        Bot("setChatPermissions", {"chat_id": chatID})
        send_msg("LUN", client, message, r.lock, "Lchat", T, redis)

    if text == c.Uchat:
        Bot(
            "setchatpermissions", {
                "chat_id":
                chatID,
                "permissions":
                json.dumps({
                    "can_send_messages": True,
                    "can_send_media_messages": True,
                    "can_send_polls": True,
                    "can_send_other_messages": True,
                    "can_invite_users": True,
                    "can_add_web_page_previews": True
                })
            })
        send_msg("LUN", client, message, r.unlock, "Lchat", T, redis)

    if text == c.Ljoin:
        get = redis.sismember("{}Nbot:Ljoin".format(BOT_ID), chatID)
        if get:
            send_msg("LUN", client, message, r.locked, "Ljoin", T, redis)
        else:
            save = redis.sadd("{}Nbot:Ljoin".format(BOT_ID), chatID)
            send_msg("LU", client, message, r.lock, "Ljoin", T, redis)

    if text == c.Ujoin:
        get = redis.sismember("{}Nbot:Ljoin".format(BOT_ID), chatID)
        if get:
            save = redis.srem("{}Nbot:Ljoin".format(BOT_ID), chatID)
            send_msg("LU", client, message, r.unlock, "Ljoin", T, redis)
        else:
            send_msg("LUN", client, message, r.unlocked, "Ljoin", T, redis)

    if text == c.Llongtext:
        get = redis.sismember("{}Nbot:Llongtext".format(BOT_ID), chatID)
        if get:
            send_msg("LUN", client, message, r.locked, "Llongtext", T, redis)
        else:
            save = redis.sadd("{}Nbot:Llongtext".format(BOT_ID), chatID)
            send_msg("LU", client, message, r.lock, "Llongtext", T, redis)

    if text == c.Ulongtext:
        get = redis.sismember("{}Nbot:Llongtext".format(BOT_ID), chatID)
        if get:
            save = redis.srem("{}Nbot:Llongtext".format(BOT_ID), chatID)
            send_msg("LU", client, message, r.unlock, "Llongtext", T, redis)
        else:
            send_msg("LUN", client, message, r.unlocked, "Llongtext", T, redis)

    if text == c.Lall:
        get = redis.sismember("{}Nbot:Lall".format(BOT_ID), chatID)
        if get:
            send_msg("LUN", client, message, r.locked, "Lall", T, redis)
        else:
            save = redis.sadd("{}Nbot:Lall".format(BOT_ID), chatID)
            send_msg("LU", client, message, r.lock, "Lall", T, redis)

    if text == c.Uall:
        get = redis.sismember("{}Nbot:Lall".format(BOT_ID), chatID)
        if get:
            save = redis.srem("{}Nbot:Lall".format(BOT_ID), chatID)
            send_msg("LU", client, message, r.unlock, "Lall", T, redis)
        else:
            send_msg("LUN", client, message, r.unlocked, "Lall", T, redis)

    if text == c.Lnote:
        get = redis.sismember("{}Nbot:Lnote".format(BOT_ID), chatID)
        if get:
            send_msg("LUN", client, message, r.locked, "Lnote", T, redis)
        else:
            save = redis.sadd("{}Nbot:Lnote".format(BOT_ID), chatID)
            send_msg("LU", client, message, r.lock, "Lnote", T, redis)

    if text == c.Unote:
        get = redis.sismember("{}Nbot:Lnote".format(BOT_ID), chatID)
        if get:
            save = redis.srem("{}Nbot:Lnote".format(BOT_ID), chatID)
            send_msg("LU", client, message, r.unlock, "Lnote", T, redis)
        else:
            send_msg("LUN", client, message, r.unlocked, "Lnote", T, redis)
    if rank != "admin" and rank != "owner":
        if text == c.Lpin:
            R = text.split(" ")[1]
            BY = "<a href=\"tg://user?id={}\">{}</a>".format(userID, userFN)
            get = redis.sismember("{}Nbot:Lpin".format(BOT_ID), chatID)
            if get:
                save = redis.srem("{}Nbot:Lpin".format(BOT_ID), chatID)
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.ADD.format(BY, R),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "disable_web_page_preview": True
                    })
            else:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.ADDed.format(BY, R),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "disable_web_page_preview": True
                    })

        if text == c.Upin:
            R = text.split(" ")[1]
            BY = "<a href=\"tg://user?id={}\">{}</a>".format(userID, userFN)
            get = redis.sismember("{}Nbot:Lpin".format(BOT_ID), chatID)
            if get:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.unADDed.format(BY, R),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "disable_web_page_preview": True
                    })
            else:
                save = redis.sadd("{}Nbot:Lpin".format(BOT_ID), chatID)
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.unADD.format(BY, R),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "disable_web_page_preview": True
                    })

    if rank != "admin":
        if text == c.LwelcomeSend:
            R = text.split(" ")[1]
            get = redis.sismember("{}Nbot:welcomeSend".format(BOT_ID), chatID)
            BY = "<a href=\"tg://user?id={}\">{}</a>".format(userID, userFN)
            if get:
                save = redis.srem("{}Nbot:welcomeSend".format(BOT_ID), chatID)
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.ADD.format(BY, R),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "disable_web_page_preview": True
                    })
            else:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.ADDed.format(BY, R),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "disable_web_page_preview": True
                    })

        if text == c.UwelcomeSend:
            R = text.split(" ")[1]
            BY = "<a href=\"tg://user?id={}\">{}</a>".format(userID, userFN)
            get = redis.sismember("{}Nbot:welcomeSend".format(BOT_ID), chatID)
            if get:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.unADDed.format(BY, R),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "disable_web_page_preview": True
                    })
            else:
                save = redis.sadd("{}Nbot:welcomeSend".format(BOT_ID), chatID)
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.unADD.format(BY, R),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "disable_web_page_preview": True
                    })

    if rank != "admin":
        if text == c.Lbancheck:
            R = text.split(" ")[1]
            get = redis.sismember("{}Nbot:bancheck".format(BOT_ID), chatID)
            BY = "<a href=\"tg://user?id={}\">{}</a>".format(userID, userFN)
            if get:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.ADDed.format(BY, R),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "disable_web_page_preview": True
                    })
            else:
                save = redis.sadd("{}Nbot:bancheck".format(BOT_ID), chatID)
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.ADD.format(BY, R),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "disable_web_page_preview": True
                    })

        if text == c.Ubancheck:
            R = text.split(" ")[1]
            BY = "<a href=\"tg://user?id={}\">{}</a>".format(userID, userFN)
            get = redis.sismember("{}Nbot:bancheck".format(BOT_ID), chatID)
            if get:
                save = redis.srem("{}Nbot:bancheck".format(BOT_ID), chatID)
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.unADD.format(BY, R),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "disable_web_page_preview": True
                    })
            else:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.unADDed.format(BY, R),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "disable_web_page_preview": True
                    })

        if text == c.Lreply:
            R = text.split(" ")[1]
            get = redis.sismember("{}Nbot:ReplySend".format(BOT_ID), chatID)
            BY = "<a href=\"tg://user?id={}\">{}</a>".format(userID, userFN)
            if get:
                save = redis.srem("{}Nbot:ReplySend".format(BOT_ID), chatID)
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.ADD.format(BY, R),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "disable_web_page_preview": True
                    })
            else:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.ADDed.format(BY, R),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "disable_web_page_preview": True
                    })

        if text == c.Ureply:
            R = text.split(" ")[1]
            BY = "<a href=\"tg://user?id={}\">{}</a>".format(userID, userFN)
            get = redis.sismember("{}Nbot:ReplySend".format(BOT_ID), chatID)
            if get:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.unADDed.format(BY, R),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "disable_web_page_preview": True
                    })
            else:
                save = redis.sadd("{}Nbot:ReplySend".format(BOT_ID), chatID)
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.unADD.format(BY, R),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "disable_web_page_preview": True
                    })

        if text == c.LreplyBOT:
            R = text.split(" ")[1]
            get = redis.sismember("{}Nbot:ReplySendBOT".format(BOT_ID), chatID)
            BY = "<a href=\"tg://user?id={}\">{}</a>".format(userID, userFN)
            if get:
                save = redis.srem("{}Nbot:ReplySendBOT".format(BOT_ID), chatID)
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.ADD.format(BY, R),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "disable_web_page_preview": True
                    })
            else:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.ADDed.format(BY, R),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "disable_web_page_preview": True
                    })

        if text == c.UreplyBOT:
            R = text.split(" ")[1]
            BY = "<a href=\"tg://user?id={}\">{}</a>".format(userID, userFN)
            get = redis.sismember("{}Nbot:ReplySendBOT".format(BOT_ID), chatID)
            if get:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.unADDed.format(BY, R),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "disable_web_page_preview": True
                    })
            else:
                save = redis.sadd("{}Nbot:ReplySendBOT".format(BOT_ID), chatID)
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.unADD.format(BY, R),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "disable_web_page_preview": True
                    })

        if text == c.Lkickme:
            R = text.split(" ")[1]
            get = redis.sismember("{}Nbot:kickme".format(BOT_ID), chatID)
            BY = "<a href=\"tg://user?id={}\">{}</a>".format(userID, userFN)
            if get:
                save = redis.srem("{}Nbot:kickme".format(BOT_ID), chatID)
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.ADD.format(BY, R),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "disable_web_page_preview": True
                    })
            else:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.ADDed.format(BY, R),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "disable_web_page_preview": True
                    })

        if text == c.Ukickme:
            R = text.split(" ")[1]
            BY = "<a href=\"tg://user?id={}\">{}</a>".format(userID, userFN)
            get = redis.sismember("{}Nbot:kickme".format(BOT_ID), chatID)
            if get:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.unADDed.format(BY, R),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "disable_web_page_preview": True
                    })
            else:
                save = redis.sadd("{}Nbot:kickme".format(BOT_ID), chatID)
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.unADD.format(BY, R),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "disable_web_page_preview": True
                    })

        if text == c.LID:
            R = text.split(" ")[1]
            get = redis.sismember("{}Nbot:IDSend".format(BOT_ID), chatID)
            BY = "<a href=\"tg://user?id={}\">{}</a>".format(userID, userFN)
            if get:
                save = redis.srem("{}Nbot:IDSend".format(BOT_ID), chatID)
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.ADD.format(BY, R),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "disable_web_page_preview": True
                    })
            else:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.ADDed.format(BY, R),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "disable_web_page_preview": True
                    })

        if text == c.UID:
            R = text.split(" ")[1]
            BY = "<a href=\"tg://user?id={}\">{}</a>".format(userID, userFN)
            get = redis.sismember("{}Nbot:IDSend".format(BOT_ID), chatID)
            if get:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.unADDed.format(BY, R),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "disable_web_page_preview": True
                    })
            else:
                save = redis.sadd("{}Nbot:IDSend".format(BOT_ID), chatID)
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.unADD.format(BY, R),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "disable_web_page_preview": True
                    })

        if re.search(c.LIDPH, text):
            R = text.replace(c.stAd, "")
            get = redis.sismember("{}Nbot:IDSendPH".format(BOT_ID), chatID)
            BY = "<a href=\"tg://user?id={}\">{}</a>".format(userID, userFN)
            if get:
                save = redis.srem("{}Nbot:IDSendPH".format(BOT_ID), chatID)
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.ADD.format(BY, R),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "disable_web_page_preview": True
                    })
            else:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.ADDed.format(BY, R),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "disable_web_page_preview": True
                    })

        if re.search(c.UIDPH, text):
            R = text.replace(c.stUd, "")
            BY = "<a href=\"tg://user?id={}\">{}</a>".format(userID, userFN)
            get = redis.sismember("{}Nbot:IDSendPH".format(BOT_ID), chatID)
            if get:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.unADDed.format(BY, R),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "disable_web_page_preview": True
                    })
            else:
                save = redis.sadd("{}Nbot:IDSendPH".format(BOT_ID), chatID)
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.unADD.format(BY, R),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "disable_web_page_preview": True
                    })

        if text == c.Lflood:
            R = text.split(" ")[1]
            BY = "<a href=\"tg://user?id={}\">{}</a>".format(userID, userFN)
            get = redis.sismember("{}Nbot:Lflood".format(BOT_ID), chatID)
            if get:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.ADDed.format(BY, R),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "disable_web_page_preview": True
                    })
            else:
                save = redis.sadd("{}Nbot:Lflood".format(BOT_ID), chatID)
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.ADD.format(BY, R),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "disable_web_page_preview": True
                    })

        if text == c.Uflood:
            R = text.split(" ")[1]
            BY = "<a href=\"tg://user?id={}\">{}</a>".format(userID, userFN)
            get = redis.sismember("{}Nbot:Lflood".format(BOT_ID), chatID)
            if get:
                save = redis.srem("{}Nbot:Lflood".format(BOT_ID), chatID)
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.unADD.format(BY, R),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "disable_web_page_preview": True
                    })
            else:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.unADDed.format(BY, R),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "disable_web_page_preview": True
                    })

        if re.search(c.LIDpt, text):
            R = text.replace(c.stAd, "")
            get = redis.sismember("{}Nbot:IDpt".format(BOT_ID), chatID)
            BY = "<a href=\"tg://user?id={}\">{}</a>".format(userID, userFN)
            if get:
                save = redis.srem("{}Nbot:IDpt".format(BOT_ID), chatID)
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.ADD.format(BY, R),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "disable_web_page_preview": True
                    })
            else:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.ADDed.format(BY, R),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "disable_web_page_preview": True
                    })

        if re.search(c.UIDpt, text):
            R = text.replace(c.stUd, "")
            BY = "<a href=\"tg://user?id={}\">{}</a>".format(userID, userFN)
            get = redis.sismember("{}Nbot:IDpt".format(BOT_ID), chatID)
            if get:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.unADDed.format(BY, R),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "disable_web_page_preview": True
                    })
            else:
                save = redis.sadd("{}Nbot:IDpt".format(BOT_ID), chatID)
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.unADD.format(BY, R),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "disable_web_page_preview": True
                    })
示例#21
0
def updateHandlers(client, message, redis):

    type = message.chat.type
    userID = message.from_user.id
    chatID = message.chat.id
    if redis.sismember("{}Nbot:lang:ar".format(BOT_ID), chatID):
        lang = "ar"
    elif redis.sismember("{}Nbot:lang:en".format(BOT_ID), chatID):
        lang = "en"
    else:
        lang = "ar"
    moduleCMD = "lang." + lang + "-cmd"
    moduleREPLY = "lang." + lang + "-reply"
    c = importlib.import_module(moduleCMD)
    r = importlib.import_module(moduleREPLY)
    if (type is "supergroup" or type is "group") and message.outgoing != True:
        userID = message.from_user.id
        chatID = message.chat.id
        rank = isrank(redis, userID, chatID)
        group = redis.sismember("{}Nbot:groups".format(BOT_ID), chatID)
        text = message.text
        title = message.chat.title
        if text and group is False:
            if (rank is "sudo" or rank is "sudos") or (
                    redis.get("{}Nbot:autoaddbot".format(BOT_ID))
                    and GPranks(userID, chatID) == "creator"):
                if text == c.add:
                    if redis.get("{}Nbot:autoaddbotN".format(BOT_ID)):
                        auN = int(
                            redis.get("{}Nbot:autoaddbotN".format(BOT_ID)))
                    else:
                        auN = 1
                    if auN >= Bot("getChatMembersCount", {
                            "chat_id": chatID
                    })["result"] and not (rank is "sudo" or rank is "sudos"):
                        Bot(
                            "sendMessage", {
                                "chat_id":
                                chatID,
                                "text":
                                r.Toolow.format((int(
                                    redis.get(
                                        "{}Nbot:autoaddbotN".format(BOT_ID)))
                                                 or 0)),
                                "reply_to_message_id":
                                message.message_id,
                                "parse_mode":
                                "html"
                            })
                        return False
                    GetME = Bot("getChatMember", {
                        "chat_id": chatID,
                        "user_id": BOT_ID
                    })["result"]
                    if (not GetME["can_change_info"]
                            or not GetME["can_delete_messages"]
                            or not GetME["can_invite_users"]
                            or not GetME["can_restrict_members"]
                            or not GetME["can_pin_messages"]
                            or not GetME["can_promote_members"]):
                        Bot(
                            "sendMessage", {
                                "chat_id": chatID,
                                "text": r.GiveMEall,
                                "reply_to_message_id": message.message_id,
                                "parse_mode": "html"
                            })
                        return False

                if text == c.add and not redis.sismember(
                        "{}Nbot:disabledgroups".format(BOT_ID),
                        chatID) and Ckuser(message):
                    locksarray = {
                        'Llink', 'Llongtext', 'Lmarkdown', 'Linline', 'Lfiles',
                        'Lcontact', 'Lbots', 'Lfwd', 'Lnote'
                    }
                    for lock in locksarray:
                        redis.sadd("{}Nbot:{}".format(BOT_ID, lock), chatID)
                    ads = Bot("getChatAdministrators", {"chat_id": chatID})
                    for ad in ads['result']:
                        userId = ad["user"]["id"]
                        userFn = ad["user"]["first_name"]
                        if ad['status'] == "administrator" and int(
                                userId) != int(BOT_ID):
                            setrank(redis, "admin", userId, chatID, "array")
                        if ad['status'] == "creator":
                            setrank(redis, "creator", userId, chatID, "one")
                    add = redis.sadd("{}Nbot:groups".format(BOT_ID), chatID)
                    Bot("exportChatInviteLink", {"chat_id": chatID})
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.doneadd.format(title),
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "html"
                        })

                elif text == c.add and redis.sismember(
                        "{}Nbot:disabledgroups".format(BOT_ID),
                        chatID) and Ckuser(message):
                    redis.sadd("{}Nbot:groups".format(BOT_ID), chatID)
                    redis.srem("{}Nbot:disabledgroups".format(BOT_ID), chatID)
                    redis.hdel("{}Nbot:disabledgroupsTIME".format(BOT_ID),
                               chatID)
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.doneadd2.format(title),
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "html"
                        })
                if text == c.disabl and Ckuser(message):
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.disabled.format(title),
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "html"
                        })

        if text and group is True:
            if (rank is "sudo" or rank is "sudos") or (
                    redis.get("{}Nbot:autoaddbot".format(BOT_ID))
                    and GPranks(userID, chatID) == "creator"):
                if text == c.add and Ckuser(message):
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.doneadded.format(title),
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "html"
                        })
                if text == c.disabl and Ckuser(message):
                    redis.srem("{}Nbot:groups".format(BOT_ID), chatID)
                    redis.sadd("{}Nbot:disabledgroups".format(BOT_ID), chatID)
                    NextDay_Date = datetime.datetime.today(
                    ) + datetime.timedelta(days=1)
                    redis.hset("{}Nbot:disabledgroupsTIME".format(BOT_ID),
                               chatID, str(NextDay_Date))
                    Bot(
                        "sendMessage", {
                            "chat_id": chatID,
                            "text": r.disabl.format(title),
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "html"
                        })

        if (rank is "sudo" or rank is "sudos") and group is True:
            t = threading.Thread(target=sudo, args=(client, message, redis))
            t.setDaemon(True)
            t.start()

        if text and (rank is "sudo" or rank is "sudos" or rank is "creator"
                     or rank is "owner") and group is True:
            t = threading.Thread(target=ranks, args=(client, message, redis))
            t.setDaemon(True)
            t.start()
        if text and (rank is "sudo" or rank is "sudos" or rank is "creator"
                     or rank is "owner"
                     or rank is "admin") and group is True and re.search(
                         c.startlock, text):
            if Ckuser(message):
                t = threading.Thread(target=locks,
                                     args=(client, message, redis))
                t.setDaemon(True)
                t.start()
        if (rank is False or rank is 0) and group is True:
            t = threading.Thread(target=delete, args=(client, message, redis))
            t.setDaemon(True)
            t.start()

        if (rank is "sudo" or rank is "sudos" or rank is "creator"
                or rank is "owner" or rank is "admin") and group is True:
            t = threading.Thread(target=gpcmd, args=(client, message, redis))
            t.setDaemon(True)
            t.start()
        if group is True:
            t = threading.Thread(target=allGP, args=(client, message, redis))
            t.setDaemon(True)
            t.start()

    if type is "private" and message.outgoing != True:
        text = message.text
        rank = isrank(redis, userID, chatID)
        if (rank is "sudo" or rank is "sudos"):
            t = threading.Thread(target=sudo, args=(client, message, redis))
            t.setDaemon(True)
            t.start()
        if text and re.search("^/start$", text):
            redis.sadd("{}Nbot:privates".format(BOT_ID), userID)
            print("start")
        if text and re.search("^/start (.*)$", text):
            tx = text.replace("/start ", "")
            split = tx.split("=")
            order = split[0]
            print(split)

            if order == "showreplylistBOT":
                chatId = split[1]
                userId = split[2]
                TY = split[3]
                rank = isrank(redis, userId, chatId)
                if (rank == "sudo" or rank == "sudos"):
                    li = redis.hkeys("{}Nbot:{}".format(BOT_ID, TY))
                    if li:
                        i = 1
                        words = ""
                        for word in li:
                            words = words + "\n" + str(i) + " - {" + word + "}"
                            i += 1
                            if len(words) > 3000:
                                Bot(
                                    "sendMessage", {
                                        "chat_id": userId,
                                        "text": words,
                                        "reply_to_message_id":
                                        message.message_id,
                                        "parse_mode": "html"
                                    })
                                words = ''
                        Bot(
                            "sendMessage", {
                                "chat_id": userId,
                                "text": words,
                                "reply_to_message_id": message.message_id,
                                "parse_mode": "html"
                            })
                        reply_markup = InlineKeyboardMarkup([[
                            InlineKeyboardButton(
                                r.Delall2R,
                                callback_data=json.dumps(
                                    ["del{}".format(TY + 'BOT'), "", userID])),
                        ]])
                        Bot(
                            "sendMessage", {
                                "chat_id": chatID,
                                "text": r.DelallR,
                                "reply_to_message_id": message.message_id,
                                "disable_web_page_preview": True,
                                "reply_markup": reply_markup
                            })

            if order == "showreplylist":
                chatId = split[1]
                userId = split[2]
                TY = split[3]
                group = redis.sismember("{}Nbot:groups".format(BOT_ID), chatId)
                rank = isrank(redis, userId, chatId)
                if (rank is not False or rank is not 0 or rank != "vip"
                        or rank != "admin") and group is True:
                    li = redis.hkeys("{}Nbot:{}:{}".format(BOT_ID, chatId, TY))
                    if li:
                        i = 1
                        words = ""
                        for word in li:
                            words = words + "\n" + str(i) + " - {" + word + "}"
                            i += 1
                            if len(words) > 3000:
                                Bot(
                                    "sendMessage", {
                                        "chat_id": userId,
                                        "text": words,
                                        "reply_to_message_id":
                                        message.message_id,
                                        "parse_mode": "html"
                                    })
                                words = ''
                        Bot(
                            "sendMessage", {
                                "chat_id": userId,
                                "text": words,
                                "reply_to_message_id": message.message_id,
                                "parse_mode": "html"
                            })
                        reply_markup = InlineKeyboardMarkup([[
                            InlineKeyboardButton(r.Delall2R,
                                                 callback_data=json.dumps([
                                                     "del{}".format(TY),
                                                     chatId, userID
                                                 ])),
                        ]])
                        Bot(
                            "sendMessage", {
                                "chat_id": chatID,
                                "text": r.DelallR,
                                "reply_to_message_id": message.message_id,
                                "disable_web_page_preview": True,
                                "reply_markup": reply_markup
                            })

            if order == "showBlocklist":
                chatId = split[1]
                userId = split[2]
                TY = split[3]
                group = redis.sismember("{}Nbot:groups".format(BOT_ID), chatId)
                rank = isrank(redis, userId, chatId)
                if (rank is not False or rank is not 0
                        or rank != "vip") and group is True:
                    redis.hset("{}Nbot:{}:TXreplys".format(BOT_ID, chatID), tx,
                               text)
                    li = redis.smembers("{}Nbot:{}:{}".format(
                        BOT_ID, chatId, TY))
                    print(li)
                    if li:
                        i = 1
                        words = ""
                        for ID in li:
                            reply_markup = InlineKeyboardMarkup([[
                                InlineKeyboardButton(r.Blocklistone,
                                                     callback_data=json.dumps([
                                                         "delfromb", TY,
                                                         userID, chatId
                                                     ])),
                            ]])
                            if TY == "blockanimations":
                                Bot(
                                    "sendAnimation", {
                                        "chat_id": userId,
                                        "animation": ID,
                                        "reply_markup": reply_markup
                                    })
                            if TY == "blockSTICKERs":
                                Bot(
                                    "sendSticker", {
                                        "chat_id": userId,
                                        "sticker": ID,
                                        "reply_markup": reply_markup
                                    })
                            if TY == "blockphotos":
                                Bot(
                                    "sendPhoto", {
                                        "chat_id": userId,
                                        "photo": ID,
                                        "reply_markup": reply_markup
                                    })
                            if TY == "blockTEXTs":
                                words = words + "\n" + str(
                                    i) + " - {" + ID + "}"
                                i += 1
                                print(len(words))
                                if len(words) > 3000:
                                    Bot(
                                        "sendMessage", {
                                            "chat_id": userId,
                                            "text": words,
                                            "reply_to_message_id":
                                            message.message_id,
                                            "parse_mode": "html"
                                        })
                                    words = ''
                        if TY == "blockTEXTs":

                            Bot(
                                "sendMessage", {
                                    "chat_id": userId,
                                    "text": words,
                                    "reply_to_message_id": message.message_id,
                                    "parse_mode": "html"
                                })

                        reply_markup = InlineKeyboardMarkup([[
                            InlineKeyboardButton(r.Delall2,
                                                 callback_data=json.dumps([
                                                     "delBL", TY, userID,
                                                     chatId
                                                 ])),
                        ]])
                        Bot(
                            "sendMessage", {
                                "chat_id": userId,
                                "text": r.Delall,
                                "reply_to_message_id": message.message_id,
                                "parse_mode": "html",
                                "reply_markup": reply_markup
                            })
                    else:
                        Bot(
                            "sendMessage", {
                                "chat_id": userId,
                                "text": r.listempty2,
                                "reply_to_message_id": message.message_id,
                                "parse_mode": "html"
                            })
示例#22
0
文件: tr.py 项目: r00t94/wtf
def updateMsgs(client, message, redis):
    type = message.chat.type
    userID = message.from_user.id
    chatID = message.chat.id
    rank = isrank(redis, userID, chatID)
    text = message.text
    title = message.chat.title
    userFN = message.from_user.first_name
    type = message.chat.type

    if text and text == "نقل البيانات" and rank == "sudo" and message.reply_to_message.document:
        msgID = Bot(
            "sendMessage", {
                "chat_id": chatID,
                "text": "انتظر قليلاً يتم تحميل الملف ℹ️",
                "reply_to_message_id": message.message_id,
                "parse_mode": "html",
                "disable_web_page_preview": True
            })["result"]["message_id"]

        fileName = message.reply_to_message.download()
        JsonDate = json.load(open(fileName))
        if int(JsonDate["BOT_ID"]) != int(BOT_ID):
            Bot(
                "editMessageText", {
                    "chat_id": chatID,
                    "text": "عذراً هذه الملف ليس لي ⚠️",
                    "message_id": msgID,
                    "disable_web_page_preview": True,
                    "parse_mode": "html"
                })
            return 0
        co = len(JsonDate["GP_BOT"])
        Bot(
            "editMessageText", {
                "chat_id": chatID,
                "text": f"تم ايجاد {co} مجموعه في الملف ℹ️",
                "message_id": msgID,
                "disable_web_page_preview": True,
                "parse_mode": "html"
            })
        for chatID in JsonDate["GP_BOT"].keys():
            try:
                time.sleep(0.1)
                print(chatID)
                Bot("exportChatInviteLink", {"chat_id": chatID})
                add = redis.sadd("{}Nbot:groups".format(BOT_ID), chatID)
                locksarray = {
                    'Llink', 'Llongtext', 'Lmarkdown', 'Linline', 'Lfiles',
                    'Lcontact', 'Lbots', 'Lfwd', 'Lnote'
                }
                for lock in locksarray:
                    redis.sadd("{}Nbot:{}".format(BOT_ID, lock), chatID)
                ads = Bot("getChatAdministrators", {"chat_id": chatID})
                for ad in ads['result']:
                    userId = ad["user"]["id"]
                    userFn = ad["user"]["first_name"]
                    if ad['status'] == "administrator" and int(userId) != int(
                            BOT_ID):
                        setrank(redis, "admin", userId, chatID, "array")
                    if ad['status'] == "creator":
                        setrank(redis, "malk", userId, chatID, "one")
                gpDate = JsonDate["GP_BOT"][chatID]
                if "ASAS" in gpDate:
                    for userId in gpDate["ASAS"]:
                        setrank(redis, "acreator", userId, chatID, "array")
                if "MNSH" in gpDate:
                    for userId in gpDate["MNSH"]:
                        setrank(redis, "creator", userId, chatID, "array")
                if "MDER" in gpDate:
                    for userId in gpDate["MDER"]:
                        setrank(redis, "owner", userId, chatID, "array")
                if "MOD" in gpDate:
                    for userId in gpDate["MOD"]:
                        setrank(redis, "admin", userId, chatID, "array")
            except Exception as e:
                print(e)
        Bot(
            "editMessageText", {
                "chat_id": chatID,
                "text": f"تم نقل المجموعات ✅",
                "message_id": msgID,
                "disable_web_page_preview": True,
                "parse_mode": "html"
            })
示例#23
0
文件: all.py 项目: MetalGhost1/NewBot
def allGP(client, message, redis):
    type = message.chat.type
    userID = message.from_user.id
    chatID = message.chat.id
    username = message.from_user.username
    if username is None:
        username = "******"
    userFN = message.from_user.first_name
    title = message.chat.title
    rank = isrank(redis, userID, chatID)
    text = message.text
    if redis.sismember("{}Nbot:lang:ar".format(BOT_ID), chatID):
        lang = "ar"
    elif redis.sismember("{}Nbot:lang:en".format(BOT_ID), chatID):
        lang = "en"
    else:
        lang = "ar"
    moduleCMD = "lang." + lang + "-cmd"
    moduleREPLY = "lang." + lang + "-reply"
    c = importlib.import_module(moduleCMD)
    r = importlib.import_module(moduleREPLY)
    redis.hincrby("{}Nbot:{}:msgs".format(BOT_ID, chatID), userID)
    if text:
        if re.search(c.ShowO, text) and (rank is not False or rank is not 0
                                         or rank != "vip"):
            reply_markup = getOR(rank, r, userID)
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": r.Showall,
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html",
                    "disable_web_page_preview": True,
                    "reply_markup": reply_markup
                })

        if text == c.ID and not redis.sismember(
                "{}Nbot:IDSend".format(BOT_ID),
                chatID) and not message.reply_to_message:
            Ch = True
            if redis.sismember("{}Nbot:IDpt".format(BOT_ID), chatID):
                t = IDrank(redis, userID, chatID, r)
                msgs = (redis.hget("{}Nbot:{}:msgs".format(BOT_ID, chatID),
                                   userID) or 0)
                edits = (redis.hget("{}Nbot:{}:edits".format(BOT_ID, chatID),
                                    userID) or 0)
                rate = int(msgs) * 100 / 20000
                if redis.hget("{}Nbot:SHOWid".format(BOT_ID), chatID):
                    tx = redis.hget("{}Nbot:SHOWid".format(BOT_ID), chatID)
                else:
                    tx = r.IDnPT
                if not redis.sismember("{}Nbot:IDSendPH".format(BOT_ID),
                                       chatID):
                    get = Bot("getUserProfilePhotos", {
                        "user_id": userID,
                        "offset": 0,
                        "limit": 1
                    })
                    if get["ok"] == False:
                        Ch = True
                    elif get["result"]["total_count"] == 0:
                        Ch = True
                    else:
                        Ch = False
                        file_id = get["result"]["photos"][0][0]["file_id"]
                        Bot(
                            "sendPhoto", {
                                "chat_id":
                                chatID,
                                "photo":
                                file_id,
                                "caption":
                                tx.format(us=("@" + username or "None"),
                                          id=userID,
                                          rk=t,
                                          msgs=msgs,
                                          edits=edits,
                                          rate=str(rate) + "%"),
                                "reply_to_message_id":
                                message.message_id,
                                "parse_mode":
                                "html"
                            })
                if Ch == True:
                    Bot(
                        "sendMessage", {
                            "chat_id":
                            chatID,
                            "text":
                            tx.format(us=("@" + username or "None"),
                                      id=userID,
                                      rk=t,
                                      msgs=msgs,
                                      edits=edits,
                                      rate=str(rate) + "%"),
                            "reply_to_message_id":
                            message.message_id,
                            "parse_mode":
                            "html"
                        })

            if not redis.sismember("{}Nbot:IDSendPH".format(BOT_ID),
                                   chatID) and not redis.sismember(
                                       "{}Nbot:IDpt".format(BOT_ID), chatID):
                get = Bot("getUserProfilePhotos", {
                    "user_id": userID,
                    "offset": 0,
                    "limit": 1
                })
                if get["ok"] == False:
                    Ch = True
                elif get["result"]["total_count"] == 0:
                    Ch = True
                else:
                    Ch = False
                    reply_markup = InlineKeyboardMarkup([[
                        InlineKeyboardButton(r.RIDPHs,
                                             callback_data=json.dumps(
                                                 ["ShowDateUser", "", userID]))
                    ]])
                    file_id = get["result"]["photos"][0][0]["file_id"]
                    Bot(
                        "sendPhoto", {
                            "chat_id": chatID,
                            "photo": file_id,
                            "caption": r.RID.format(userID),
                            "reply_to_message_id": message.message_id,
                            "parse_mode": "html",
                            "reply_markup": reply_markup
                        })
            if Ch == True and not redis.sismember("{}Nbot:IDpt".format(BOT_ID),
                                                  chatID):
                reply_markup = InlineKeyboardMarkup([[
                    InlineKeyboardButton(r.RIDPHs,
                                         callback_data=json.dumps(
                                             ["ShowDateUser", "", userID]))
                ]])
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.RID.format(userID),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "reply_markup": reply_markup
                    })

        if text == c.ID and not redis.sismember(
                "{}Nbot:IDSend".format(BOT_ID),
                chatID) and message.reply_to_message:
            us = message.reply_to_message.from_user.id
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": us,
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html"
                })
        if re.search(c.idus, text) and not redis.sismember(
                "{}Nbot:IDSend".format(BOT_ID), chatID):
            user = text.split("@")[1]
            try:
                getUser = client.get_users(user)
                us = getUser.id
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": us,
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html"
                    })
            except Exception as e:
                print(e)

        if re.search(c.ShowSudos, text):
            tx = (redis.get("{}Nbot:SHOWsudos".format(BOT_ID)) or "")
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": tx,
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html"
                })
        if text == c.mymsgs:
            get = redis.hget("{}Nbot:{}:msgs".format(BOT_ID, chatID), userID)
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": r.yourmsgs.format((get or 0)),
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html"
                })
        if text == c.link:
            get = (redis.hget("{}Nbot:links".format(BOT_ID), chatID)
                   or GetLink(chatID) or "none")
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": r.showGPlk.format(get),
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html",
                    "disable_web_page_preview": True
                })

        if text == c.myedits:
            get = redis.hget("{}Nbot:{}:edits".format(BOT_ID, chatID), userID)
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": r.youredits.format((get or 0)),
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html"
                })

        if text == c.myaddcontact:
            get = redis.hget("{}Nbot:{}:addcontact".format(BOT_ID, chatID),
                             userID)
            Bot(
                "sendMessage", {
                    "chat_id": chatID,
                    "text": r.youraddcontact.format((get or 0)),
                    "reply_to_message_id": message.message_id,
                    "parse_mode": "html"
                })

        if not redis.sismember("{}Nbot:ReplySendBOT".format(BOT_ID), chatID):
            if redis.hexists("{}Nbot:TXreplys".format(BOT_ID), text):
                tx = redis.hget("{}Nbot:TXreplys".format(BOT_ID), text)
                Bot(
                    "sendMessage", {
                        "chat_id":
                        chatID,
                        "text":
                        tx.format(fn=Name(userFn),
                                  us=("@" + username or "none"),
                                  id=userID,
                                  rk=IDrank(redis, userID, chatID, r),
                                  cn=title),
                        "reply_to_message_id":
                        message.message_id,
                        "parse_mode":
                        "html"
                    })

            if redis.hexists("{}Nbot:STreplys".format(BOT_ID), text):
                ID = redis.hget("{}Nbot:STreplys".format(BOT_ID), text)
                Bot(
                    "sendSticker", {
                        "chat_id": chatID,
                        "sticker": ID,
                        "reply_to_message_id": message.message_id
                    })

            if redis.hexists("{}Nbot:GFreplys".format(BOT_ID), text):
                ID = redis.hget("{}Nbot:GFreplys".format(BOT_ID), text)
                Bot(
                    "sendanimation", {
                        "chat_id": chatID,
                        "animation": ID,
                        "reply_to_message_id": message.message_id
                    })

            if redis.hexists("{}Nbot:{}:VOreplys".format(BOT_ID, chatID),
                             text):
                ID = redis.hget("{}Nbot:VOreplys".format(BOT_ID), text)
                Bot(
                    "sendvoice", {
                        "chat_id": chatID,
                        "voice": ID,
                        "reply_to_message_id": message.message_id
                    })

        if not redis.sismember("{}Nbot:ReplySend".format(BOT_ID), chatID):
            if redis.hexists("{}Nbot:{}:TXreplys".format(BOT_ID, chatID),
                             text):
                tx = redis.hget("{}Nbot:{}:TXreplys".format(BOT_ID, chatID),
                                text)
                Bot(
                    "sendMessage", {
                        "chat_id":
                        chatID,
                        "text":
                        tx.format(fn=Name(userFN),
                                  us=("@" + username or "n"),
                                  id=userID,
                                  rk=IDrank(redis, userID, chatID, r),
                                  cn=title),
                        "reply_to_message_id":
                        message.message_id,
                        "parse_mode":
                        "html"
                    })

            if redis.hexists("{}Nbot:{}:STreplys".format(BOT_ID, chatID),
                             text):
                ID = redis.hget("{}Nbot:{}:STreplys".format(BOT_ID, chatID),
                                text)
                Bot(
                    "sendSticker", {
                        "chat_id": chatID,
                        "sticker": ID,
                        "reply_to_message_id": message.message_id
                    })

            if redis.hexists("{}Nbot:{}:GFreplys".format(BOT_ID, chatID),
                             text):
                ID = redis.hget("{}Nbot:{}:GFreplys".format(BOT_ID, chatID),
                                text)
                Bot(
                    "sendanimation", {
                        "chat_id": chatID,
                        "animation": ID,
                        "reply_to_message_id": message.message_id
                    })

            if redis.hexists("{}Nbot:{}:VOreplys".format(BOT_ID, chatID),
                             text):
                ID = redis.hget("{}Nbot:{}:VOreplys".format(BOT_ID, chatID),
                                text)
                Bot(
                    "sendvoice", {
                        "chat_id": chatID,
                        "voice": ID,
                        "reply_to_message_id": message.message_id
                    })
示例#24
0
def delete(client, message, redis):
    #print(message)
    type = message.chat.type
    userID = message.from_user.id
    userFN = message.from_user.first_name
    chatID = message.chat.id
    rank = isrank(redis, userID, chatID)
    if message.text:
        text = message.text
    elif message.caption:
        text = message.caption
    else:
        text = 0
    lang = Glang(redis, chatID)
    moduleCMD = "lang." + lang + "-cmd"
    moduleREPLY = "lang." + lang + "-reply"
    c = importlib.import_module(moduleCMD)
    r = importlib.import_module(moduleREPLY)
    if redis.sismember("{}Nbot:restricteds".format(BOT_ID), userID):
        Bot(
            "restrictChatMember", {
                "chat_id": chatID,
                "user_id": userId,
                "can_send_messages": 0,
                "can_send_media_messages": 0,
                "can_send_other_messages": 0,
                "can_send_polls": 0,
                "can_change_info": 0,
                "can_add_web_page_previews": 0,
                "can_pin_messages": 0,
                "can_invite_users": 0,
            })
    if redis.sismember("{}Nbot:bans".format(BOT_ID), userID):
        Bot("kickChatMember", {"chat_id": chatID, "user_id": userID})

    if text:
        if text == c.kickme and not redis.sismember(
                "{}Nbot:kickme".format(BOT_ID), chatID):
            GetGprank = GPranks(userID, chatID)
            if GetGprank == "member":
                reply_markup = InlineKeyboardMarkup([[
                    InlineKeyboardButton(r.yes,
                                         callback_data=json.dumps(
                                             ["kickme-yes", "", userID])),
                    InlineKeyboardButton(r.no,
                                         callback_data=json.dumps(
                                             ["kickme-no", "", userID])),
                ]])
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.kickme,
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "reply_markup": reply_markup
                    })

        if re.findall(
                "[Hh][Tt][Tt][Pp][Ss]:/|[Hh][Tt][Tt][Pp]://|.[Ii][Rr]|.[Cc][Oo][Mm]|.[Oo][Rr][Gg]|.[Ii][Nn][Ff][Oo]|[Ww][Ww][Ww]|.[Tt][Kk]|.[Mm][Ee]",
                text):
            if redis.sismember("{}Nbot:Llink".format(BOT_ID), chatID):  #1
                Bot("deleteMessage", {
                    "chat_id": chatID,
                    "message_id": message.message_id
                })
                if redis.sismember("{}Nbot:Llink:res".format(BOT_ID), chatID):
                    Bot(
                        "restrictChatMember", {
                            "chat_id": chatID,
                            "user_id": userId,
                            "can_send_messages": 0,
                            "can_send_media_messages": 0,
                            "can_send_other_messages": 0,
                            "can_send_polls": 0,
                            "can_change_info": 0,
                            "can_add_web_page_previews": 0,
                            "can_pin_messages": 0,
                            "can_invite_users": 0,
                        })

        if re.findall('@', text):
            if redis.sismember("{}Nbot:Lusername".format(BOT_ID), chatID):  #2
                Bot("deleteMessage", {
                    "chat_id": chatID,
                    "message_id": message.message_id
                })
                if redis.sismember("{}Nbot:Lusername:res".format(BOT_ID),
                                   chatID):
                    Bot(
                        "restrictChatMember", {
                            "chat_id": chatID,
                            "user_id": userId,
                            "can_send_messages": 0,
                            "can_send_media_messages": 0,
                            "can_send_other_messages": 0,
                            "can_send_polls": 0,
                            "can_change_info": 0,
                            "can_add_web_page_previews": 0,
                            "can_pin_messages": 0,
                            "can_invite_users": 0,
                        })

        if message.forward_date:
            if redis.sismember("{}Nbot:Lfwd".format(BOT_ID), chatID):  #18
                Bot("deleteMessage", {
                    "chat_id": chatID,
                    "message_id": message.message_id
                })
                if redis.sismember("{}Nbot:Lfwd:res".format(BOT_ID), chatID):
                    Bot(
                        "restrictChatMember", {
                            "chat_id": chatID,
                            "user_id": userId,
                            "can_send_messages": 0,
                            "can_send_media_messages": 0,
                            "can_send_other_messages": 0,
                            "can_send_polls": 0,
                            "can_change_info": 0,
                            "can_add_web_page_previews": 0,
                            "can_pin_messages": 0,
                            "can_invite_users": 0,
                        })

        if re.findall('#', text):
            if redis.sismember("{}Nbot:Ltag".format(BOT_ID), chatID):  #3
                Bot("deleteMessage", {
                    "chat_id": chatID,
                    "message_id": message.message_id
                })
                if redis.sismember("{}Nbot:Ltag:res".format(BOT_ID), chatID):
                    Bot(
                        "restrictChatMember", {
                            "chat_id": chatID,
                            "user_id": userId,
                            "can_send_messages": 0,
                            "can_send_media_messages": 0,
                            "can_send_other_messages": 0,
                            "can_send_polls": 0,
                            "can_change_info": 0,
                            "can_add_web_page_previews": 0,
                            "can_pin_messages": 0,
                            "can_invite_users": 0,
                        })

        if re.findall("[a-zA-Z0-9$@$!%*?&#^-_. +]+", text):
            if redis.sismember("{}Nbot:Lenglish".format(BOT_ID), chatID):  #4
                Bot("deleteMessage", {
                    "chat_id": chatID,
                    "message_id": message.message_id
                })
                if redis.sismember("{}Nbot:Lenglish:res".format(BOT_ID),
                                   chatID):
                    Bot(
                        "restrictChatMember", {
                            "chat_id": chatID,
                            "user_id": userId,
                            "can_send_messages": 0,
                            "can_send_media_messages": 0,
                            "can_send_other_messages": 0,
                            "can_send_polls": 0,
                            "can_change_info": 0,
                            "can_add_web_page_previews": 0,
                            "can_pin_messages": 0,
                            "can_invite_users": 0,
                        })

        if re.findall("[ا-ي٠-٩]", text):
            if redis.sismember("{}Nbot:Larabic".format(BOT_ID), chatID):  #5
                Bot("deleteMessage", {
                    "chat_id": chatID,
                    "message_id": message.message_id
                })
                if redis.sismember("{}Nbot:Larabic:res".format(BOT_ID),
                                   chatID):
                    Bot(
                        "restrictChatMember", {
                            "chat_id": chatID,
                            "user_id": userId,
                            "can_send_messages": 0,
                            "can_send_media_messages": 0,
                            "can_send_other_messages": 0,
                            "can_send_polls": 0,
                            "can_change_info": 0,
                            "can_add_web_page_previews": 0,
                            "can_pin_messages": 0,
                            "can_invite_users": 0,
                        })

        Nlongtext = (redis.get("{}Nbot:Nlongtext".format(BOT_ID)) or 250)
        if len(text) >= Nlongtext:
            if redis.sismember("{}Nbot:Llongtext".format(BOT_ID), chatID):  #2
                Bot("deleteMessage", {
                    "chat_id": chatID,
                    "message_id": message.message_id
                })
                if redis.sismember("{}Nbot:Llongtext:res".format(BOT_ID),
                                   chatID):
                    Bot(
                        "restrictChatMember", {
                            "chat_id": chatID,
                            "user_id": userId,
                            "can_send_messages": 0,
                            "can_send_media_messages": 0,
                            "can_send_other_messages": 0,
                            "can_send_polls": 0,
                            "can_change_info": 0,
                            "can_add_web_page_previews": 0,
                            "can_pin_messages": 0,
                            "can_invite_users": 0,
                        })

        li = redis.smembers("{}Nbot:{}:blockTEXTs".format(BOT_ID, chatID))
        for word in li:
            if re.findall(word, text):
                Bot("deleteMessage", {
                    "chat_id": chatID,
                    "message_id": message.message_id
                })
                break


# text ^

    if message.entities:
        if redis.sismember("{}Nbot:Lmarkdown".format(BOT_ID), chatID):  #6
            for entitie in message.entities:
                if entitie.type is "text_link":
                    Bot("deleteMessage", {
                        "chat_id": chatID,
                        "message_id": message.message_id
                    })
                    if redis.sismember("{}Nbot:Lmarkdown:res".format(BOT_ID),
                                       chatID):
                        Bot(
                            "restrictChatMember", {
                                "chat_id": chatID,
                                "user_id": userId,
                                "can_send_messages": 0,
                                "can_send_media_messages": 0,
                                "can_send_other_messages": 0,
                                "can_send_polls": 0,
                                "can_change_info": 0,
                                "can_add_web_page_previews": 0,
                                "can_pin_messages": 0,
                                "can_invite_users": 0,
                            })

                    break

    if message.via_bot:
        if redis.sismember("{}Nbot:Linline".format(BOT_ID), chatID):  #7
            Bot("deleteMessage", {
                "chat_id": chatID,
                "message_id": message.message_id
            })
            if redis.sismember("{}Nbot:Linline:res".format(BOT_ID), chatID):
                Bot(
                    "restrictChatMember", {
                        "chat_id": chatID,
                        "user_id": userId,
                        "can_send_messages": 0,
                        "can_send_media_messages": 0,
                        "can_send_other_messages": 0,
                        "can_send_polls": 0,
                        "can_change_info": 0,
                        "can_add_web_page_previews": 0,
                        "can_pin_messages": 0,
                        "can_invite_users": 0,
                    })

    if message.reply_markup:
        if redis.sismember("{}Nbot:Linline".format(BOT_ID), chatID):
            Bot("deleteMessage", {
                "chat_id": chatID,
                "message_id": message.message_id
            })
            if redis.sismember("{}Nbot:Linline:res".format(BOT_ID), chatID):
                Bot(
                    "restrictChatMember", {
                        "chat_id": chatID,
                        "user_id": userId,
                        "can_send_messages": 0,
                        "can_send_media_messages": 0,
                        "can_send_other_messages": 0,
                        "can_send_polls": 0,
                        "can_change_info": 0,
                        "can_add_web_page_previews": 0,
                        "can_pin_messages": 0,
                        "can_invite_users": 0,
                    })

    if message.sticker:
        if redis.sismember("{}Nbot:Lsticker".format(BOT_ID), chatID):  #8
            Bot("deleteMessage", {
                "chat_id": chatID,
                "message_id": message.message_id
            })
            if redis.sismember("{}Nbot:Lsticker:res".format(BOT_ID), chatID):
                Bot(
                    "restrictChatMember", {
                        "chat_id": chatID,
                        "user_id": userId,
                        "can_send_messages": 0,
                        "can_send_media_messages": 0,
                        "can_send_other_messages": 0,
                        "can_send_polls": 0,
                        "can_change_info": 0,
                        "can_add_web_page_previews": 0,
                        "can_pin_messages": 0,
                        "can_invite_users": 0,
                    })

        elif redis.sismember("{}Nbot:{}:blockSTICKERs".format(BOT_ID, chatID),
                             message.sticker.file_id):
            Bot("deleteMessage", {
                "chat_id": chatID,
                "message_id": message.message_id
            })

    if message.animation:
        if redis.sismember("{}Nbot:Lgifs".format(BOT_ID), chatID):  #9
            Bot("deleteMessage", {
                "chat_id": chatID,
                "message_id": message.message_id
            })
            if redis.sismember("{}Nbot:Lgifs:res".format(BOT_ID), chatID):
                Bot(
                    "restrictChatMember", {
                        "chat_id": chatID,
                        "user_id": userId,
                        "can_send_messages": 0,
                        "can_send_media_messages": 0,
                        "can_send_other_messages": 0,
                        "can_send_polls": 0,
                        "can_change_info": 0,
                        "can_add_web_page_previews": 0,
                        "can_pin_messages": 0,
                        "can_invite_users": 0,
                    })

        elif redis.sismember(
                "{}Nbot:{}:blockanimations".format(BOT_ID, chatID),
                message.animation.file_id):
            Bot("deleteMessage", {
                "chat_id": chatID,
                "message_id": message.message_id
            })

    if message.audio:
        if redis.sismember("{}Nbot:Lmusic".format(BOT_ID), chatID):  #10
            Bot("deleteMessage", {
                "chat_id": chatID,
                "message_id": message.message_id
            })
            if redis.sismember("{}Nbot:Lmusic:res".format(BOT_ID), chatID):
                Bot(
                    "restrictChatMember", {
                        "chat_id": chatID,
                        "user_id": userId,
                        "can_send_messages": 0,
                        "can_send_media_messages": 0,
                        "can_send_other_messages": 0,
                        "can_send_polls": 0,
                        "can_change_info": 0,
                        "can_add_web_page_previews": 0,
                        "can_pin_messages": 0,
                        "can_invite_users": 0,
                    })

    if message.voice:
        if redis.sismember("{}Nbot:Lvoice".format(BOT_ID), chatID):  #11
            Bot("deleteMessage", {
                "chat_id": chatID,
                "message_id": message.message_id
            })
            if redis.sismember("{}Nbot:Lvoice:res".format(BOT_ID), chatID):
                Bot(
                    "restrictChatMember", {
                        "chat_id": chatID,
                        "user_id": userId,
                        "can_send_messages": 0,
                        "can_send_media_messages": 0,
                        "can_send_other_messages": 0,
                        "can_send_polls": 0,
                        "can_change_info": 0,
                        "can_add_web_page_previews": 0,
                        "can_pin_messages": 0,
                        "can_invite_users": 0,
                    })

    if message.video:
        if redis.sismember("{}Nbot:Lvideo".format(BOT_ID), chatID):  #12
            Bot("deleteMessage", {
                "chat_id": chatID,
                "message_id": message.message_id
            })
            if redis.sismember("{}Nbot:Lvideo:res".format(BOT_ID), chatID):
                Bot(
                    "restrictChatMember", {
                        "chat_id": chatID,
                        "user_id": userId,
                        "can_send_messages": 0,
                        "can_send_media_messages": 0,
                        "can_send_other_messages": 0,
                        "can_send_polls": 0,
                        "can_change_info": 0,
                        "can_add_web_page_previews": 0,
                        "can_pin_messages": 0,
                        "can_invite_users": 0,
                    })

    if message.document:
        if redis.sismember("{}Nbot:Lfiles".format(BOT_ID), chatID):  #13
            Bot("deleteMessage", {
                "chat_id": chatID,
                "message_id": message.message_id
            })
            if redis.sismember("{}Nbot:Lfiles:res".format(BOT_ID), chatID):
                Bot(
                    "restrictChatMember", {
                        "chat_id": chatID,
                        "user_id": userId,
                        "can_send_messages": 0,
                        "can_send_media_messages": 0,
                        "can_send_other_messages": 0,
                        "can_send_polls": 0,
                        "can_change_info": 0,
                        "can_add_web_page_previews": 0,
                        "can_pin_messages": 0,
                        "can_invite_users": 0,
                    })

    if message.photo:
        if redis.sismember("{}Nbot:Lphoto".format(BOT_ID), chatID):  #14
            Bot("deleteMessage", {
                "chat_id": chatID,
                "message_id": message.message_id
            })
            if redis.sismember("{}Nbot:Lphoto:res".format(BOT_ID), chatID):
                Bot(
                    "restrictChatMember", {
                        "chat_id": chatID,
                        "user_id": userId,
                        "can_send_messages": 0,
                        "can_send_media_messages": 0,
                        "can_send_other_messages": 0,
                        "can_send_polls": 0,
                        "can_change_info": 0,
                        "can_add_web_page_previews": 0,
                        "can_pin_messages": 0,
                        "can_invite_users": 0,
                    })

        elif redis.sismember("{}Nbot:{}:blockphotos".format(BOT_ID, chatID),
                             message.photo.file_id):
            Bot("deleteMessage", {
                "chat_id": chatID,
                "message_id": message.message_id
            })

    if message.contact:
        if redis.sismember("{}Nbot:Lcontact".format(BOT_ID), chatID):  #15
            Bot("deleteMessage", {
                "chat_id": chatID,
                "message_id": message.message_id
            })
            if redis.sismember("{}Nbot:Lcontact:res".format(BOT_ID), chatID):
                Bot(
                    "restrictChatMember", {
                        "chat_id": chatID,
                        "user_id": userId,
                        "can_send_messages": 0,
                        "can_send_media_messages": 0,
                        "can_send_other_messages": 0,
                        "can_send_polls": 0,
                        "can_change_info": 0,
                        "can_add_web_page_previews": 0,
                        "can_pin_messages": 0,
                        "can_invite_users": 0,
                    })

    if message.new_chat_members:
        if message.new_chat_members[0].is_bot:
            if redis.sismember("{}Nbot:Lbots".format(BOT_ID), chatID):  #16
                first_name = message.new_chat_members[0].first_name
                username = message.new_chat_members[0].username
                Bot("kickChatMember", {
                    "chat_id": chatID,
                    "user_id": message.new_chat_members[0].id
                })
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.kickbotadd.format(username, first_name),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html"
                    })
        if redis.sismember("{}Nbot:Ljoin".format(BOT_ID), chatID):  #17
            Bot("deleteMessage", {
                "chat_id": chatID,
                "message_id": message.message_id
            })

    if message.forward_date:
        if redis.sismember("{}Nbot:Lfwd".format(BOT_ID), chatID):  #18
            Bot("deleteMessage", {
                "chat_id": chatID,
                "message_id": message.message_id
            })
            if redis.sismember("{}Nbot:Lfwd:res".format(BOT_ID), chatID):
                Bot(
                    "restrictChatMember", {
                        "chat_id": chatID,
                        "user_id": userId,
                        "can_send_messages": 0,
                        "can_send_media_messages": 0,
                        "can_send_other_messages": 0,
                        "can_send_polls": 0,
                        "can_change_info": 0,
                        "can_add_web_page_previews": 0,
                        "can_pin_messages": 0,
                        "can_invite_users": 0,
                    })

    if message.video_note:
        if redis.sismember("{}Nbot:Lnote".format(BOT_ID), chatID):  #19
            Bot("deleteMessage", {
                "chat_id": chatID,
                "message_id": message.message_id
            })
            if redis.sismember("{}Nbot:Lnote:res".format(BOT_ID), chatID):
                Bot(
                    "restrictChatMember", {
                        "chat_id": chatID,
                        "user_id": userId,
                        "can_send_messages": 0,
                        "can_send_media_messages": 0,
                        "can_send_other_messages": 0,
                        "can_send_polls": 0,
                        "can_change_info": 0,
                        "can_add_web_page_previews": 0,
                        "can_pin_messages": 0,
                        "can_invite_users": 0,
                    })

    if redis.sismember("{}Nbot:Lflood".format(BOT_ID), chatID):  #20
        Max_msg = int((redis.hget("{}Nbot:max_msg".format(BOT_ID), chatID)
                       or 10))
        Time_ck = int((redis.hget("{}Nbot:time_ck".format(BOT_ID), chatID)
                       or 3))
        User_msg = int(
            (redis.get("{}Nbot:{}:{}:flood".format(BOT_ID, chatID, userID))
             or 1))
        if User_msg > Max_msg:
            GetGprank = GPranks(userID, chatID)
            if GetGprank == "member":

                if redis.hexists("{}Nbot:floodset".format(BOT_ID), chatID):
                    get = redis.hget("{}Nbot:floodset".format(BOT_ID), chatID)
                else:
                    get = "res"
                if get == "res":
                    Bot(
                        "restrictChatMember", {
                            "chat_id": chatID,
                            "user_id": userId,
                            "can_send_messages": 0,
                            "can_send_media_messages": 0,
                            "can_send_other_messages": 0,
                            "can_send_polls": 0,
                            "can_change_info": 0,
                            "can_add_web_page_previews": 0,
                            "can_pin_messages": 0,
                            "can_invite_users": 0,
                        })
                if get == "ban":
                    Bot("kickChatMember", {
                        "chat_id": chatID,
                        "user_id": userID
                    })

                redis.sadd("{}Nbot:{}:restricteds".format(BOT_ID, chatID),
                           userID)
                BY = "<a href=\"tg://user?id={}\">{}</a>".format(
                    userID, Name(userFN))
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": r.TKflood.format(BY, Max_msg, Time_ck),
                        "parse_mode": "html"
                    })
        redis.setex("{}Nbot:{}:{}:flood".format(BOT_ID, chatID, userID),
                    Time_ck, User_msg + 1)
示例#25
0
def sudo(client, message,redis):
	type = message.chat.type
	userID = message.from_user.id
	chatID = message.chat.id
	rank = isrank(redis,userID,chatID)
	text = message.text
	title = message.chat.title
	userFN = message.from_user.first_name
	type = message.chat.type
	c = importlib.import_module("lang.arcmd")
	r = importlib.import_module("lang.arreply")
	if redis.hexists("{}Nbot:stepSUDO:or".format(BOT_ID),userID):
		tx = redis.hget("{}Nbot:stepSUDO:or".format(BOT_ID),userID)
		if text :
			redis.sadd("{}Nbot:{}:TXPoeders".format(BOT_ID,chatID),f"{tx}={text}")
			redis.hdel("{}Nbot:stepSUDO:or".format(BOT_ID),userID)
			Bot("sendMessage",{"chat_id":chatID,"text":f"✅꒐ تم اضافه الامر {tx} الى {text}","reply_to_message_id":message.message_id,"parse_mode":"html"})


	if redis.hexists("{}Nbot:stepSUDO".format(BOT_ID),userID):

		
		tx = redis.hget("{}Nbot:stepSUDO".format(BOT_ID),userID)
		if text :
			redis.hset("{}Nbot:TXreplys".format(BOT_ID),tx,text)
			redis.hdel("{}Nbot:stepSUDO".format(BOT_ID),userID)
			Bot("sendMessage",{"chat_id":chatID,"text":r.SRtext.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})
		
		if message.sticker:
			ID = message.sticker.file_id
			redis.hset("{}Nbot:STreplys".format(BOT_ID),tx,ID)
			redis.hdel("{}Nbot:stepSUDO".format(BOT_ID),userID)
			Bot("sendMessage",{"chat_id":chatID,"text":r.SRst.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})

		if message.animation:
			ID = message.animation.file_id
			redis.hset("{}Nbot:GFreplys".format(BOT_ID),tx,ID)
			redis.hdel("{}Nbot:stepSUDO".format(BOT_ID),userID)
			Bot("sendMessage",{"chat_id":chatID,"text":r.SRgf.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})

		if message.voice:
			ID = message.voice.file_id
			redis.hset("{}Nbot:VOreplys".format(BOT_ID),tx,ID)
			redis.hdel("{}Nbot:stepSUDO".format(BOT_ID),userID)
			Bot("sendMessage",{"chat_id":chatID,"text":r.SRvo.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})

		if message.photo:
			ID = message.photo.file_id
			redis.hset("{}Nbot:PHreplys".format(BOT_ID),tx,ID)
			redis.hdel("{}Nbot:stepSUDO".format(BOT_ID),userID)
			Bot("sendMessage",{"chat_id":chatID,"text":r.SRph.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})
		if message.document:
			ID = message.document.file_id
			redis.hset("{}Nbot:DOreplys".format(BOT_ID),tx,ID)
			redis.hdel("{}Nbot:stepSUDO".format(BOT_ID),userID)
			Bot("sendMessage",{"chat_id":chatID,"text":r.SRfi.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})



	if text and (type is "supergroup" or type is "group"):
		if rank == "sudo":
			if text == "وضع مجموعه المطور":
				redis.set("{}Nbot:sudogp".format(BOT_ID),chatID)
				Bot("sendMessage",{"chat_id":chatID,"text":f"✅꒐ تم تحديد المجموعه لاستلام الاشعارات \n{title} {chatID}","reply_to_message_id":message.message_id,"parse_mode":"html"})
		if re.search("^اضف امر عام (.*)$",text):
			cc = re.findall("^اضف امر عام (.*)$",text)
			redis.hset("{}Nbot:stepSUDO:or".format(BOT_ID),userID,cc[0])
			message.reply_text(f"⏺꒐ الان ارسل الامر ليتم تغيره الى {cc[0]}")
		if re.search("^الاوامر العامه$",text):
			tx = "الاوامر العامه ℹ️:\n"
			x = redis.smembers("{}Nbot:{}:TXPoeders".format(BOT_ID,chatID))
			if not x :
				message.reply_text(r.listempty2)
				return 0
			i = 1
			for x in x:
				x = x.split("=")
				tx = tx+f"{i} - {x[0]} > {x[1]}\n"
				i +=1
			kb = InlineKeyboardMarkup([[InlineKeyboardButton(r.delList.format(text), callback_data=json.dumps(["delList","TXPoeders",userID]))]])
			message.reply_text(tx,reply_markup=kb)
			
		if re.search("^مسح الامر العام (.*)$",text):
			cc = re.findall("^مسح الامر العام (.*)$",text)[0]
			x = redis.smembers("{}Nbot:{}:TXPoeders".format(BOT_ID,chatID))
			for x1 in x:
				x = x1.split("=")
				if x[0] == cc:
					redis.srem("{}Nbot:{}:TXPoeders".format(BOT_ID,chatID),x1)
					message.reply_text(f"✅꒐ تم حذف الامر {cc} من الاوامر العامه")
					return 0
			message.reply_text(f"⚠️꒐ لا يوجد {cc} امر")
		if re.search(c.leaveChatS, text) and redis.get("{}Nbot:leaveaddbot".format(BOT_ID)) :
			Bot("leaveChat",{"chat_id":chatID})
			redis.srem("{}Nbot:groups".format(BOT_ID),chatID)
			redis.sadd("{}Nbot:disabledgroups".format(BOT_ID),chatID)
			NextDay_Date = datetime.datetime.today() + datetime.timedelta(days=1)
			redis.hset("{}Nbot:disabledgroupsTIME".format(BOT_ID),chatID,str(NextDay_Date))
		text = text.replace("مسح ","")
		if re.search(c.malk, text) and Ckuser(message):
			arrays = redis.get("{}Nbot:{}:malk".format(BOT_ID,chatID))
			if arrays:
				b = BYusers({arrays},chatID,redis,client)
				if	b is not "":
					Bot("sendMessage",{"chat_id":chatID,"text":r.showlist.format(text,b),"reply_to_message_id":message.message_id,"parse_mode":"markdown"})
				else:
					Bot("sendMessage",{"chat_id":chatID,"text":r.listempty.format(text),"reply_to_message_id":message.message_id,"parse_mode":"markdown"})
			else:
				Bot("sendMessage",{"chat_id":chatID,"text":r.listempty.format(text),"reply_to_message_id":message.message_id,"parse_mode":"markdown"})

		if re.search(c.setmalk, text) and Ckuser(message):
			if re.search("@",text):
				user = text.split("@")[1]
			if re.search(c.setmalk2,text):
				user = text.split(" ")[2]
			if message.reply_to_message:
				user = message.reply_to_message.from_user.id
			if 'user' not in locals():return False
			try:
				getUser = client.get_users(user)
				userId = getUser.id
				userFn = getUser.first_name
				setcr = setrank(redis,"malk",userId,chatID,"one")
				if setcr is "malk":
					send_msg("UD",client, message,r.DsetRK,"",getUser,redis)
				elif (setcr is True or setcr is 1):
					send_msg("UD",client, message,r.setRK,"",getUser,redis)
			except Exception as e:
				Bot("sendMessage",{"chat_id":chatID,"text":r.userNocc,"reply_to_message_id":message.message_id,"parse_mode":"html"})

		if re.search(c.remmalk, text) and Ckuser(message):
			if re.search("@",text):
				user = text.split("@")[1]
			if re.search(c.remmalk2,text):
				user = text.split(" ")[2]
			if message.reply_to_message:
				user = message.reply_to_message.from_user.id
			if 'user' not in locals():return False
			try:
				getUser = client.get_users(user)
				userId = getUser.id
				userFn = getUser.first_name
				setcr = remrank(redis,"malk",userId,chatID,"one")
				if setcr:
					send_msg("UD",client, message,r.remRK,"",getUser,redis)
				elif not setcr:
					send_msg("UD",client, message,r.DremRK,"",getUser,redis)
			except Exception as e:
				Bot("sendMessage",{"chat_id":chatID,"text":r.userNocc,"reply_to_message_id":message.message_id,"parse_mode":"html"})


	if text and (type is "private" or (type is "supergroup" or type is "group")) :
		if rank == "sudo":

			if text == "تفعيل الاذاعه" :
				R = text.split(" ")[1]
				get = redis.get("{}Nbot:bodas".format(BOT_ID))
				BY = "<a href=\"tg://user?id={}\">{}</a>".format(userID,userFN)
				if get :
					save = redis.delete("{}Nbot:bodas".format(BOT_ID))
					Bot("sendMessage",{"chat_id":chatID,"text":r.ADD.format(BY,R),"reply_to_message_id":message.message_id,"parse_mode":"html","disable_web_page_preview":True})

				else:
					Bot("sendMessage",{"chat_id":chatID,"text":r.ADDed.format(BY,R),"reply_to_message_id":message.message_id,"parse_mode":"html","disable_web_page_preview":True})

			if text == "تعطيل الاذاعه" :
				R = text.split(" ")[1]
				BY = "<a href=\"tg://user?id={}\">{}</a>".format(userID,userFN)
				get = redis.get("{}Nbot:bodas".format(BOT_ID))
				if get :
					Bot("sendMessage",{"chat_id":chatID,"text":r.unADDed.format(BY,R),"reply_to_message_id":message.message_id,"parse_mode":"html","disable_web_page_preview":True})
				else:
					save = redis.set("{}Nbot:bodas".format(BOT_ID),1)
					Bot("sendMessage",{"chat_id":chatID,"text":r.unADD.format(BY,R),"reply_to_message_id":message.message_id,"parse_mode":"html","disable_web_page_preview":True})
				


			if re.search("^رفع نسخه احتياطيه$|^رفع نسخة احتياطية$", text):
				msgID = Bot("sendMessage",{"chat_id":chatID,"text":"انتظر قليلاً يتم تحميل الملف ℹ️","reply_to_message_id":message.message_id,"parse_mode":"html","disable_web_page_preview":True})["result"]["message_id"]
				fileName = message.reply_to_message.download()
				JsonDate = json.load(open(fileName))
				if int(JsonDate["BOT_ID"]) != int(BOT_ID):
					Bot("editMessageText",{"chat_id":chatID,"text":"عذراً هذه الملف ليس لي ⚠️","message_id":msgID,"disable_web_page_preview":True,"parse_mode":"html"})
					return 0
				co = len(JsonDate["group"])
				Bot("editMessageText",{"chat_id":chatID,"text":f"تم ايجاد {co} مجموعه في الملف ℹ️","message_id":msgID,"disable_web_page_preview":True,"parse_mode":"html"})
				for chatid in JsonDate["group"].keys():
					redis.sadd("{}Nbot:groups".format(BOT_ID),chatid)
					for rk in JsonDate["group"][chatid].keys():
						if rk == "malk":
							setrank(redis,rk,JsonDate["group"][chatid][rk],chatid,"one")
						else:
							for userId in JsonDate["group"][chatid][rk]:
								setrank(redis,rk,userId,chatid,"array")
				Bot("editMessageText",{"chat_id":chatID,"text":f"تم رفع المجموعات ✅","message_id":msgID,"disable_web_page_preview":True,"parse_mode":"html"})


			if re.search("^جلب نسخه احتياطيه$|^جلب نسخة احتياطية$", text):
				JsonSave = defaultdict(list)
				JsonSave["BOT_ID"] = BOT_ID
				JsonSave["group"] = {}
				gps = redis.smembers("{}Nbot:groups".format(BOT_ID))
				for gp in gps:
					JsonSave["group"][gp] = {}
					malk_userid = redis.get("{}Nbot:{}:malk".format(BOT_ID,gp))
					if malk_userid:
						JsonSave["group"][gp]["malk"] = int(malk_userid)
					ranks_ar = {"acreator","creator","owner","admin"}
					for rk in ranks_ar:
						get = redis.smembers(f"{BOT_ID}Nbot:{gp}:{rk}")
						if get:
							JsonSave["group"][gp][rk] = {}
							user_ids = []
							for userid in get:
								user_ids.append(int(userid))
							JsonSave["group"][gp][rk] = user_ids

				with open(f'{userID}.json', 'w') as fp:
					json.dump(JsonSave, fp)
				da = datetime.datetime.now().strftime("%Y-%m-%d")
				message.reply_document(f'{userID}.json',caption=f"عدد المجموعات 💬 : {len(gps)}\nتاريخ النسخه 📆 : {da}\n⎯ ⎯ ⎯ ⎯")
			if text == "حذف مجموعه المطور":
				redis.delete("{}Nbot:sudogp".format(BOT_ID))
				Bot("sendMessage",{"chat_id":chatID,"text":f"✅꒐ تم تحويل الاشعارات الى الخاص","reply_to_message_id":message.message_id,"parse_mode":"html"})

			if re.search("^تحويل الاساسي$|^تحويل الاساسي @(.*)$|^تحويل الاساسي [0-9]+$", text):
				if re.search("@",text):
					user = text.split("@")[1]
				if re.search("^تحويل الاساسي [0-9]+$" ,text):
					user = text.split(" ")[2]
				if message.reply_to_message:
					user = message.reply_to_message.from_user.id
				if 'user' not in locals():return False
				try:
					getUser = client.get_users(user)
					userId = getUser.id
					userFn = getUser.first_name
					setsudo(redis,userId)
					date = open("./config.py").read().replace(f"SUDO = {userID}", f"SUDO = {userId}")
					print(date)
					open("./config.py","w+").write(date)
					Bot("sendMessage",{"chat_id":chatID,"text":f"✅꒐ تم تحويل المطور الاساسي الى {userFn} {userId}","reply_to_message_id":message.message_id,"parse_mode":"html"})
				except Exception as e:
					print(e)
					Bot("sendMessage",{"chat_id":chatID,"text":r.userNocc,"reply_to_message_id":message.message_id,"parse_mode":"html"})


		if re.search(c.STreplyBOT, text):
			tx = text.replace(c.RPreplyBOT,"")
			if redis.hexists("{}Nbot:TXreplys".format(BOT_ID,chatID),tx):
				Bot("sendMessage",{"chat_id":chatID,"text":r.Yrp.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})
			elif redis.hexists("{}Nbot:STreplys".format(BOT_ID,chatID),tx):
				Bot("sendMessage",{"chat_id":chatID,"text":r.Yrp.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})
			elif redis.hexists("{}Nbot:GFreplys".format(BOT_ID,chatID),tx):
				Bot("sendMessage",{"chat_id":chatID,"text":r.Yrp.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})
			elif redis.hexists("{}Nbot:VOreplys".format(BOT_ID,chatID),tx):
				Bot("sendMessage",{"chat_id":chatID,"text":r.Yrp.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})
			else:
				redis.hset("{}Nbot:stepSUDO".format(BOT_ID),userID,tx)
				kb = InlineKeyboardMarkup([[InlineKeyboardButton(r.MoreInfo, url="t.me/zx_xx")]])
				Bot("sendMessage",{"chat_id":chatID,"text":r.Sendreply % tx,"reply_to_message_id":message.message_id,"parse_mode":"html","reply_markup":kb})
			


		if re.search(c.DLreplyBOT, text):
			tx = text.replace(c.RPdreplyBOT,"")
			if redis.hexists("{}Nbot:TXreplys".format(BOT_ID,chatID),tx):
				redis.hdel("{}Nbot:TXreplys".format(BOT_ID,chatID),tx)
				Bot("sendMessage",{"chat_id":chatID,"text":r.Drp.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})
			elif redis.hexists("{}Nbot:STreplys".format(BOT_ID,chatID),tx):
				redis.hdel("{}Nbot:STreplys".format(BOT_ID,chatID),tx)
				Bot("sendMessage",{"chat_id":chatID,"text":r.Drp.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})
			elif redis.hexists("{}Nbot:GFreplys".format(BOT_ID,chatID),tx):
				redis.hdel("{}Nbot:GFreplys".format(BOT_ID,chatID),tx)
				Bot("sendMessage",{"chat_id":chatID,"text":r.Drp.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})
			elif redis.hexists("{}Nbot:VOreplys".format(BOT_ID,chatID),tx):
				redis.hdel("{}Nbot:GFreplys".format(BOT_ID,chatID),tx)
				Bot("sendMessage",{"chat_id":chatID,"text":r.Drp.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})
			else:
				Bot("sendMessage",{"chat_id":chatID,"text":r.Norp.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})

		if re.search(c.ReplylistBOT, text):
			reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(c.STword,callback_data=json.dumps(["showreplylistBOT","",userID])),InlineKeyboardButton(c.STgifs,callback_data=json.dumps(["showGFreplylistBOT","",userID])),],[InlineKeyboardButton(c.STvoice,callback_data=json.dumps(["showVOreplylistBOT","",userID])),InlineKeyboardButton(c.STsticker,callback_data=json.dumps(["showSTreplylistBOT","",userID])),]])
			Bot("sendMessage",{"chat_id":chatID,"text":r.blocklist.format(text,title),"reply_to_message_id":message.message_id,"parse_mode":"html","reply_markup":reply_markup})

		if rank is "sudo" or rank is "asudo":
			if text == c.remfiles:
				onlyfiles = [f for f in listdir("files") if isfile(join("files", f))]
				array = []
				if not onlyfiles:
					Bot("sendMessage",{"chat_id":chatID,"text":r.NOaddfiles2,"reply_to_message_id":message.message_id,"parse_mode":"html","disable_web_page_preview":True})
					return False
				for f in onlyfiles:
					array.append([InlineKeyboardButton(f,callback_data=json.dumps(["delF",f,userID]))])
				array.append([InlineKeyboardButton(c.remallfiles,callback_data=json.dumps(["delFa","",userID]))])
				kb = InlineKeyboardMarkup(array)
				Bot("sendMessage",{"chat_id":chatID,"text":r.dlFiles,"reply_to_message_id":message.message_id,"parse_mode":"html","disable_web_page_preview":True,"reply_markup":kb})


			if text == c.files:
				onlyfiles = [f for f in listdir("files") if isfile(join("files", f))]
				filesR = redis.smembers("{}Nbot:botfiles".format(BOT_ID))
				array = []
				if not onlyfiles:
					Bot("sendMessage",{"chat_id":chatID,"text":r.NOaddfiles2,"reply_to_message_id":message.message_id,"parse_mode":"html","disable_web_page_preview":True})
					return False
				for f in onlyfiles:
					if f in filesR:
						s = r.true
					else:
						s = r.false
					array.append([InlineKeyboardButton(f+" "+s,callback_data=json.dumps(["au",f,userID]))])
				kb = InlineKeyboardMarkup(array)
				Bot("sendMessage",{"chat_id":chatID,"text":r.Files,"reply_to_message_id":message.message_id,"parse_mode":"html","disable_web_page_preview":True,"reply_markup":kb})

			if text == c.ADDfiles:
				url = "https://raw.githubusercontent.com/TshAkEAb/TshakeV2-files/master/files"
				req = requests.get(url).text
				if not re.search(".py",req):
					Bot("sendMessage",{"chat_id":chatID,"text":r.NOaddfiles,"reply_to_message_id":message.message_id,"disable_web_page_preview":True,"parse_mode":"html"})
					return False

				files = req.split("\n")
				array = []
				for f in files:
					array.append([InlineKeyboardButton(f,callback_data=json.dumps(["dlf",f,userID]))])
				kb = InlineKeyboardMarkup(array)
				Bot("sendMessage",{"chat_id":chatID,"text":r.addFiles,"reply_to_message_id":message.message_id,"parse_mode":"html","disable_web_page_preview":True,"reply_markup":kb})


			if text == c.Ubot:
				Files_H = ["inline.py","all.py","callback.py","delete.py","edit.py","gpcmd.py","locks.py","msg.py","nf.py","ranks.py","sudo.py"]
				#Files_H = ["gpcmd.py"]
				Files_L = ["arreply.py","arcmd.py"]
				Files_U = ["tg.py","locks.py","rank.py","send.py"]
				Files_B = ["bot.py","setup.py"]
				for fnh in Files_H:
					url = "https://raw.githubusercontent.com/ghost11886/TshakeV2/main/handlers/"+fnh
					out = requests.get(url).text
					f = open("./handlers/"+fnh,"w+")
					f.write(out)
					f.close()
				for fnu in Files_U:
					url = "https://raw.githubusercontent.com/ghost11886/TshakeV2/main/utlis/"+fnu
					out = requests.get(url).text
					f = open("./utlis/"+fnu,"w+")
					f.write(out)
					f.close()
				for fnb in Files_B:
					url = "https://raw.githubusercontent.com/ghost11886/TshakeV2/main/"+fnb
					out = requests.get(url).text
					f = open("./"+fnb,"w+")
					f.write(out)
					f.close()
				for fnu in Files_L:
					url = "https://raw.githubusercontent.com/ghost11886/TshakeV2/main/lang/"+fnu
					out = requests.get(url).text
					f = open("./lang/"+fnu,"w+")
					f.write(out)
					f.close()
					
				Bot("sendMessage",{"chat_id":chatID,"text":r.Wres,"reply_to_message_id":message.message_id,"parse_mode":"html"})
				run(redis,chatID)
				
			if re.search(c.setSudoC, text):
				tx = text.replace(c.RsetSudoC,"")
				v = Bot("sendMessage",{"chat_id":chatID,"text":tx,"reply_to_message_id":message.message_id,"parse_mode":"html"})
				if v["ok"]:
					redis.set("{}Nbot:SHOWsudos".format(BOT_ID),tx)
					Bot("sendMessage",{"chat_id":chatID,"text":r.DsetSudosShow,"reply_to_message_id":message.message_id,"parse_mode":"html"})
				elif v["ok"] == False:
					Bot("sendMessage",{"chat_id":chatID,"text":r.DsetSudosShowE,"reply_to_message_id":message.message_id,"parse_mode":"html"})

			if re.search(c.sudosList, text) and Ckuser(message):
				text = text.replace("مسح ","")
				arrays = redis.smembers("{}Nbot:sudos".format(BOT_ID,chatID))
				b = BYusers(arrays,chatID,redis,client)
				kb = InlineKeyboardMarkup([[InlineKeyboardButton(r.delList.format(text), callback_data=json.dumps(["delList","sudos",userID]))]])
				if	b is not "":
					Bot("sendMessage",{"chat_id":chatID,"text":r.showlist.format(text,b),"reply_to_message_id":message.message_id,"parse_mode":"markdown","reply_markup":kb})
				else:
					Bot("sendMessage",{"chat_id":chatID,"text":r.listempty.format(text),"reply_to_message_id":message.message_id,"parse_mode":"markdown"})

			if re.search(c.setsudos, text) and Ckuser(message):
				if re.search("@",text):
					user = text.split("@")[1]
				if re.search(c.setsudos2,text):
					user = text.split(" ")[2]
				if message.reply_to_message:
					user = message.reply_to_message.from_user.id
				if 'user' not in locals():return False
				try:
					getUser = client.get_users(user)
					userId = getUser.id
					userFn = getUser.first_name
					setcr = setsudos(redis,userId)
					if setcr is "sudos":
						send_msg("UD",client, message,r.DsetRK,"",getUser,redis)
					elif (setcr is True or setcr is 1):
						send_msg("UD",client, message,r.setRK,"",getUser,redis)
				except Exception as e:
					print(e)
					Bot("sendMessage",{"chat_id":chatID,"text":r.userNocc,"reply_to_message_id":message.message_id,"parse_mode":"html"})

			if re.search(c.remsudos, text) and Ckuser(message):
				if re.search("@",text):
					user = text.split("@")[1]
				if re.search(c.remsudos2,text):
					user = text.split(" ")[2]
				if message.reply_to_message:
					user = message.reply_to_message.from_user.id
				if 'user' not in locals():return False
				try:
					getUser = client.get_users(user)
					userId = getUser.id
					userFn = getUser.first_name
					setcr = remsudos(redis,userId)
					if setcr:
						send_msg("UD",client, message,r.remRK,"",getUser,redis)
					elif not setcr:
						send_msg("UD",client, message,r.DremRK,"",getUser,redis)
				except Exception as e:
					Bot("sendMessage",{"chat_id":chatID,"text":r.userNocc,"reply_to_message_id":message.message_id,"parse_mode":"html"})
			



			if re.search(c.asudoList, text) and Ckuser(message):
				text = text.replace("مسح ","")
				arrays = redis.smembers("{}Nbot:asudo".format(BOT_ID,chatID))
				b = BYusers(arrays,chatID,redis,client)
				kb = InlineKeyboardMarkup([[InlineKeyboardButton(r.delList.format(text), callback_data=json.dumps(["delList","asudo",userID]))]])
				if	b is not "":
					Bot("sendMessage",{"chat_id":chatID,"text":r.showlist.format(text,b),"reply_to_message_id":message.message_id,"parse_mode":"markdown","reply_markup":kb})
				else:
					Bot("sendMessage",{"chat_id":chatID,"text":r.listempty.format(text),"reply_to_message_id":message.message_id,"parse_mode":"markdown"})

			if re.search(c.setasudo, text) and Ckuser(message):
				if re.search("@",text):
					user = text.split("@")[1]
				if re.search(c.setasudo2,text):
					user = text.split(" ")[2]
				if message.reply_to_message:
					user = message.reply_to_message.from_user.id
				if 'user' not in locals():return False
				try:
					getUser = client.get_users(user)
					userId = getUser.id
					userFn = getUser.first_name
					setcr = setasudo(redis,userId)
					if setcr is "sudos":
						send_msg("UD",client, message,r.DsetRK,"",getUser,redis)
					elif (setcr is True or setcr is 1):
						send_msg("UD",client, message,r.setRK,"",getUser,redis)
				except Exception as e:
					print(e)
					Bot("sendMessage",{"chat_id":chatID,"text":r.userNocc,"reply_to_message_id":message.message_id,"parse_mode":"html"})

			if re.search(c.remasudo, text) and Ckuser(message):
				if re.search("@",text):
					user = text.split("@")[1]
				if re.search(c.remasudo2,text):
					user = text.split(" ")[2]
				if message.reply_to_message:
					user = message.reply_to_message.from_user.id
				if 'user' not in locals():return False
				try:
					getUser = client.get_users(user)
					userId = getUser.id
					userFn = getUser.first_name
					setcr = remasudo(redis,userId)
					if setcr:
						send_msg("UD",client, message,r.remRK,"",getUser,redis)
					elif not setcr:
						send_msg("UD",client, message,r.DremRK,"",getUser,redis)
				except Exception as e:
					Bot("sendMessage",{"chat_id":chatID,"text":r.userNocc,"reply_to_message_id":message.message_id,"parse_mode":"html"})
			

			if re.search(c.banall, text):
				if re.search("@",text):
					user = text.split("@")[1]
				if re.search(c.ban2all,text):
					user = text.split(" ")[2]
				if message.reply_to_message:
					user = message.reply_to_message.from_user.id
				if 'user' not in locals():return False
				try:
					getUser = client.get_users(user)
					userId = getUser.id
					userFn = getUser.first_name
					BY = "<a href=\"tg://user?id={}\">{}</a>".format(userId,userFn)
					Getrank = isrank(redis,userId,chatID)
					GetGprank = GPranks(userId,chatID)
					if Getrank == "bot":return False
					if Getrank == "sudos" or Getrank == "sudo":
						Bot("sendMessage",{"chat_id":chatID,"text":r.cTsudo,"reply_to_message_id":message.message_id,"parse_mode":"html"})
						return False
					if redis.sismember("{}Nbot:bans".format(BOT_ID),userId):
						Bot("sendMessage",{"chat_id":chatID,"text":r.Dbanall.format(BY),"reply_to_message_id":message.message_id,"parse_mode":"html"})
					else:
						redis.sadd("{}Nbot:bans".format(BOT_ID),userId)
						Bot("sendMessage",{"chat_id":chatID,"text":r.banall.format(BY),"reply_to_message_id":message.message_id,"parse_mode":"html"})
						if (GetGprank == "member" or GetGprank == "restricted"):
							Bot("kickChatMember",{"chat_id":chatID,"user_id":userId})
				except Exception as e:
					print(e)
					Bot("sendMessage",{"chat_id":chatID,"text":r.userNocc,"reply_to_message_id":message.message_id,"parse_mode":"html"})

			if re.search(c.unbanall, text):
				if re.search("@",text):
					user = text.split("@")[1]
				if re.search(c.unban2all,text):
					user = text.split(" ")[2]
				if message.reply_to_message:
					user = message.reply_to_message.from_user.id
				if 'user' not in locals():return False
				try:
					getUser = client.get_users(user)
					userId = getUser.id
					userFn = getUser.first_name
					Getrank = isrank(redis,userId,chatID)
					GetGprank = GPranks(userId,chatID)
					if Getrank == "bot":return False
					if redis.sismember("{}Nbot:bans".format(BOT_ID),userId):
						redis.srem("{}Nbot:bans".format(BOT_ID),userId)
						send_msg("BNN",client, message,r.unbanall,"bans",getUser,redis)
					else:
						send_msg("BNN",client, message,r.Dunbanall,"bans",getUser,redis)
				except Exception as e:
					print(e)
					Bot("sendMessage",{"chat_id":chatID,"text":r.userNocc,"reply_to_message_id":message.message_id,"parse_mode":"html"})

			if re.search(c.TKall, text):
				if re.search("@",text):
					user = text.split("@")[1]
				if re.search(c.TK2all,text):
					user = text.split(" ")[2]
				if message.reply_to_message:
					user = message.reply_to_message.from_user.id
				if 'user' not in locals():return False
				try:
					getUser = client.get_users(user)
					userId = getUser.id
					userFn = getUser.first_name
					Getrank = isrank(redis,userId,chatID)
					GetGprank = GPranks(userId,chatID)
					if Getrank == "bot":return False
					if Getrank == "sudos" or Getrank == "sudo":
						Bot("sendMessage",{"chat_id":chatID,"text":r.cTsudo,"reply_to_message_id":message.message_id,"parse_mode":"html"})
						return False
					if redis.sismember("{}Nbot:restricteds".format(BOT_ID),userId):
						send_msg("BNN",client, message,r.Drestrictedall,"restricteds",getUser,redis)
					else:
						send_msg("BNN",client, message,r.restrictedall,"restricteds",getUser,redis)
						redis.sadd("{}Nbot:restricteds".format(BOT_ID),userId)
						if (GetGprank == "member"):
							Bot("restrictChatMember",{"chat_id": chatID,"user_id": userId,"can_send_messages": 0,"can_send_media_messages": 0,"can_send_other_messages": 0,
						    "can_send_polls": 0,"can_change_info": 0,"can_add_web_page_previews": 0,"can_pin_messages": 0,"can_invite_users": 0,})
				except Exception as e:
					print(e)
					Bot("sendMessage",{"chat_id":chatID,"text":r.userNocc,"reply_to_message_id":message.message_id,"parse_mode":"html"})

			if re.search(c.unTKall, text):
				if re.search("@",text):
					user = text.split("@")[1]
				if re.search(c.unTK2all,text):
					user = text.split(" ")[2]
				if message.reply_to_message:
					user = message.reply_to_message.from_user.id
				if 'user' not in locals():return False
				try:
					getUser = client.get_users(user)
					userId = getUser.id
					userFn = getUser.first_name
					Getrank = isrank(redis,userId,chatID)
					GetGprank = GPranks(userId,chatID)
					if Getrank == "bot":return False
					if redis.sismember("{}Nbot:restricteds".format(BOT_ID),userId):
						send_msg("BNN",client, message,r.unrestrictedall,"restricteds",getUser,redis)
						redis.srem("{}Nbot:restricteds".format(BOT_ID),userId)
					else:
						send_msg("BNN",client, message,r.Dunrestrictedall,"restricteds",getUser,redis)
				except Exception as e:
					print(e)
					Bot("sendMessage",{"chat_id":chatID,"text":r.userNocc,"reply_to_message_id":message.message_id,"parse_mode":"html"})

			if re.search(c.Alllist, text) and Ckuser(message):
				reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(c.STbanall,callback_data=json.dumps(["showbanall","",userID])),InlineKeyboardButton(c.STtkall,callback_data=json.dumps(["showtkall","",userID])),]])
				Bot("sendMessage",{"chat_id":chatID,"text":r.banlist,"reply_to_message_id":message.message_id,"parse_mode":"html","reply_markup":reply_markup})
			
			
			if re.search(c.stats, text) and Ckuser(message):
				pr = redis.scard("{}Nbot:privates".format(BOT_ID))
				gp = redis.scard("{}Nbot:groups".format(BOT_ID))
				kb = InlineKeyboardMarkup([[InlineKeyboardButton(r.CKgps,callback_data=json.dumps(["ckGPs","",userID]))]])
				Bot("sendMessage",{"chat_id":chatID,"text":r.showstats.format(gp,pr),"reply_to_message_id":message.message_id,"parse_mode":"html","reply_markup":kb})
			
			if re.search(c.fwdall, text) and message.reply_to_message:
				Bot("forwardMessage",{"chat_id":chatID,"from_chat_id":chatID,"message_id":message.reply_to_message.message_id})
				reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(c.STgroup,callback_data=json.dumps(["fwdtogroups","",userID])),InlineKeyboardButton(c.STprivates,callback_data=json.dumps(["fwdtoprivates","",userID])),]])
				Bot("sendMessage",{"chat_id":chatID,"text":r.sendto,"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html","reply_markup":reply_markup})

			if re.search(c.showGPS, text) and Ckuser(message):
				IDS = redis.smembers("{}Nbot:groups".format(BOT_ID))
				GPslist = ""
				i = 1
				for ID in IDS:
					get = Bot("getChat",{"chat_id":ID})
					if get["ok"]:
						Title = (get["result"]["title"] or "None")
						Link = (redis.hget("{}Nbot:links".format(BOT_ID),ID) or GetLink(ID) or "none")
						name = "[{}]({})".format(Title,Link)
						N = r.ShowGPN.format(i,name,ID)
						GPslist = GPslist+"\n\n"+N
						i +=1
				sendM("NO",GPslist,message)
			if text == c.Laudo :
				R = text.split(" ")[1]
				get = redis.get("{}Nbot:autoaddbot".format(BOT_ID))
				BY = "<a href=\"tg://user?id={}\">{}</a>".format(userID,userFN)
				if get :
					Bot("sendMessage",{"chat_id":chatID,"text":r.ADDed.format(BY,R),"reply_to_message_id":message.message_id,"parse_mode":"html","disable_web_page_preview":True})
				else:
					save = redis.set("{}Nbot:autoaddbot".format(BOT_ID),1)
					Bot("sendMessage",{"chat_id":chatID,"text":r.ADD.format(BY,R),"reply_to_message_id":message.message_id,"parse_mode":"html","disable_web_page_preview":True})

			if text == c.Uauto :
				R = text.split(" ")[1]
				BY = "<a href=\"tg://user?id={}\">{}</a>".format(userID,userFN)
				get = redis.get("{}Nbot:autoaddbot".format(BOT_ID))
				if get :
					save = redis.delete("{}Nbot:autoaddbot".format(BOT_ID))
					Bot("sendMessage",{"chat_id":chatID,"text":r.unADD.format(BY,R),"reply_to_message_id":message.message_id,"parse_mode":"html","disable_web_page_preview":True})
				else:
					Bot("sendMessage",{"chat_id":chatID,"text":r.unADDed.format(BY,R),"reply_to_message_id":message.message_id,"parse_mode":"html","disable_web_page_preview":True})
			
			if text == c.Lleave :
				R = text.split(" ")[1]
				get = redis.get("{}Nbot:leaveaddbot".format(BOT_ID))
				BY = "<a href=\"tg://user?id={}\">{}</a>".format(userID,userFN)
				if get :
					Bot("sendMessage",{"chat_id":chatID,"text":r.ADDed.format(BY,R),"reply_to_message_id":message.message_id,"parse_mode":"html","disable_web_page_preview":True})
				else:
					save = redis.set("{}Nbot:leaveaddbot".format(BOT_ID),1)
					Bot("sendMessage",{"chat_id":chatID,"text":r.ADD.format(BY,R),"reply_to_message_id":message.message_id,"parse_mode":"html","disable_web_page_preview":True})

			if text == c.Uleave :
				R = text.split(" ")[1]
				BY = "<a href=\"tg://user?id={}\">{}</a>".format(userID,userFN)
				get = redis.get("{}Nbot:leaveaddbot".format(BOT_ID))
				if get :
					save = redis.delete("{}Nbot:leaveaddbot".format(BOT_ID))
					Bot("sendMessage",{"chat_id":chatID,"text":r.unADD.format(BY,R),"reply_to_message_id":message.message_id,"parse_mode":"html","disable_web_page_preview":True})
				else:
					Bot("sendMessage",{"chat_id":chatID,"text":r.unADDed.format(BY,R),"reply_to_message_id":message.message_id,"parse_mode":"html","disable_web_page_preview":True})
			
			if re.search(c.Setauto, text):
				N = text.split(" ")[2]
				redis.set("{}Nbot:autoaddbotN".format(BOT_ID),int(N))
				Bot("sendMessage",{"chat_id":chatID,"text":r.SetAuto.format(N),"reply_to_message_id":message.message_id,"parse_mode":"html","disable_web_page_preview":True})
			if re.search(c.leaveChat,text):
				ch = text.split(" ")[1]
				Bot("leaveChat",{"chat_id":ch})
				redis.srem("{}Nbot:groups".format(BOT_ID),ch)
				redis.sadd("{}Nbot:disabledgroups".format(BOT_ID),ch)
				NextDay_Date = datetime.datetime.today() + datetime.timedelta(days=1)
				redis.hset("{}Nbot:disabledgroupsTIME".format(BOT_ID),ch,str(NextDay_Date))
				Bot("sendMessage",{"chat_id":chatID,"text":r.DoneleaveChat,"reply_to_message_id":message.message_id,"parse_mode":"html","disable_web_page_preview":True})




			if re.search(c.sendall, text) and message.reply_to_message and Ckuser(message):
				if rank == "asudo" and redis.get("{}Nbot:bodas".format(BOT_ID)):
					return 0
				if message.reply_to_message.text:
					v = Bot("sendMessage",{"chat_id":chatID,"text":message.reply_to_message.text,"reply_to_message_id":message.message_id,"parse_mode":"html"})
					if v["ok"]:
						reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(c.STgroup,callback_data=json.dumps(["sendtogroups","",userID])),InlineKeyboardButton(c.STprivates,callback_data=json.dumps(["sendtoprivates","",userID])),]])
						Bot("sendMessage",{"chat_id":chatID,"text":r.sendto,"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html","reply_markup":reply_markup})
					elif v["ok"] == False:
						Bot("sendMessage",{"chat_id":chatID,"text":r.DsetSudosShowE,"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html"})

				if message.reply_to_message.photo:
					ID = message.reply_to_message.photo.file_id
					CP = message.reply_to_message.caption
					v = Bot("sendphoto",{"chat_id":chatID,"photo":ID,"caption":CP,"reply_to_message_id":message.message_id,"parse_mode":"html"})
					if v["ok"]:
						reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(c.STgroup,callback_data=json.dumps(["sendtogroups","",userID])),InlineKeyboardButton(c.STprivates,callback_data=json.dumps(["sendtoprivates","",userID])),]])
						Bot("sendMessage",{"chat_id":chatID,"text":r.sendto,"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html","reply_markup":reply_markup})
					elif v["ok"] == False:
						Bot("sendMessage",{"chat_id":chatID,"text":r.DsetSudosShowE,"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html"})

				if message.reply_to_message.voice:
					ID = message.reply_to_message.voice.file_id
					CP = message.reply_to_message.caption
					v = Bot("sendvoice",{"chat_id":chatID,"voice":ID,"caption":CP,"reply_to_message_id":message.message_id,"parse_mode":"html"})
					if v["ok"]:
						reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(c.STgroup,callback_data=json.dumps(["sendtogroups","",userID])),InlineKeyboardButton(c.STprivates,callback_data=json.dumps(["sendtoprivates","",userID])),]])
						Bot("sendMessage",{"chat_id":chatID,"text":r.sendto,"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html","reply_markup":reply_markup})
					elif v["ok"] == False:
						Bot("sendMessage",{"chat_id":chatID,"text":r.DsetSudosShowE,"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html"})

				if message.reply_to_message.audio:
					ID = message.reply_to_message.audio.file_id
					CP = message.reply_to_message.caption
					v = Bot("sendaudio",{"chat_id":chatID,"audio":ID,"caption":CP,"reply_to_message_id":message.message_id,"parse_mode":"html"})
					if v["ok"]:
						reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(c.STgroup,callback_data=json.dumps(["sendtogroups","",userID])),InlineKeyboardButton(c.STprivates,callback_data=json.dumps(["sendtoprivates","",userID])),]])
						Bot("sendMessage",{"chat_id":chatID,"text":r.sendto,"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html","reply_markup":reply_markup})
					elif v["ok"] == False:
						Bot("sendMessage",{"chat_id":chatID,"text":r.DsetSudosShowE,"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html"})

				if message.reply_to_message.document:
					ID = message.reply_to_message.document.file_id
					CP = message.reply_to_message.caption
					v = Bot("senddocument",{"chat_id":chatID,"document":ID,"caption":CP,"reply_to_message_id":message.message_id,"parse_mode":"html"})
					if v["ok"]:
						reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(c.STgroup,callback_data=json.dumps(["sendtogroups","",userID])),InlineKeyboardButton(c.STprivates,callback_data=json.dumps(["sendtoprivates","",userID])),]])
						Bot("sendMessage",{"chat_id":chatID,"text":r.sendto,"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html","reply_markup":reply_markup})
					elif v["ok"] == False:
						Bot("sendMessage",{"chat_id":chatID,"text":r.DsetSudosShowE,"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html"})



				if message.reply_to_message.sticker:
					ID = message.reply_to_message.sticker.file_id
					CP = message.reply_to_message.caption
					v = Bot("sendsticker",{"chat_id":chatID,"sticker":ID,"caption":CP,"reply_to_message_id":message.message_id,"parse_mode":"html"})
					if v["ok"]:
						reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(c.STgroup,callback_data=json.dumps(["sendtogroups","",userID])),InlineKeyboardButton(c.STprivates,callback_data=json.dumps(["sendtoprivates","",userID])),]])
						Bot("sendMessage",{"chat_id":chatID,"text":r.sendto,"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html","reply_markup":reply_markup})
					elif v["ok"] == False:
						Bot("sendMessage",{"chat_id":chatID,"text":r.DsetSudosShowE,"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html"})

				if message.reply_to_message.animation:
					ID = message.reply_to_message.animation.file_id
					CP = message.reply_to_message.caption
					v = Bot("sendanimation",{"chat_id":chatID,"animation":ID,"caption":CP,"reply_to_message_id":message.message_id,"parse_mode":"html"})
					if v["ok"]:
						reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(c.STgroup,callback_data=json.dumps(["sendtogroups","",userID])),InlineKeyboardButton(c.STprivates,callback_data=json.dumps(["sendtoprivates","",userID])),]])
						Bot("sendMessage",{"chat_id":chatID,"text":r.sendto,"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html","reply_markup":reply_markup})
					elif v["ok"] == False:
						Bot("sendMessage",{"chat_id":chatID,"text":r.DsetSudosShowE,"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html"})

				if message.reply_to_message.video:
					ID = message.reply_to_message.video.file_id
					CP = message.reply_to_message.caption
					v = Bot("sendvideo",{"chat_id":chatID,"video":ID,"caption":CP,"reply_to_message_id":message.message_id,"parse_mode":"html"})
					if v["ok"]:
						reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(c.STgroup,callback_data=json.dumps(["sendtogroups","",userID])),InlineKeyboardButton(c.STprivates,callback_data=json.dumps(["sendtoprivates","",userID])),]])
						Bot("sendMessage",{"chat_id":chatID,"text":r.sendto,"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html","reply_markup":reply_markup})
					elif v["ok"] == False:
						Bot("sendMessage",{"chat_id":chatID,"text":r.DsetSudosShowE,"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html"})

				if message.reply_to_message.video_note:
					ID = message.reply_to_message.video_note.file_id
					CP = message.reply_to_message.caption
					v = Bot("sendVideoNote",{"chat_id":chatID,"video_note":ID,"caption":CP,"reply_to_message_id":message.message_id,"parse_mode":"html"})
					if v["ok"]:
						reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(c.STgroup,callback_data=json.dumps(["sendtogroups","",userID])),InlineKeyboardButton(c.STprivates,callback_data=json.dumps(["sendtoprivates","",userID])),]])
						Bot("sendMessage",{"chat_id":chatID,"text":r.sendto,"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html","reply_markup":reply_markup})
					elif v["ok"] == False:
						Bot("sendMessage",{"chat_id":chatID,"text":r.DsetSudosShowE,"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html"})
示例#26
0
def updateMsgs(client, message, redis):
    type = message.chat.type
    userID = message.from_user.id
    chatID = message.chat.id
    username = message.from_user.username
    if username is None:
        username = "******"
    userFN = message.from_user.first_name
    title = message.chat.title
    rank = isrank(redis, userID, chatID)
    text = message.text
    ADDed = """◀️꒐ بواسطه ⌁ {} 
  ✅꒐ {} بالفعل مفعله في المجموعة"""
    ADD = """◀️꒐ بواسطه ⌁ {} 
  ✅꒐ تم تفعيل {} في المجموعة"""
    unADDed = """◀️꒐ بواسطه ⌁ {} 
  ❎꒐ {} بالفعل معطله في المجموعة"""
    unADD = """◀️꒐ بواسطه ⌁ {} 
  ❎꒐ تم تعطيل {} في المجموعة"""

    if (rank is not False or rank is not 0 or rank != "vip"):

        if text == "تفعيل الالعاب":
            R = text.split(" ")[1]
            get = redis.sismember("{}Nbot:gpgames".format(BOT_ID), chatID)
            BY = "<a href=\"tg://user?id={}\">{}</a>".format(userID, userFN)
            if get:
                save = redis.srem("{}Nbot:gpgames".format(BOT_ID), chatID)
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": ADD.format(BY, R),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "disable_web_page_preview": True
                    })
            else:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": ADDed.format(BY, R),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "disable_web_page_preview": True
                    })

        if text == "تعطيل الالعاب":
            R = text.split(" ")[1]
            BY = "<a href=\"tg://user?id={}\">{}</a>".format(userID, userFN)
            get = redis.sismember("{}Nbot:gpgames".format(BOT_ID), chatID)
            if get:
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": unADDed.format(BY, R),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "disable_web_page_preview": True
                    })
            else:
                save = redis.sadd("{}Nbot:gpgames".format(BOT_ID), chatID)
                Bot(
                    "sendMessage", {
                        "chat_id": chatID,
                        "text": unADD.format(BY, R),
                        "reply_to_message_id": message.message_id,
                        "parse_mode": "html",
                        "disable_web_page_preview": True
                    })

    games = {"rps.py": "🧱📃✂️", "xo.py": "❌ ⭕️", "ring.py": "👊🏻💍🖐🏻"}
    if text and re.search("^الالعاب$|^العاب$", text) and not redis.sismember(
            "{}Nbot:gpgames".format(BOT_ID), chatID):
        tx = "🕹꒐ اليك الالعاب المقدمه من (<a href=\"http://t.me/zx_xx\">TshakeTeam</a>)"
        onlyfiles = [f for f in listdir("files") if isfile(join("files", f))]
        array = []
        if not onlyfiles:
            return False
        for f in onlyfiles:
            if f in games:
                array.append(
                    [InlineKeyboardButton(games[f], callback_data=f + "play")])
        kb = InlineKeyboardMarkup(array)
        Bot(
            "sendMessage", {
                "chat_id": chatID,
                "text": tx,
                "reply_to_message_id": message.message_id,
                "parse_mode": "html",
                "disable_web_page_preview": True,
                "reply_markup": kb
            })

    if text and re.search("^نقاطي$", text):
        points = (redis.hget("{}Nbot:{}:points".format(BOT_ID, chatID), userID)
                  or 0)
        Bot(
            "sendMessage", {
                "chat_id": chatID,
                "text": "🔢꒐ نقاطك :- ({})".format(points),
                "reply_to_message_id": message.message_id,
                "parse_mode": "html",
                "disable_web_page_preview": True
            })
示例#27
0
def sudo(client, message,redis):
	type = message.chat.type
	userID = message.from_user.id
	chatID = message.chat.id
	rank = isrank(redis,userID,chatID)
	text = message.text
	title = message.chat.title
	userFN = message.from_user.first_name
	type = message.chat.type
	lang = Glang(redis,chatID)
	moduleCMD = "lang."+lang+"-cmd"
	moduleREPLY = "lang."+lang+"-reply"
	c = importlib.import_module(moduleCMD)
	r = importlib.import_module(moduleREPLY)
	if redis.hexists("{}Nbot:stepSUDO".format(BOT_ID),userID):
		tx = redis.hget("{}Nbot:stepSUDO".format(BOT_ID),userID)
		if text :
			redis.hset("{}Nbot:TXreplys".format(BOT_ID),tx,text)
			redis.hdel("{}Nbot:stepSUDO".format(BOT_ID),userID)
			Bot("sendMessage",{"chat_id":chatID,"text":r.SRtext.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})
		
		if message.sticker:
			ID = message.sticker.file_id
			redis.hset("{}Nbot:STreplys".format(BOT_ID),tx,ID)
			redis.hdel("{}Nbot:stepSUDO".format(BOT_ID),userID)
			Bot("sendMessage",{"chat_id":chatID,"text":r.SRst.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})

		if message.animation:
			ID = message.animation.file_id
			redis.hset("{}Nbot:GFreplys".format(BOT_ID),tx,ID)
			redis.hdel("{}Nbot:stepSUDO".format(BOT_ID),userID)
			Bot("sendMessage",{"chat_id":chatID,"text":r.SRgf.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})

		if message.voice:
			ID = message.voice.file_id
			redis.hset("{}Nbot:VOreplys".format(BOT_ID),tx,ID)
			redis.hdel("{}Nbot:stepSUDO".format(BOT_ID),userID)
			Bot("sendMessage",{"chat_id":chatID,"text":r.SRvo.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})

		if message.photo:
			ID = message.photo.file_id
			redis.hset("{}Nbot:PHreplys".format(BOT_ID),tx,ID)
			redis.hdel("{}Nbot:stepSUDO".format(BOT_ID),userID)
			Bot("sendMessage",{"chat_id":chatID,"text":r.SRph.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})
		if message.document:
			ID = message.document.file_id
			redis.hset("{}Nbot:DOreplys".format(BOT_ID),tx,ID)
			redis.hdel("{}Nbot:stepSUDO".format(BOT_ID),userID)
			Bot("sendMessage",{"chat_id":chatID,"text":r.SRfi.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})



	if text and (type is "supergroup" or type is "group"):
		if re.search(c.leaveChatS, text):
			Bot("leaveChat",{"chat_id":chatID})
			redis.srem("{}Nbot:groups".format(BOT_ID),chatID)
			redis.sadd("{}Nbot:disabledgroups".format(BOT_ID),chatID)
			NextDay_Date = datetime.datetime.today() + datetime.timedelta(days=1)
			redis.hset("{}Nbot:disabledgroupsTIME".format(BOT_ID),chatID,str(NextDay_Date))

		if re.search(c.creators, text) and Ckuser(message):
			text = text.replace("مسح ","")
			arrays = redis.get("{}Nbot:{}:creator".format(BOT_ID,chatID))
			if arrays:
				print(arrays)
				b = BYusers({arrays},chatID,redis,client)
				kb = InlineKeyboardMarkup([[InlineKeyboardButton(r.delList.format(text), callback_data=json.dumps(["delList","creator",userID]))]])
				if	b is not "":
					Bot("sendMessage",{"chat_id":chatID,"text":r.showlist.format(text,b),"reply_to_message_id":message.message_id,"parse_mode":"markdown","reply_markup":kb})
				else:
					Bot("sendMessage",{"chat_id":chatID,"text":r.creatorempty,"reply_to_message_id":message.message_id,"parse_mode":"markdown"})
			else:
				Bot("sendMessage",{"chat_id":chatID,"text":r.creatorempty,"reply_to_message_id":message.message_id,"parse_mode":"markdown"})

		if re.search(c.setcreator, text) and Ckuser(message):
			if re.search("@",text):
				user = text.split("@")[1]
			if re.search(c.setcreator2,text):
				user = text.split(" ")[2]
			if message.reply_to_message:
				user = message.reply_to_message.from_user.id
			if 'user' not in locals():return False
			try:
				getUser = client.get_users(user)
				userId = getUser.id
				userFn = getUser.first_name
				setcr = setrank(redis,"creator",userId,chatID,"one")
				if setcr is "creator":
					send_msg("UD",client, message,r.DsetRK,"",getUser,redis)
				elif (setcr is True or setcr is 1):
					send_msg("UD",client, message,r.setRK,"",getUser,redis)
			except Exception as e:
				Bot("sendMessage",{"chat_id":chatID,"text":r.userNocc,"reply_to_message_id":message.message_id,"parse_mode":"html"})

		if re.search(c.remcreator, text) and Ckuser(message):
			if re.search("@",text):
				user = text.split("@")[1]
			if re.search(c.remcreator2,text):
				user = text.split(" ")[2]
			if message.reply_to_message:
				user = message.reply_to_message.from_user.id
			if 'user' not in locals():return False
			try:
				getUser = client.get_users(user)
				userId = getUser.id
				userFn = getUser.first_name
				setcr = remrank(redis,"creator",userId,chatID,"one")
				if setcr:
					send_msg("UD",client, message,r.remRK,"",getUser,redis)
				elif not setcr:
					send_msg("UD",client, message,r.DremRK,"",getUser,redis)
			except Exception as e:
				Bot("sendMessage",{"chat_id":chatID,"text":r.userNocc,"reply_to_message_id":message.message_id,"parse_mode":"html"})


	if text and (type is "private" or (type is "supergroup" or type is "group")) :
		if re.search(c.STreplyBOT, text):
			tx = text.replace(c.RPreplyBOT,"")
			if redis.hexists("{}Nbot:TXreplys".format(BOT_ID,chatID),tx):
				Bot("sendMessage",{"chat_id":chatID,"text":r.Yrp.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})
			elif redis.hexists("{}Nbot:STreplys".format(BOT_ID,chatID),tx):
				Bot("sendMessage",{"chat_id":chatID,"text":r.Yrp.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})
			elif redis.hexists("{}Nbot:GFreplys".format(BOT_ID,chatID),tx):
				Bot("sendMessage",{"chat_id":chatID,"text":r.Yrp.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})
			elif redis.hexists("{}Nbot:VOreplys".format(BOT_ID,chatID),tx):
				Bot("sendMessage",{"chat_id":chatID,"text":r.Yrp.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})
			else:
				redis.hset("{}Nbot:stepSUDO".format(BOT_ID),userID,tx)
				kb = InlineKeyboardMarkup([[InlineKeyboardButton(r.MoreInfo, url="t.me/vvhvvv")]])
				Bot("sendMessage",{"chat_id":chatID,"text":r.Sendreply % tx,"reply_to_message_id":message.message_id,"parse_mode":"html","reply_markup":kb})
			


		if re.search(c.DLreplyBOT, text):
			tx = text.replace(c.RPdreplyBOT,"")
			if redis.hexists("{}Nbot:TXreplys".format(BOT_ID,chatID),tx):
				redis.hdel("{}Nbot:TXreplys".format(BOT_ID,chatID),tx)
				Bot("sendMessage",{"chat_id":chatID,"text":r.Drp.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})
			elif redis.hexists("{}Nbot:STreplys".format(BOT_ID,chatID),tx):
				redis.hdel("{}Nbot:STreplys".format(BOT_ID,chatID),tx)
				Bot("sendMessage",{"chat_id":chatID,"text":r.Drp.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})
			elif redis.hexists("{}Nbot:GFreplys".format(BOT_ID,chatID),tx):
				redis.hdel("{}Nbot:GFreplys".format(BOT_ID,chatID),tx)
				Bot("sendMessage",{"chat_id":chatID,"text":r.Drp.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})
			elif redis.hexists("{}Nbot:VOreplys".format(BOT_ID,chatID),tx):
				redis.hdel("{}Nbot:GFreplys".format(BOT_ID,chatID),tx)
				Bot("sendMessage",{"chat_id":chatID,"text":r.Drp.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})
			else:
				Bot("sendMessage",{"chat_id":chatID,"text":r.Norp.format(tx),"reply_to_message_id":message.message_id,"parse_mode":"html"})

		if re.search(c.ReplylistBOT, text):
			reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(c.STword,callback_data=json.dumps(["showreplylistBOT","",userID])),InlineKeyboardButton(c.STgifs,callback_data=json.dumps(["showGFreplylistBOT","",userID])),],[InlineKeyboardButton(c.STvoice,callback_data=json.dumps(["showVOreplylistBOT","",userID])),InlineKeyboardButton(c.STsticker,callback_data=json.dumps(["showSTreplylistBOT","",userID])),]])
			Bot("sendMessage",{"chat_id":chatID,"text":r.blocklist.format(text,title),"reply_to_message_id":message.message_id,"parse_mode":"html","reply_markup":reply_markup})



		if rank is "sudo":
			if text == c.remfiles:
				onlyfiles = [f for f in listdir("files") if isfile(join("files", f))]
				array = []
				if not onlyfiles:
					Bot("sendMessage",{"chat_id":chatID,"text":r.NOaddfiles2,"reply_to_message_id":message.message_id,"parse_mode":"html","disable_web_page_preview":True})
					return False
				for f in onlyfiles:
					array.append([InlineKeyboardButton(f,callback_data=json.dumps(["delF",f,userID]))])
				array.append([InlineKeyboardButton(c.remallfiles,callback_data=json.dumps(["delFa","",userID]))])
				kb = InlineKeyboardMarkup(array)
				Bot("sendMessage",{"chat_id":chatID,"text":r.dlFiles,"reply_to_message_id":message.message_id,"parse_mode":"html","disable_web_page_preview":True,"reply_markup":kb})


			if text == c.files:
				onlyfiles = [f for f in listdir("files") if isfile(join("files", f))]
				filesR = redis.smembers("{}Nbot:botfiles".format(BOT_ID))
				array = []
				print(onlyfiles)
				if not onlyfiles:
					Bot("sendMessage",{"chat_id":chatID,"text":r.NOaddfiles2,"reply_to_message_id":message.message_id,"parse_mode":"html","disable_web_page_preview":True})
					return False
				for f in onlyfiles:
					if f in filesR:
						s = r.true
					else:
						s = r.false
					array.append([InlineKeyboardButton(f+" "+s,callback_data=json.dumps(["au",f,userID]))])
				kb = InlineKeyboardMarkup(array)
				Bot("sendMessage",{"chat_id":chatID,"text":r.Files,"reply_to_message_id":message.message_id,"parse_mode":"html","disable_web_page_preview":True,"reply_markup":kb})

			if text == c.ADDfiles:
				url = "https://raw.githubusercontent.com/Nitro/NB-files/master/files"
				req = requests.get(url).text
				if not re.search(".py",req):
					Bot("sendMessage",{"chat_id":chatID,"text":r.NOaddfiles,"reply_to_message_id":message.message_id,"disable_web_page_preview":True,"parse_mode":"html"})
					return False

				files = req.split("\n")
				array = []
				for f in files:
					array.append([InlineKeyboardButton(f,callback_data=json.dumps(["dlf",f,userID]))])
				kb = InlineKeyboardMarkup(array)
				Bot("sendMessage",{"chat_id":chatID,"text":r.addFiles,"reply_to_message_id":message.message_id,"parse_mode":"html","disable_web_page_preview":True,"reply_markup":kb})


			if text == c.Ubot:
				Files_H = ["inline.py","all.py","callback.py","delete.py","edit.py","gpcmd.py","locks.py","msg.py","nf.py","ranks.py","sudo.py"]
				#Files_H = ["gpcmd.py"]
				Files_U = ["tg.py","locks.py","rank.py","send.py"]
				Files_B = ["bot.py","setup.py"]
				for fnh in Files_H:
					url = "https://raw.githubusercontent.com/Nitro/NB/master/handlers/"+fnh
					out = requests.get(url).text
					f = open("./handlers/"+fnh,"w+")
					f.write(out)
					f.close()
				for fnu in Files_U:
					url = "https://raw.githubusercontent.com/Nitro/NB/master/utlis/"+fnu
					out = requests.get(url).text
					f = open("./utlis/"+fnu,"w+")
					f.write(out)
					f.close()
				for fnb in Files_B:
					url = "https://raw.githubusercontent.com/Nitro/NB/master/"+fnb
					out = requests.get(url).text
					f = open("./"+fnb,"w+")
					f.write(out)
					f.close()
				Bot("sendMessage",{"chat_id":chatID,"text":r.Wres,"reply_to_message_id":message.message_id,"parse_mode":"html"})
				run(redis,chatID)
				

			if text == c.Ulang:
				t = r.Dulang
				t2 = r.Wres
				os.system("rm -rf lang;git clone https://github.com/Nitro/Nitro-lang.git;sudo cp -R Nitro-lang/lang lang/; rm -rf Nitro-lang")
				Bot("sendMessage",{"chat_id":chatID,"text":t,"reply_to_message_id":message.message_id,"parse_mode":"html"})
				Bot("sendMessage",{"chat_id":chatID,"text":t2,"reply_to_message_id":message.message_id,"parse_mode":"html"})
				run(redis,chatID)
			if re.search(c.setSudoC, text):
				tx = text.replace(c.RsetSudoC,"")
				v = Bot("sendMessage",{"chat_id":chatID,"text":tx,"reply_to_message_id":message.message_id,"parse_mode":"html"})
				if v["ok"]:
					redis.set("{}Nbot:SHOWsudos".format(BOT_ID),tx)
					Bot("sendMessage",{"chat_id":chatID,"text":r.DsetSudosShow,"reply_to_message_id":message.message_id,"parse_mode":"html"})
				elif v["ok"] == False:
					Bot("sendMessage",{"chat_id":chatID,"text":r.DsetSudosShowE,"reply_to_message_id":message.message_id,"parse_mode":"html"})

			if re.search(c.sudosList, text) and Ckuser(message):
				text = text.replace("مسح ","")
				arrays = redis.smembers("{}Nbot:sudos".format(BOT_ID,chatID))
				b = BYusers(arrays,chatID,redis,client)
				kb = InlineKeyboardMarkup([[InlineKeyboardButton(r.delList.format(text), callback_data=json.dumps(["delList","sudos",userID]))]])
				if	b is not "":
					Bot("sendMessage",{"chat_id":chatID,"text":r.showlist.format(text,b),"reply_to_message_id":message.message_id,"parse_mode":"markdown","reply_markup":kb})
				else:
					Bot("sendMessage",{"chat_id":chatID,"text":r.listempty.format(text),"reply_to_message_id":message.message_id,"parse_mode":"markdown"})

			if re.search(c.setsudos, text) and Ckuser(message):
				if re.search("@",text):
					user = text.split("@")[1]
				if re.search(c.setsudos2,text):
					user = text.split(" ")[2]
				if message.reply_to_message:
					user = message.reply_to_message.from_user.id
				if 'user' not in locals():return False
				try:
					getUser = client.get_users(user)
					userId = getUser.id
					userFn = getUser.first_name
					setcr = setsudos(redis,userId)
					if setcr is "sudos":
						send_msg("UD",client, message,r.DsetRK,"",getUser,redis)
					elif (setcr is True or setcr is 1):
						send_msg("UD",client, message,r.setRK,"",getUser,redis)
				except Exception as e:
					print(e)
					Bot("sendMessage",{"chat_id":chatID,"text":r.userNocc,"reply_to_message_id":message.message_id,"parse_mode":"html"})

			if re.search(c.remsudos, text) and Ckuser(message):
				if re.search("@",text):
					user = text.split("@")[1]
				if re.search(c.remsudos2,text):
					user = text.split(" ")[2]
				if message.reply_to_message:
					user = message.reply_to_message.from_user.id
				if 'user' not in locals():return False
				try:
					getUser = client.get_users(user)
					userId = getUser.id
					userFn = getUser.first_name
					setcr = remsudos(redis,userId)
					if setcr:
						send_msg("UD",client, message,r.remRK,"",getUser,redis)
					elif not setcr:
						send_msg("UD",client, message,r.DremRK,"",getUser,redis)
				except Exception as e:
					Bot("sendMessage",{"chat_id":chatID,"text":r.userNocc,"reply_to_message_id":message.message_id,"parse_mode":"html"})
			
			if re.search(c.banall, text):
				if re.search("@",text):
					user = text.split("@")[1]
				if re.search(c.ban2all,text):
					user = text.split(" ")[2]
				if message.reply_to_message:
					user = message.reply_to_message.from_user.id
				if 'user' not in locals():return False
				try:
					getUser = client.get_users(user)
					userId = getUser.id
					userFn = getUser.first_name
					BY = "<a href=\"tg://user?id={}\">{}</a>".format(userId,userFn)
					Getrank = isrank(redis,userId,chatID)
					GetGprank = GPranks(userId,chatID)
					if Getrank == "bot":return False
					if Getrank == "sudos" or Getrank == "sudo":
						Bot("sendMessage",{"chat_id":chatID,"text":r.cTsudo,"reply_to_message_id":message.message_id,"parse_mode":"html"})
						return False
					if redis.sismember("{}Nbot:bans".format(BOT_ID),userId):
						Bot("sendMessage",{"chat_id":chatID,"text":r.Dbanall.format(BY),"reply_to_message_id":message.message_id,"parse_mode":"html"})
					else:
						redis.sadd("{}Nbot:bans".format(BOT_ID),userId)
						Bot("sendMessage",{"chat_id":chatID,"text":r.banall.format(BY),"reply_to_message_id":message.message_id,"parse_mode":"html"})
						if (GetGprank == "member" or GetGprank == "restricted"):
							Bot("kickChatMember",{"chat_id":chatID,"user_id":userId})
				except Exception as e:
					print(e)
					Bot("sendMessage",{"chat_id":chatID,"text":r.userNocc,"reply_to_message_id":message.message_id,"parse_mode":"html"})

			if re.search(c.unbanall, text):
				if re.search("@",text):
					user = text.split("@")[1]
				if re.search(c.unban2all,text):
					user = text.split(" ")[2]
				if message.reply_to_message:
					user = message.reply_to_message.from_user.id
				if 'user' not in locals():return False
				try:
					getUser = client.get_users(user)
					userId = getUser.id
					userFn = getUser.first_name
					Getrank = isrank(redis,userId,chatID)
					GetGprank = GPranks(userId,chatID)
					if Getrank == "bot":return False
					if redis.sismember("{}Nbot:bans".format(BOT_ID),userId):
						redis.srem("{}Nbot:bans".format(BOT_ID),userId)
						send_msg("BNN",client, message,r.unbanall,"bans",getUser,redis)
					else:
						send_msg("BNN",client, message,r.Dunbanall,"bans",getUser,redis)
				except Exception as e:
					print(e)
					Bot("sendMessage",{"chat_id":chatID,"text":r.userNocc,"reply_to_message_id":message.message_id,"parse_mode":"html"})

			if re.search(c.TKall, text):
				if re.search("@",text):
					user = text.split("@")[1]
				if re.search(c.TK2all,text):
					user = text.split(" ")[2]
				if message.reply_to_message:
					user = message.reply_to_message.from_user.id
				if 'user' not in locals():return False
				try:
					getUser = client.get_users(user)
					userId = getUser.id
					userFn = getUser.first_name
					Getrank = isrank(redis,userId,chatID)
					GetGprank = GPranks(userId,chatID)
					if Getrank == "bot":return False
					if Getrank == "sudos" or Getrank == "sudo":
						Bot("sendMessage",{"chat_id":chatID,"text":r.cTsudo,"reply_to_message_id":message.message_id,"parse_mode":"html"})
						return False
					if redis.sismember("{}Nbot:restricteds".format(BOT_ID),userId):
						send_msg("BNN",client, message,r.Drestrictedall,"restricteds",getUser,redis)
					else:
						send_msg("BNN",client, message,r.restrictedall,"restricteds",getUser,redis)
						redis.sadd("{}Nbot:restricteds".format(BOT_ID),userId)
						if (GetGprank == "member"):
							Bot("restrictChatMember",{"chat_id": chatID,"user_id": userId,"can_send_messages": 0,"can_send_media_messages": 0,"can_send_other_messages": 0,
						    "can_send_polls": 0,"can_change_info": 0,"can_add_web_page_previews": 0,"can_pin_messages": 0,"can_invite_users": 0,})
				except Exception as e:
					print(e)
					Bot("sendMessage",{"chat_id":chatID,"text":r.userNocc,"reply_to_message_id":message.message_id,"parse_mode":"html"})

			if re.search(c.unTKall, text):
				if re.search("@",text):
					user = text.split("@")[1]
				if re.search(c.unTK2all,text):
					user = text.split(" ")[2]
				if message.reply_to_message:
					user = message.reply_to_message.from_user.id
				if 'user' not in locals():return False
				try:
					getUser = client.get_users(user)
					userId = getUser.id
					userFn = getUser.first_name
					Getrank = isrank(redis,userId,chatID)
					GetGprank = GPranks(userId,chatID)
					if Getrank == "bot":return False
					if redis.sismember("{}Nbot:restricteds".format(BOT_ID),userId):
						send_msg("BNN",client, message,r.unrestrictedall,"restricteds",getUser,redis)
						redis.srem("{}Nbot:restricteds".format(BOT_ID),userId)
					else:
						send_msg("BNN",client, message,r.Dunrestrictedall,"restricteds",getUser,redis)
				except Exception as e:
					print(e)
					Bot("sendMessage",{"chat_id":chatID,"text":r.userNocc,"reply_to_message_id":message.message_id,"parse_mode":"html"})

			if re.search(c.Alllist, text) and Ckuser(message):
				reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(c.STbanall,callback_data=json.dumps(["showbanall","",userID])),InlineKeyboardButton(c.STtkall,callback_data=json.dumps(["showtkall","",userID])),]])
				Bot("sendMessage",{"chat_id":chatID,"text":r.banlist,"reply_to_message_id":message.message_id,"parse_mode":"html","reply_markup":reply_markup})
			
			
			if re.search(c.stats, text) and Ckuser(message):
				pr = redis.scard("{}Nbot:privates".format(BOT_ID))
				gp = redis.scard("{}Nbot:groups".format(BOT_ID))
				kb = InlineKeyboardMarkup([[InlineKeyboardButton(r.CKgps,callback_data=json.dumps(["ckGPs","",userID]))]])
				Bot("sendMessage",{"chat_id":chatID,"text":r.showstats.format(gp,pr),"reply_to_message_id":message.message_id,"parse_mode":"html","reply_markup":kb})
			
			if re.search(c.fwdall, text) and message.reply_to_message:
				Bot("forwardMessage",{"chat_id":chatID,"from_chat_id":chatID,"message_id":message.reply_to_message.message_id})
				reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(c.STgroup,callback_data=json.dumps(["fwdtogroups","",userID])),InlineKeyboardButton(c.STprivates,callback_data=json.dumps(["fwdtoprivates","",userID])),]])
				Bot("sendMessage",{"chat_id":chatID,"text":r.sendto,"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html","reply_markup":reply_markup})

			if re.search(c.showGPS, text) and Ckuser(message):
				IDS = redis.smembers("{}Nbot:groups".format(BOT_ID))
				GPslist = ""
				i = 1
				for ID in IDS:
					get = Bot("getChat",{"chat_id":ID})
					if get["ok"]:
						Title = (get["result"]["title"] or "None")
						Link = (redis.hget("{}Nbot:links".format(BOT_ID),ID) or GetLink(ID) or "none")
						name = "[{}]({})".format(Title,Link)
						N = r.ShowGPN.format(i,name,ID)
						GPslist = GPslist+"\n\n"+N
						i +=1
				sendM("NO",GPslist,message)
			
			if text == c.Laudo :
				R = text.split(" ")[1]
				get = redis.get("{}Nbot:autoaddbot".format(BOT_ID))
				BY = "<a href=\"tg://user?id={}\">{}</a>".format(userID,userFN)
				if get :
					Bot("sendMessage",{"chat_id":chatID,"text":r.ADDed.format(BY,R),"reply_to_message_id":message.message_id,"parse_mode":"html","disable_web_page_preview":True})
				else:
					save = redis.set("{}Nbot:autoaddbot".format(BOT_ID),1)
					Bot("sendMessage",{"chat_id":chatID,"text":r.ADD.format(BY,R),"reply_to_message_id":message.message_id,"parse_mode":"html","disable_web_page_preview":True})

			if text == c.Uauto :
				R = text.split(" ")[1]
				BY = "<a href=\"tg://user?id={}\">{}</a>".format(userID,userFN)
				get = redis.get("{}Nbot:autoaddbot".format(BOT_ID),chatID)
				if get :
					save = redis.delete("{}Nbot:autoaddbot".format(BOT_ID))
					Bot("sendMessage",{"chat_id":chatID,"text":r.unADD.format(BY,R),"reply_to_message_id":message.message_id,"parse_mode":"html","disable_web_page_preview":True})
				else:
					Bot("sendMessage",{"chat_id":chatID,"text":r.unADDed.format(BY,R),"reply_to_message_id":message.message_id,"parse_mode":"html","disable_web_page_preview":True})
			if re.search(c.Setauto, text):
				N = text.split(" ")[2]
				redis.set("{}Nbot:autoaddbotN".format(BOT_ID),int(N))
				Bot("sendMessage",{"chat_id":chatID,"text":r.SetAuto.format(N),"reply_to_message_id":message.message_id,"parse_mode":"html","disable_web_page_preview":True})
			if re.search(c.leaveChat,text):
				ch = text.split(" ")[1]
				Bot("leaveChat",{"chat_id":ch})
				redis.srem("{}Nbot:groups".format(BOT_ID),ch)
				redis.sadd("{}Nbot:disabledgroups".format(BOT_ID),ch)
				NextDay_Date = datetime.datetime.today() + datetime.timedelta(days=1)
				redis.hset("{}Nbot:disabledgroupsTIME".format(BOT_ID),ch,str(NextDay_Date))
				Bot("sendMessage",{"chat_id":chatID,"text":r.DoneleaveChat,"reply_to_message_id":message.message_id,"parse_mode":"html","disable_web_page_preview":True})




			if re.search(c.sendall, text) and message.reply_to_message and Ckuser(message):
				if message.reply_to_message.text:
					v = Bot("sendMessage",{"chat_id":chatID,"text":message.reply_to_message.text,"reply_to_message_id":message.message_id,"parse_mode":"html"})
					if v["ok"]:
						reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(c.STgroup,callback_data=json.dumps(["sendtogroups","",userID])),InlineKeyboardButton(c.STprivates,callback_data=json.dumps(["sendtoprivates","",userID])),]])
						Bot("sendMessage",{"chat_id":chatID,"text":r.sendto,"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html","reply_markup":reply_markup})
					elif v["ok"] == False:
						Bot("sendMessage",{"chat_id":chatID,"text":r.DsetSudosShowE,"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html"})

				if message.reply_to_message.photo:
					ID = message.reply_to_message.photo.file_id
					CP = message.reply_to_message.caption
					v = Bot("sendphoto",{"chat_id":chatID,"photo":ID,"caption":CP,"reply_to_message_id":message.message_id,"parse_mode":"html"})
					if v["ok"]:
						reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(c.STgroup,callback_data=json.dumps(["sendtogroups","",userID])),InlineKeyboardButton(c.STprivates,callback_data=json.dumps(["sendtoprivates","",userID])),]])
						Bot("sendMessage",{"chat_id":chatID,"text":r.sendto,"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html","reply_markup":reply_markup})
					elif v["ok"] == False:
						Bot("sendMessage",{"chat_id":chatID,"text":r.DsetSudosShowE,"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html"})

				if message.reply_to_message.voice:
					ID = message.reply_to_message.voice.file_id
					CP = message.reply_to_message.caption
					v = Bot("sendvoice",{"chat_id":chatID,"voice":ID,"caption":CP,"reply_to_message_id":message.message_id,"parse_mode":"html"})
					if v["ok"]:
						reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(c.STgroup,callback_data=json.dumps(["sendtogroups","",userID])),InlineKeyboardButton(c.STprivates,callback_data=json.dumps(["sendtoprivates","",userID])),]])
						Bot("sendMessage",{"chat_id":chatID,"text":r.sendto,"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html","reply_markup":reply_markup})
					elif v["ok"] == False:
						Bot("sendMessage",{"chat_id":chatID,"text":r.DsetSudosShowE,"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html"})

				if message.reply_to_message.audio:
					ID = message.reply_to_message.audio.file_id
					CP = message.reply_to_message.caption
					v = Bot("sendaudio",{"chat_id":chatID,"audio":ID,"caption":CP,"reply_to_message_id":message.message_id,"parse_mode":"html"})
					if v["ok"]:
						reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(c.STgroup,callback_data=json.dumps(["sendtogroups","",userID])),InlineKeyboardButton(c.STprivates,callback_data=json.dumps(["sendtoprivates","",userID])),]])
						Bot("sendMessage",{"chat_id":chatID,"text":r.sendto,"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html","reply_markup":reply_markup})
					elif v["ok"] == False:
						Bot("sendMessage",{"chat_id":chatID,"text":r.DsetSudosShowE,"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html"})

				if message.reply_to_message.document:
					ID = message.reply_to_message.document.file_id
					CP = message.reply_to_message.caption
					v = Bot("senddocument",{"chat_id":chatID,"document":ID,"caption":CP,"reply_to_message_id":message.message_id,"parse_mode":"html"})
					if v["ok"]:
						reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(c.STgroup,callback_data=json.dumps(["sendtogroups","",userID])),InlineKeyboardButton(c.STprivates,callback_data=json.dumps(["sendtoprivates","",userID])),]])
						Bot("sendMessage",{"chat_id":chatID,"text":r.sendto,"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html","reply_markup":reply_markup})
					elif v["ok"] == False:
						Bot("sendMessage",{"chat_id":chatID,"text":r.DsetSudosShowE,"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html"})



				if message.reply_to_message.sticker:
					ID = message.reply_to_message.sticker.file_id
					CP = message.reply_to_message.caption
					v = Bot("sendsticker",{"chat_id":chatID,"sticker":ID,"caption":CP,"reply_to_message_id":message.message_id,"parse_mode":"html"})
					if v["ok"]:
						reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(c.STgroup,callback_data=json.dumps(["sendtogroups","",userID])),InlineKeyboardButton(c.STprivates,callback_data=json.dumps(["sendtoprivates","",userID])),]])
						Bot("sendMessage",{"chat_id":chatID,"text":r.sendto,"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html","reply_markup":reply_markup})
					elif v["ok"] == False:
						Bot("sendMessage",{"chat_id":chatID,"text":r.DsetSudosShowE,"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html"})

				if message.reply_to_message.animation:
					ID = message.reply_to_message.animation.file_id
					CP = message.reply_to_message.caption
					v = Bot("sendanimation",{"chat_id":chatID,"animation":ID,"caption":CP,"reply_to_message_id":message.message_id,"parse_mode":"html"})
					if v["ok"]:
						reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(c.STgroup,callback_data=json.dumps(["sendtogroups","",userID])),InlineKeyboardButton(c.STprivates,callback_data=json.dumps(["sendtoprivates","",userID])),]])
						Bot("sendMessage",{"chat_id":chatID,"text":r.sendto,"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html","reply_markup":reply_markup})
					elif v["ok"] == False:
						Bot("sendMessage",{"chat_id":chatID,"text":r.DsetSudosShowE,"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html"})

				if message.reply_to_message.video:
					ID = message.reply_to_message.video.file_id
					CP = message.reply_to_message.caption
					v = Bot("sendvideo",{"chat_id":chatID,"video":ID,"caption":CP,"reply_to_message_id":message.message_id,"parse_mode":"html"})
					if v["ok"]:
						reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(c.STgroup,callback_data=json.dumps(["sendtogroups","",userID])),InlineKeyboardButton(c.STprivates,callback_data=json.dumps(["sendtoprivates","",userID])),]])
						Bot("sendMessage",{"chat_id":chatID,"text":r.sendto,"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html","reply_markup":reply_markup})
					elif v["ok"] == False:
						Bot("sendMessage",{"chat_id":chatID,"text":r.DsetSudosShowE,"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html"})

				if message.reply_to_message.video_note:
					ID = message.reply_to_message.video_note.file_id
					CP = message.reply_to_message.caption
					v = Bot("sendVideoNote",{"chat_id":chatID,"video_note":ID,"caption":CP,"reply_to_message_id":message.message_id,"parse_mode":"html"})
					if v["ok"]:
						reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(c.STgroup,callback_data=json.dumps(["sendtogroups","",userID])),InlineKeyboardButton(c.STprivates,callback_data=json.dumps(["sendtoprivates","",userID])),]])
						Bot("sendMessage",{"chat_id":chatID,"text":r.sendto,"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html","reply_markup":reply_markup})
					elif v["ok"] == False:
						Bot("sendMessage",{"chat_id":chatID,"text":r.DsetSudosShowE,"reply_to_message_id":message.reply_to_message.message_id,"parse_mode":"html"})