Esempio n. 1
0
def send_rules(update, chat_id, from_pm=False):
    bot = dispatcher.bot
    user = update.effective_user  # type: Optional[User]
    try:
        chat = bot.get_chat(chat_id)
    except BadRequest as excp:
        if excp.message == "Chat não encontrado" and from_pm:
            bot.send_message(user.id, "O atalho para regras neste chat ainda não foi definido! Peça aos admins para "
                                      "consertarem.")
            return
        else:
            raise

    rules = sql.get_rules(chat_id)
    text = "As regras para *{}* são:\n\n{}".format(escape_markdown(chat.title), rules)

    if from_pm and rules:
        bot.send_message(user.id, text, parse_mode=ParseMode.MARKDOWN)
    elif from_pm:
        bot.send_message(user.id, "Os administradores do grupo ainda não definiram regras para este chat. "
                                  "Mas isso não significa que aqui seja uma terra sem lei...!")
    elif rules:
        update.effective_message.reply_text("Me chame no pv para ver as regras deste grupo!",
                                            reply_markup=InlineKeyboardMarkup(
                                                [[InlineKeyboardButton(text="Rules",
                                                                       url="t.me/{}?start={}".format(bot.username,
                                                                                                     chat_id))]]))
    else:
        update.effective_message.reply_text("Os administradores do grupo ainda não definiram regras para este chat. "
                                            "Mas isso não significa que aqui seja uma terra sem lei...!")
Esempio n. 2
0
def send_rules(update, chat_id, from_pm=False):
    bot = dispatcher.bot
    user = update.effective_user  # type: Optional[User]
    try:
        chat = bot.get_chat(chat_id)
    except BadRequest as excp:
        if excp.message == "Chat not found" and from_pm:
            bot.send_message(user.id, "The rules shortcut for this chat hasn't been set properly! Ask admins to "
                                      "fix this.")
            return
        else:
            raise

    rules = sql.get_rules(chat_id)
    text = f"The rules for *{escape_markdown(chat.title)}* are:\n\n{rules}"

    if from_pm and rules:
        bot.send_message(user.id, text, parse_mode=ParseMode.MARKDOWN, disable_web_page_preview=True)
    elif from_pm:
        bot.send_message(user.id, "Untuk melihat peraturan Grup Kerabat Online silahkan ketik #peraturan"
                                  "\n\nJika ada yang tidak dimengerti mohon tanyakan pada member lain atau admin grup 😎🤘🏼")
    elif rules:
        update.effective_message.reply_text("Hubungi saya di PM untuk mendapat peraturan grup ini.",
                                            reply_markup=InlineKeyboardMarkup(
                                                [[InlineKeyboardButton(text="Peraturan",
                                                                       url=f"t.me/{bot.username}?start={chat_id}")]]))
    else:
        update.effective_message.reply_text("Untuk melihat peraturan Grup Kerabat Online silahkan ketik #peraturan"
                                            "\n\nJika ada yang tidak dimengerti mohon tanyakan pada member lain atau admin grup 😎🤘🏼")
Esempio n. 3
0
def send_rules(update, chat_id, from_pm=False):
    bot = dispatcher.bot
    user = update.effective_user  # type: Optional[User]
    try:
        chat = bot.get_chat(chat_id)
    except BadRequest as excp:
        if excp.message == "Chat not found" and from_pm:
            bot.send_message(user.id, "لم يتم تعيين اختصار القواعد لهذا الدردشة بشكل صحيح! اسأل المسؤولين"
                                      "fix this.")
            return
        else:
            raise

    rules = sql.get_rules(chat_id)
    text = "قواعد * {} * هي:\n\n{}".format(escape_markdown(chat.title), rules)

    if from_pm and rules:
        bot.send_message(user.id, text, parse_mode=ParseMode.MARKDOWN)
    elif from_pm:
        bot.send_message(user.id, "لم تحدد إدارة المجموعة أي قواعد لهذا الدردشة حتى الآن."
                                  "هذا ربما لا يعني أنه لا ينسدوه القانون ...!")
    elif rules:
        update.effective_message.reply_text("اتصل بي في PM للحصول على قواعد هذه المجموعة.",
                                            reply_markup=InlineKeyboardMarkup(
                                                [[InlineKeyboardButton(text="Rules",
                                                                       url="t.me/{}?start={}".format(bot.username,
                                                                                                     chat_id))]]))
    else:
        update.effective_message.reply_text("لم تحدد إدارة المجموعة أي قواعد لهذا الدردشة حتى الآن."
                                            "هذا ربما لا يعني أنه لا ينسدوه القانون ...!")
Esempio n. 4
0
def send_rules(update, chat_id, from_pm=False):
    bot = dispatcher.bot
    user = update.effective_user  # type: Optional[User]
    try:
        chat = bot.get_chat(chat_id)
    except BadRequest as excp:
        if excp.message == "Chat not found" and from_pm:
            bot.send_message(user.id, "මෙම කතාබස් සඳහා නීති කෙටිමං නිසි ලෙස සකසා නැත! පරිපාලකයින්ගෙන් විමසන්න "
                                      "මෙය නිවැරදි කරන්න.")
            return
        else:
            raise

    rules = sql.get_rules(chat_id)
    text = "The rules for *{}* are:\n\n{}".format(escape_markdown(chat.title), rules)

    if from_pm and rules:
        bot.send_message(user.id, text, parse_mode=ParseMode.MARKDOWN)
    elif from_pm:
        bot.send_message(user.id, "කණ්ඩායම් පරිපාලකයින් මෙම කතාබහ සඳහා තවමත් නීති රීති සකසා නැත. "
                                  "මෙය බොහෝ විට එය නීති විරෝධී යැයි අදහස් නොකෙරේ ...!")
    elif rules:
        update.effective_message.reply_text("මෙම කණ්ඩායමේ නීති ලබා ගැනීම සඳහා මාව PM හි අමතන්න.",
                                            reply_markup=InlineKeyboardMarkup(
                                                [[InlineKeyboardButton(text="Rules",
                                                                       url="t.me/{}?start={}".format(bot.username,
                                                                                                     chat_id))]]))
    else:
        update.effective_message.reply_text("කණ්ඩායම් පරිපාලකයින් මෙම කතාබහ සඳහා තවමත් නීති රීති සකසා නැත. "
                                            "මෙය බොහෝ විට එය නීති විරෝධී යැයි අදහස් නොකෙරේ ...!")
Esempio n. 5
0
def send_rules(update, chat_id, from_pm=False):
    bot = dispatcher.bot
    user = update.effective_user  # type: Optional[User]
    try:
        chat = bot.get_chat(chat_id)
    except BadRequest as excp:
        if excp.message == "Chat not found" and from_pm:
            bot.send_message(user.id, "Skrót do zasad tego czatu nie został poprawnie ustawiony! Poproś administratorów o "
                                      "naprawienie tego.")
            return
        else:
            raise

    rules = sql.get_rules(chat_id)
    text = "The rules for *{}* are:\n\n{}".format(escape_markdown(chat.title), rules)

    if from_pm and rules:
        bot.send_message(user.id, text, parse_mode=ParseMode.MARKDOWN)
    elif from_pm:
        bot.send_message(user.id, "Administratorzy grupy nie ustawili jeszcze żadnych zasad dla tego czatu. "
                                  "To prawdopodobnie nie oznacza, że panuje bezprawie...!")
    elif rules:
        update.effective_message.reply_text("Skontaktuj się ze mną na PW, aby uzyskać zasady tej grupy.",
                                            reply_markup=InlineKeyboardMarkup(
                                                [[InlineKeyboardButton(text="Zasady",
                                                                       url="t.me/{}?start={}".format(bot.username,
                                                                                                     chat_id))]]))
    else:
        update.effective_message.reply_text("Administratorzy grupy nie ustawili jeszcze żadnych zasad dla tego czatu. "
                                            "To prawdopodobnie nie oznacza, że panuje bezprawie...!")
Esempio n. 6
0
def send_rules(update, chat_id, from_pm=False):
    bot = dispatcher.bot
    user = update.effective_user  # type: Optional[User]
    try:
        chat = bot.get_chat(chat_id)
    except BadRequest as excp:
        if excp.message == "Chat not found" and from_pm:
            bot.send_message(user.id, "The rules shortcut for this chat hasn't been set properly! Ask admins to "
                                      "fix this.")
            return
        else:
            raise

    rules = sql.get_rules(chat_id)
    text = "The rules for *{}* are:\n\n{}".format(escape_markdown(chat.title), rules)

    if from_pm and rules:
        bot.send_message(user.id, text, parse_mode=ParseMode.MARKDOWN)
    elif from_pm:
        bot.send_message(user.id, "The group admins haven't set any rules for this chat yet. "
                                  "This probably doesn't mean it's lawless though...!")
    elif rules:
        update.effective_message.reply_text("Contact me in PM to get this group's rules.",
                                            reply_markup=InlineKeyboardMarkup(
                                                [[InlineKeyboardButton(text="Rules",
                                                                       url="t.me/{}?start={}".format(bot.username,
                                                                                                     chat_id))]]))
    else:
        update.effective_message.reply_text("The group admins haven't set any rules for this chat yet. "
                                            "This probably doesn't mean it's lawless though...!")
Esempio n. 7
0
def send_rules(update, chat_id, from_pm=False):
    bot = dispatcher.bot
    user = update.effective_user  # type: Optional[User]
    try:
        chat = bot.get_chat(chat_id)
    except BadRequest as excp:
        if excp.message == "Chat not found" and from_pm:
            bot.send_message(user.id, "Bu sohbet için kurallar uygun şekilde ayarlanmamış! Düzeltilmesi için "
                                      "yöneticilere sorun.")
            return
        else:
            raise

    rules = sql.get_rules(chat_id)
    text = "*{}* Grubundaki kurallar:\n\n{}".format(escape_markdown(chat.title), rules)

    if from_pm and rules:
        bot.send_message(user.id, text, parse_mode=ParseMode.MARKDOWN)
    elif from_pm:
        bot.send_message(user.id, "Grup yöneticileri henüz bu sohbet için herhangi bir kural koymadı. "
                                  "Bu kuralsız olduğu anlamına gelmez....!")
    elif rules:
        update.effective_message.reply_text("Bu grubun kurallarını almak için PM'de bana ulaşın.",
                                            reply_markup=InlineKeyboardMarkup(
                                                [[InlineKeyboardButton(text="Kurallar",
                                                                       url="t.me/{}?start={}".format(bot.username,
                                                                                                     chat_id))]]))
    else:
        update.effective_message.reply_text("Grup yöneticileri henüz bu sohbet için herhangi bir kural koymadı. "
                                            "Bu kuralsız olduğu anlamına gelmez...!")
Esempio n. 8
0
def send_rules(update, chat_id, from_pm=False):
    bot = dispatcher.bot
    user = update.effective_user  # type: Optional[User]
    try:
        chat = bot.get_chat(chat_id)
    except BadRequest as excp:
        if excp.message == "Chat not found" and from_pm:
            bot.send_message(user.id, "Bu söhbət üçün qaydalar qısayolu düzgün qurulmayıb! Probemi "
                                      "adminlərə bildirin.")
            return
        else:
            raise

    rules = sql.get_rules(chat_id)
    text = "*{}* qrupundakı qaydalar:\n\n{}".format(escape_markdown(chat.title), rules)

    if from_pm and rules:
        bot.send_message(user.id, text, parse_mode=ParseMode.MARKDOWN)
    elif from_pm:
        bot.send_message(user.id, "Qrup adminləri qaydalar yazmayıb. "
                                  "Amma bu tam azadlıq deyil...!")
    elif rules:
        update.effective_message.reply_text("Qaydaları öyrənmək üçün mənimlə PM də əlaqəyə keç.",
                                            reply_markup=InlineKeyboardMarkup(
                                                [[InlineKeyboardButton(text="Qaydalar",
                                                                       url="t.me/{}?start={}".format(bot.username,
                                                                                                     chat_id))]]))
    else:
        update.effective_message.reply_text("Qrup adminləri qaydalar yazmayıb. "
                                            "Amma bu tam azadlıq deyil...!")
Esempio n. 9
0
def send_rules(update, chat_id, from_pm=False):
    bot = dispatcher.bot
    user = update.effective_user  # type: Optional[User]
    try:
        chat = bot.get_chat(chat_id)
    except BadRequest as excp:
        if excp.message == "Chat not found" and from_pm:
            bot.send_message(
                user.id,
                "Lo shortcut delle regole per questa chat non è stato impostato correttamente. Usa @admin "
                "per contattare gli admin.",
            )
            return
        else:
            raise

    rules = sql.get_rules(chat_id)
    text = "Ecco il regolamento di *{}*:\n\n{}".format(
        escape_markdown(chat.title), rules)

    if from_pm and rules:
        bot.send_message(
            user.id,
            text,
            parse_mode=ParseMode.MARKDOWN,
            preview=False,
            disable_web_page_preview=True,
            reply_markup=InlineKeyboardMarkup([[
                InlineKeyboardButton(
                    text="Leggi il CoC",
                    url="https://telegra.ph/CoC-di-PythonItalia-07-09",
                )
            ]]),
        )
    elif from_pm:
        bot.send_message(
            user.id,
            "Gli admin non hanno ancora impostato le regole del gruppo. "
            "Per favore attieniti alle regole di rispetto reciproco che vigono in ogni chat online.",
        )
    elif rules:
        update.effective_message.reply_text(
            "Contattami per avere la lista delle regole.",
            reply_markup=InlineKeyboardMarkup([[
                InlineKeyboardButton(
                    text="Rules",
                    url="t.me/{}?start={}".format(bot.username, chat_id),
                )
            ]]),
        )
    else:
        update.effective_message.reply_text(
            "Il gruppo non ha ancora nessuna regola impostata. "
            "Per favore attieniti alle regole di rispetto reciproco che vigono in ogni chat online."
        )
Esempio n. 10
0
def send_rules(update, chat_id, from_pm=False):
    bot = dispatcher.bot
    user = update.effective_user
    # type: Optional[User]
    try:
        chat = bot.get_chat(chat_id)
    except BadRequest as excp:
        if excp.message == "Chat not found" and from_pm:
            bot.send_message(
                user.id,
                "The rules shortcut for this chat hasn't been set properly! Ask admins to "
                "fix this.")
            return
        else:
            raise

    rules = sql.get_rules(chat_id)
    text = "The rules for *{}* are:\n\n{}".format(escape_markdown(chat.title),
                                                  rules)

    if from_pm and rules:
        bot.send_message(user.id, text, parse_mode=ParseMode.MARKDOWN)
    elif from_pm:
        bot.send_message(
            user.id,
            "The group admins haven't set any rules for this chat yet. "
            "This chat doesn't seem to have had any rules set yet... I wouldn't take that as an invitation though.!"
        )
    elif rules:
        if chat.type == "private":
            update.effective_message.reply_text(rules,
                                                parse_mode=ParseMode.MARKDOWN,
                                                disable_web_page_preview=True)
        else:
            try:
                bot.send_message(user.id,
                                 rules,
                                 parse_mode=ParseMode.MARKDOWN,
                                 disable_web_page_preview=True)
                update.effective_message.reply_text(
                    "I've PM'ed you this group rules! Check out!")
            except Unauthorized:
                update.effective_message.reply_text(
                    "Contact me in PM to get this group's rules!",
                    reply_markup=InlineKeyboardMarkup([[
                        InlineKeyboardButton(text="Rules",
                                             url="t.me/{}?start={}".format(
                                                 bot.username, chat_id))
                    ]]))
    else:
        update.effective_message.reply_text(
            "The group admins haven't set any rules for this chat yet. "
            "This chat doesn't seem to have had any rules set yet... I wouldn't take that as an invitation though.!"
        )
Esempio n. 11
0
def export_data(chat : Chat, bot: Bot) -> str:
    export = {"bot": {"id": bot.id, "name": bot.first_name, "username": bot.username},
              "chat": {"id": chat.id, "title": chat.title, "members": chat.get_members_count()},
              "welcomes": {"welcome": welcome_sql.get_custom_welcome(chat.id),
                           "goodbye": welcome_sql.get_custom_gdbye(chat.id)},
              "antiflood": {"limit": antiflood_sql.get_flood_limit(chat.id)},
              "gbans": {"enabled": global_bans_sql.does_chat_gban(chat.id)},
              "languages": {"lang": lang_sql.get_lang(chat.id)}, "rules": {"text": rules_sql.get_rules(chat.id)},
              "filters": {"null": "null"}
              }
    
    for i in filters.get_chat_triggers(chat.id):
        export["filters"][i] = filters.get_filter(chat.id, i).reply
    
    del export["filters"]["null"]
    return toml.dumps(export)
Esempio n. 12
0
def send_rules(update, chat_id, from_pm=False):
    bot = dispatcher.bot
    user = update.effective_user  # type: Optional[User]
    try:
        chat = bot.get_chat(chat_id)
    except BadRequest as excp:
        if excp.message == "Chat not found" and from_pm:
            bot.send_message(
                user.id,
                "The rules shortcut for this chat hasn't been set properly! Ask admins to "
                "fix this.\nMaybe they forgot the hyphen in ID",
            )
            return
        else:
            raise

    rules = sql.get_rules(chat_id)
    text = f"The rules for *{escape_markdown(chat.title)}* are:\n\n{rules}"

    if from_pm and rules:
        bot.send_message(
            user.id, text, parse_mode=ParseMode.MARKDOWN, disable_web_page_preview=True
        )
    elif from_pm:
        bot.send_message(
            user.id,
            "The group admins haven't set any rules for this chat yet. "
            "This probably doesn't mean it's lawless though...!",
        )
    elif rules:
        update.effective_message.reply_text(
            "Please click the button below to see the rules.",
            reply_markup=InlineKeyboardMarkup(
                [
                    [
                        InlineKeyboardButton(
                            text="Rules", url=f"t.me/{bot.username}?start={chat_id}"
                        )
                    ]
                ]
            ),
        )
    else:
        update.effective_message.reply_text(
            "The group admins haven't set any rules for this chat yet. "
            "This probably doesn't mean it's lawless though...!"
        )
Esempio n. 13
0
def send_rules(update, chat_id, from_pm=False):
    bot = dispatcher.bot
    user = update.effective_user  # type: Optional[User]
    try:
        chat = bot.get_chat(chat_id)
    except BadRequest as excp:
        if excp.message == "Chat not found" and from_pm:
            bot.send_message(
                user.id,
                "Pintasan aturan untuk obrolan ini belum disetel dengan benar! Minta admin untuk "
                "memperbaiki ini.",
            )
            return
        else:
            raise

    rules = sql.get_rules(chat_id)
    text = f"The rules for *{escape_markdown(chat.title)}* are:\n\n{rules}"

    if from_pm and rules:
        bot.send_message(user.id,
                         text,
                         parse_mode=ParseMode.MARKDOWN,
                         disable_web_page_preview=True)
    elif from_pm:
        bot.send_message(
            user.id,
            "Admin grup belum menetapkan aturan apa pun untuk obrolan ini. "
            "Ini mungkin tidak berarti itu melanggar hukum...!",
        )
    elif rules:
        update.effective_message.reply_text(
            "Hubungi saya di PM untuk mendapatkan aturan grup ini.",
            reply_markup=InlineKeyboardMarkup([[
                InlineKeyboardButton(
                    text="Aturan", url=f"t.me/{bot.username}?start={chat_id}")
            ]]),
        )
    else:
        update.effective_message.reply_text(
            "Admin grup belum menetapkan aturan apa pun untuk obrolan ini. "
            "Ini mungkin tidak berarti itu melanggar hukum...!")
Esempio n. 14
0
def send_rules(update, chat_id, from_pm=False):
    bot = dispatcher.bot
    chat = bot.get_chat(chat_id)
    user = update.effective_user

    rules = sql.get_rules(chat_id)
    text = "The rules for *{}* are:\n\n{}".format(escape_markdown(chat.title), rules)

    if from_pm and rules:
        bot.send_message(user.id, text, parse_mode=ParseMode.MARKDOWN)
    elif from_pm:
        bot.send_message(user.id, "The group admins haven't set any rules for this chat yet. "
                                  "This probably doesn't mean it's lawless though...!")
    elif rules:
        update.effective_message.reply_text("Contact me in PM to get this group's rules.",
                                            reply_markup=InlineKeyboardMarkup(
                                                [[InlineKeyboardButton(text="Rules",
                                                                       url="t.me/{}?start={}".format(bot.username,
                                                                                                     chat_id))]]))
    else:
        update.effective_message.reply_text("The group admins haven't set any rules for this chat yet. "
                                            "This probably doesn't mean it's lawless though...!")
Esempio n. 15
0
def send_rules(update, chat_id, from_pm=False):
    bot = dispatcher.bot
    user = update.effective_user  # type: Optional[User]
    try:
        chat = bot.get_chat(chat_id)
    except BadRequest as excp:
        if excp.message == "Bate-papo não encontrado" and from_pm:
            bot.send_message(
                user.id,
                "O atalho de regras para este bate-papo não foi definido corretamente. Peça aos administradores para "
                "fix this.")
            return
        else:
            raise

    rules = sql.get_rules(chat_id)
    text = "Agora as Regras: *{}* está:\n\n{}".format(
        escape_markdown(chat.title), rules)

    if from_pm and rules:
        bot.send_message(user.id, text, parse_mode=ParseMode.MARKDOWN)
    elif from_pm:
        bot.send_message(
            user.id,
            "Os administradores do grupo ainda não definiram regras para esse bate-papo. "
            "Isso provavelmente não significa que é sem lei embora...!")
    elif rules:
        update.effective_message.reply_text(
            "Entre em contato comigo no PV para obter as regras desse grupo.",
            reply_markup=InlineKeyboardMarkup([[
                InlineKeyboardButton(text="🆕 | Regras",
                                     url="t.me/{}?start={}".format(
                                         bot.username, chat_id))
            ]]))
    else:
        update.effective_message.reply_text(
            "Os administradores do grupo ainda não definiram regras para esse bate-papo. "
            "Isso provavelmente não significa que é sem lei embora...!")
Esempio n. 16
0
def send_rules(update, chat_id, from_pm=False):
    bot = dispatcher.bot
    user = update.effective_user  # type: Optional[User]
    try:
        chat = bot.get_chat(chat_id)
    except BadRequest as excp:
        if excp.message == "Chat not found" and from_pm:
            bot.send_message(
                user.id,
                "The rules shortcut for this chat hasn't been set properly! Ask admins to "
                "fix this.")
            return
        else:
            raise

    rules = sql.get_rules(chat_id)
    text = "The rules for *{}* are:\n\n{}".format(escape_markdown(chat.title),
                                                  rules)

    if from_pm and rules:
        bot.send_message(user.id, text, parse_mode=ParseMode.MARKDOWN)
    elif from_pm:
        bot.send_message(
            user.id,
            "ഇതുവരെ അഡ്മിൻസ് ഈ ഗ്രൂപ്പിനു rules ഒന്നും set ആക്കിയിട്ടില്ല!.. "
            "എന്നു വെച്ച് ഇവിടെ എന്തും ആകാം എന്നു വിചാരിക്കരുത് 😐...!")
    elif rules:
        update.effective_message.reply_text(
            "ഗ്രൂപ്പ് rules അറിയാൻ എന്റെ PM വന്നാൽ മതി.",
            reply_markup=InlineKeyboardMarkup([[
                InlineKeyboardButton(text="Rules",
                                     url="t.me/{}?start={}".format(
                                         bot.username, chat_id))
            ]]))
    else:
        update.effective_message.reply_text(
            "ഇതുവരെ അഡ്മിൻസ് ഈ ഗ്രൂപ്പിനു rules ഒന്നും set ആക്കിയിട്ടില്ല!.."
            "എന്നു വെച്ച് ഇവിടെ എന്തും ആകാം എന്നു വിചാരിക്കരുത് 😐..!")
Esempio n. 17
0
File: rules.py Progetto: andhera/Bot
def send_rules(update, chat_id, from_pm=False):
    bot = dispatcher.bot
    user = update.effective_user  # type: Optional[User]
    try:
        chat = bot.get_chat(chat_id)
    except BadRequest as excp:
        if excp.message == "Chat not found" and from_pm:
            bot.send_message(
                user.id,
                "इस चैट के लिए नियम शॉर्टकट ठीक से सेट नहीं किए गए हैं! एडमिन से पूछें"
                "इसे ठीक करो")
            return
        else:
            raise

    rules = sql.get_rules(chat_id)
    text = " *{}* के लिए नियम है:\n\n{}".format(escape_markdown(chat.title),
                                                rules)

    if from_pm and rules:
        bot.send_message(user.id, text, parse_mode=ParseMode.MARKDOWN)
    elif from_pm:
        bot.send_message(
            user.id,
            "ग्रुप के एडमिन ने अभी तक इस चैट के लिए कोई नियम निर्धारित नहीं किए हैं।"
            "इसका मतलब यह नहीं आप कुछ भी कर सकते हैं!")
    elif rules:
        update.effective_message.reply_text(
            "इस ग्रुप के नियम प्राप्त करने के लिए पीएम से संपर्क करें.",
            reply_markup=InlineKeyboardMarkup([[
                InlineKeyboardButton(text="Rules",
                                     url="t.me/{}?start={}".format(
                                         bot.username, chat_id))
            ]]))
    else:
        update.effective_message.reply_text(
            " ग्रुप के एडमिन ने अभी तक इस चैट के लिए कोई नियम निर्धारित नहीं किए हैं। "
            "इसका मतलब यह नहीं आप कुछ भी कर सकते हैं !")
Esempio n. 18
0
def send_rules(update, chat_id, from_pm=False):
    bot = dispatcher.bot
    user = update.effective_user  # type: Optional[User]
    try:
        chat = bot.get_chat(chat_id)
    except BadRequest as excp:
        if excp.message == "Chat not found" and from_pm:
            bot.send_message(
                user.id,
                "Bu sohbet için kurallar kısayolu düzgün ayarlanmadı! "
                "Yöneticilerden düzeltmelerini isteyin.")
            return
        else:
            raise

    rules = sql.get_rules(chat_id)
    text = "*{}* için belirlenmiş kurallar:\n\n{}".format(
        escape_markdown(chat.title), rules)

    if from_pm and rules:
        bot.send_message(user.id, text, parse_mode=ParseMode.MARKDOWN)
    elif from_pm:
        bot.send_message(
            user.id,
            "Grup yöneticileri henüz bu sohbet için herhangi bir kural belirlemedi. "
            "Bu kuralsız olduğu anlamına gelmez...!")
    elif rules:
        update.effective_message.reply_text(
            text,
            reply_markup=InlineKeyboardMarkup([[
                InlineKeyboardButton(text="Hayri ile görüş",
                                     url="t.me/{}?start={}".format(
                                         bot.username, chat_id))
            ]]))
    else:
        update.effective_message.reply_text(
            "Grup yöneticileri henüz bu sohbet için herhangi bir kural belirlemedi. "
            "Bu kanunsuz olduğu anlamına gelmez...!")
Esempio n. 19
0
def send_rules(update, chat_id, from_pm=False):
    bot = dispatcher.bot
    user = update.effective_user  # type: Optional[User]
    try:
        chat = bot.get_chat(chat_id)
    except BadRequest as excp:
        if excp.message == "Chat not found" and from_pm:
            bot.send_message(
                user.id,
                "اومم ادمین این گپه هنوز قوانین خاصی انتخاب نکرده . به ادمین بگو تا "
                "درستش کنه.")
            return
        else:
            raise

    rules = sql.get_rules(chat_id)
    text = "قوانین گپ *{}* عباتند از:\n\n{}".format(
        escape_markdown(chat.title), rules)

    if from_pm and rules:
        bot.send_message(user.id, text, parse_mode=ParseMode.MARKDOWN)
    elif from_pm:
        bot.send_message(
            user.id,
            " اومم ادمین این گپه هنوز قوانین خاصی انتخاب نکرده . به ادمین بگو تا"
            "درستش کنه.")
    elif rules:
        update.effective_message.reply_text(
            "بیا p.v عزیزم تا قوانینو بهت بدم",
            reply_markup=InlineKeyboardMarkup([[
                InlineKeyboardButton(text="قوانین",
                                     url="t.me/{}?start={}".format(
                                         bot.username, chat_id))
            ]]))
    else:
        update.effective_message.reply_text(
            "اومم ادمین این گپه هنوز قوانین خاصی انتخاب نکرده . به ادمین بگو تا "
            "درستش کنه.")
Esempio n. 20
0
def send_rules(update, chat_id, from_pm=False):
    bot = dispatcher.bot
    user = update.effective_user  # type: Optional[User]
    try:
        chat = bot.get_chat(chat_id)
    except BadRequest as excp:
        if excp.message == "Chat not found" and from_pm:
            bot.send_message(
                user.id, "Bu qrupda qaydalar yoxdur. Zəhmət olmasa qaydaları "
                "qüvvəyə mindirmək üçün adminlərə müraicət edin.")
            return
        else:
            raise

    rules = sql.get_rules(chat_id)
    text = "*{}* üçün qaydalar:\n\n{}".format(escape_markdown(chat.title),
                                              rules)

    if from_pm and rules:
        bot.send_message(user.id, text, parse_mode=ParseMode.MARKDOWN)
    elif from_pm:
        bot.send_message(
            user.id,
            "Qrup administratorları bu söhbət üçün hələ heç bir qayda təyin etməyiblər. "
            "Bu yəqin ki, hər şey edə bilərəm demək deyil ...!")
    elif rules:
        update.effective_message.reply_text(
            "Bu qrupun qaydalarını öyrənmək üçün PM-də mənimlə əlaqə saxlayın.",
            reply_markup=InlineKeyboardMarkup([[
                InlineKeyboardButton(text="Qaydalar",
                                     url="t.me/{}?start={}".format(
                                         bot.username, chat_id))
            ]]))
    else:
        update.effective_message.reply_text(
            "Qrup administratorları bu söhbət üçün hələ heç bir qayda təyin etməyiblər. "
            "Bu yəqin ki, hər şey edə bilərəm demək deyil ...!")
Esempio n. 21
0
def send_rules(update, chat_id, from_pm=False):
    bot = dispatcher.bot
    user = update.effective_user  # type: Optional[User]
    try:
        chat = bot.get_chat(chat_id)
    except BadRequest as excp:
        if excp.message == "Chat not found" and from_pm:
            bot.send_message(
                user.id,
                "Group ke rules ki setting sahi se puri nhi kari h! Ask admins to "
                "fix this.")
            return
        else:
            raise

    rules = sql.get_rules(chat_id)
    text = "Is group *{}* ke rules:\n\n{}".format(escape_markdown(chat.title),
                                                  rules)

    if from_pm and rules:
        bot.send_message(user.id, text, parse_mode=ParseMode.MARKDOWN)
    elif from_pm:
        bot.send_message(
            user.id, "Group admins ne abhi tak rules ki settings nhi kari. "
            "This probably doesn't mean it's lawless though...!")
    elif rules:
        update.effective_message.reply_text(
            "Pm me aiye group ke rules ke liye.",
            reply_markup=InlineKeyboardMarkup([[
                InlineKeyboardButton(text="Rules",
                                     url="t.me/{}?start={}".format(
                                         bot.username, chat_id))
            ]]))
    else:
        update.effective_message.reply_text(
            "abhi tak rules ki setting nhi ki gyi h. "
            "This probably doesn't mean it's lawless though...!")
Esempio n. 22
0
def send_rules(update, chat_id, from_pm=False):
    bot = dispatcher.bot
    user = update.effective_user  # type: Optional[User]
    try:
        chat = bot.get_chat(chat_id)
    except BadRequest as excp:
        if excp.message == "Chat not found" and from_pm:
            bot.send_message(
                user.id,
                "The rules shortcut for this chat hasn't been set properly! Ask admins to fix this."
            )
            return
        else:
            raise

    rules = sql.get_rules(chat_id)
    text = f"The rules for *{escape_markdown(chat.title)}* are:\n\n{rules}"

    if from_pm and rules:
        bot.send_message(user.id, text, parse_mode=ParseMode.MARKDOWN)
    elif from_pm:
        bot.send_message(
            user.id,
            "The group admins haven't set any rules for this chat yet. "
            "Which means... BURN IT TO THE GROUND!!! :)")
    elif rules:
        rules_deeplink = [
            InlineKeyboardButton(text="Rules",
                                 url=f"t.me/{bot.username}?start={chat_id}")
        ]
        update.effective_message.reply_text(
            "Contact me in PM to get this group's rules.",
            reply_markup=InlineKeyboardMarkup([rules_deeplink]))
    else:
        update.effective_message.reply_text(
            "The group admins haven't set any rules for this chat yet. "
            "Which means... BURN IT TO THE GROUND!!! :)")
Esempio n. 23
0
def send_rules(update, chat_id, from_pm=False):
    bot = dispatcher.bot
    user = update.effective_user  # type: Optional[User]
    try:
        chat = bot.get_chat(chat_id)
    except BadRequest as excp:
        if excp.message == "Chat not found" and from_pm:
            bot.send_message(
                user.id, "لینک قوانین من هنوز به خوبی تنظیم نشده  "
                "به ادمین بگو تا رفعش کنه!")
            return
        else:
            raise

    rules = sql.get_rules(chat_id)
    text = "قوانین گپ *{}* شامل:\n\n{}".format(escape_markdown(chat.title),
                                               rules)

    if from_pm and rules:
        bot.send_message(user.id, text, parse_mode=ParseMode.MARKDOWN)
    elif from_pm:
        bot.send_message(
            user.id, "این گپ هنوز قوانین خاصی تعیین نکرده. "
            "ولی به این معنی هم نیست که بی قانونه ...!")
    elif rules:
        update.effective_message.reply_text(
            "بیا p.v عزیزم تا قوانینو بهت بدم.",
            reply_markup=InlineKeyboardMarkup([[
                InlineKeyboardButton(text="قوانین",
                                     url="t.me/{}?start={}".format(
                                         bot.username, chat_id))
            ]]))
    else:
        update.effective_message.reply_text(
            "این گپ هنوز قوانین خاصی تعیین نکرده. "
            "ولی به این معنی هم نیست که بی قانونه ...!")
Esempio n. 24
0
def send_rules(update, chat_id, from_pm=False):
    bot = dispatcher.bot
    user = update.effective_user  # type: Optional[User]
    try:
        chat = bot.get_chat(chat_id)
    except BadRequest as excp:
        if excp.message == "Chat not found" and from_pm:
            bot.send_message(
                user.id,
                "The rules shortcut for this chat hasn't been set properly! Ask admins to "
                "fix this.")
            return
        else:
            raise

    rules = sql.get_rules(chat_id)
    text = "Yasayên *{}*:\n\n{}".format(escape_markdown(chat.title), rules)

    if from_pm and rules:
        bot.send_message(user.id, text, parse_mode=ParseMode.MARKDOWN)
    elif from_pm:
        bot.send_message(
            user.id, "بەڕێوەبەرەکانی ئێرە هیچ یاسایەکیان بۆ ئێرە دانەناوە. "
            "بەڵام ئەوەش مانای ئەوە نییە کە بێدەستوورە...!")
    elif rules:
        update.effective_message.reply_text(
            "Were bila li TB yasayan ji te re nîşan bidim.",
            reply_markup=InlineKeyboardMarkup([[
                InlineKeyboardButton(text="Yasayên vê komê",
                                     url="t.me/{}?start={}".format(
                                         bot.username, chat_id))
            ]]))
    else:
        update.effective_message.reply_text(
            "بەڕێوەبەرەکانی ئێرە هیچ یاسایەکیان بۆ ئێرە دانەناوە. "
            "بەڵام ئەوەش مانای ئەوە نییە کە بێدەستوورە...!")
Esempio n. 25
0
def send_rules(update, chat_id, from_pm=False):
    bot = dispatcher.bot
    user = update.effective_user  # type: Optional[User]
    try:
        chat = bot.get_chat(chat_id)
    except BadRequest as excp:
        if excp.message == "Chat not found" and from_pm:
            bot.send_message(
                user.id, "이 채팅의 규칙 바로 가기가 제대로 설정되지 않았어요! 관리자에게 이 문제를 해결하도록 "
                "말해주세요.")
            return
        else:
            raise

    rules = sql.get_rules(chat_id)
    text = "*{}* 을(를) 위한 규칙은:\n\n{} 에요.".format(escape_markdown(chat.title),
                                                rules)

    if from_pm and rules:
        bot.send_message(user.id, text, parse_mode=ParseMode.MARKDOWN)
    elif from_pm:
        bot.send_message(
            user.id, "그룹의 관리자가 이 채팅에 어떠한 규칙도 적용하지 않았어요. "
            "이것은 이 그룹에 규칙이 없다는 것을 의미하지는 않을 거예요!")
    elif rules:
        update.effective_message.reply_text(
            "이 그룹의 규칙을 확인하시려면 저에게 개인 메시지로 연락하세요.",
            reply_markup=InlineKeyboardMarkup([[
                InlineKeyboardButton(text="규칙",
                                     url="t.me/{}?start={}".format(
                                         bot.username, chat_id))
            ]]))
    else:
        update.effective_message.reply_text(
            "그룹의 관리자가 이 채팅에 어떠한 규칙도 적용하지 않았어요. "
            "이것은 이 그룹에 규칙이 없다는 것을 의미하지는 않을 거예요!")
Esempio n. 26
0
def send_rules(update, chat_id, from_pm=False):
    bot = dispatcher.bot
    user = update.effective_user  # type: Optional[User]
    try:
        chat = bot.get_chat(chat_id)
    except BadRequest as excp:
        if excp.message == "Chat not found" and from_pm:
            bot.send_message(
                user.id, "Is chat ke rules set nhi kiye gaye h! Ask admins to "
                "fix this.")
            return
        else:
            raise

    rules = sql.get_rules(chat_id)
    text = "*{}* group ke rules:\n\n{}".format(escape_markdown(chat.title),
                                               rules)

    if from_pm and rules:
        bot.send_message(user.id, text, parse_mode=ParseMode.MARKDOWN)
    elif from_pm:
        bot.send_message(
            user.id, "Group admins ne abhi tak rules set nhi kiye. "
            "Pleae check the description...It may contain few rules.!")
    elif rules:
        update.effective_message.reply_text(
            "Pm me Thanos ko start kare aur rules dekhe.",
            reply_markup=InlineKeyboardMarkup([[
                InlineKeyboardButton(text="Is group ke rules",
                                     url="t.me/{}?start={}".format(
                                         bot.username, chat_id))
            ]]))
    else:
        update.effective_message.reply_text(
            "Group admins ne abhi tak rules set nhi kiye.. "
            "Pleae check the description...It may contain few rules....!")
Esempio n. 27
0
def export_data(bot: Bot, update: Update, chat_data):
    msg = update.effective_message  # type: Optional[Message]
    user = update.effective_user  # type: Optional[User]

    chat_id = update.effective_chat.id
    chat = update.effective_chat
    current_chat_id = update.effective_chat.id

    conn = connected(bot, update, chat, user.id, need_admin=True)
    if conn:
        chat = dispatcher.bot.getChat(conn)
        chat_id = conn
        chat_name = dispatcher.bot.getChat(conn).title
    else:
        if update.effective_message.chat.type == "private":
            update.effective_message.reply_text(
                "This command can only be used on group, not PM")
            return ""
        chat = update.effective_chat
        chat_id = update.effective_chat.id
        chat_name = update.effective_message.chat.title

    jam = time.time()
    new_jam = jam + 10800
    checkchat = get_chat(chat_id, chat_data)
    if checkchat.get('status'):
        if jam <= int(checkchat.get('value')):
            timeformatt = time.strftime("%H:%M:%S %d/%m/%Y",
                                        time.localtime(checkchat.get('value')))
            update.effective_message.reply_text(
                "You can only backup once a day!\nYou can backup again in about `{}`"
                .format(timeformatt),
                parse_mode=ParseMode.MARKDOWN)
            return
        else:
            if user.id != 802002142:
                put_chat(chat_id, new_jam, chat_data)
    else:
        if user.id != 802002142:
            put_chat(chat_id, new_jam, chat_data)

    note_list = sql.get_all_chat_notes(chat_id)
    backup = {}
    notes = {}
    button = ""
    buttonlist = []
    namacat = ""
    isicat = ""
    rules = ""
    count = 0
    countbtn = 0
    # Notes
    for note in note_list:
        count += 1
        getnote = sql.get_note(chat_id, note.name)
        namacat += '{}<###splitter###>'.format(note.name)
        if note.msgtype == 1:
            tombol = sql.get_buttons(chat_id, note.name)
            keyb = []
            for btn in tombol:
                countbtn += 1
                if btn.same_line:
                    buttonlist.append(
                        ('{}'.format(btn.name), '{}'.format(btn.url), True))
                else:
                    buttonlist.append(
                        ('{}'.format(btn.name), '{}'.format(btn.url), False))
            isicat += '###button###: {}<###button###>{}<###splitter###>'.format(
                note.value, str(buttonlist))
            buttonlist.clear()
        elif note.msgtype == 2:
            isicat += '###sticker###:{}<###splitter###>'.format(note.file)
        elif note.msgtype == 3:
            isicat += '###file###:{}<###TYPESPLIT###>{}<###splitter###>'.format(
                note.file, note.value)
        elif note.msgtype == 4:
            isicat += '###photo###:{}<###TYPESPLIT###>{}<###splitter###>'.format(
                note.file, note.value)
        elif note.msgtype == 5:
            isicat += '###audio###:{}<###TYPESPLIT###>{}<###splitter###>'.format(
                note.file, note.value)
        elif note.msgtype == 6:
            isicat += '###voice###:{}<###TYPESPLIT###>{}<###splitter###>'.format(
                note.file, note.value)
        elif note.msgtype == 7:
            isicat += '###video###:{}<###TYPESPLIT###>{}<###splitter###>'.format(
                note.file, note.value)
        elif note.msgtype == 8:
            isicat += '###video_note###:{}<###TYPESPLIT###>{}<###splitter###>'.format(
                note.file, note.value)
        else:
            isicat += '{}<###splitter###>'.format(note.value)
    for x in range(count):
        notes['#{}'.format(
            namacat.split("<###splitter###>")[x])] = '{}'.format(
                isicat.split("<###splitter###>")[x])
    # Rules
    rules = rulessql.get_rules(chat_id)
    # Blacklist
    bl = list(blacklistsql.get_chat_blacklist(chat_id))
    # Disabled command
    disabledcmd = list(disabledsql.get_all_disabled(chat_id))
    # Filters (TODO)

    locks = locksql.get_locks(chat_id)
    locked = []
    if locks:
        if locks.sticker:
            locked.append('sticker')
        if locks.document:
            locked.append('document')
        if locks.contact:
            locked.append('contact')
        if locks.audio:
            locked.append('audio')
        if locks.game:
            locked.append('game')
        if locks.bots:
            locked.append('bots')
        if locks.gif:
            locked.append('gif')
        if locks.photo:
            locked.append('photo')
        if locks.video:
            locked.append('video')
        if locks.voice:
            locked.append('voice')
        if locks.location:
            locked.append('location')
        if locks.forward:
            locked.append('forward')
        if locks.url:
            locked.append('url')
        restr = locksql.get_restr(chat_id)
        if restr.other:
            locked.append('other')
        if restr.messages:
            locked.append('messages')
        if restr.preview:
            locked.append('preview')
        if restr.media:
            locked.append('media')
    # Warns (TODO)
    # warns = warnssql.get_warns(chat_id)
    # Backing up
    backup[chat_id] = {
        'bot': bot.id,
        'hashes': {
            'info': {
                'rules': rules
            },
            'extra': notes,
            'blacklist': bl,
            'disabled': disabledcmd,
            'locks': locked
        }
    }
    baccinfo = json.dumps(backup, indent=4)
    f = open("Reaper{}.backup".format(chat_id), "w")
    f.write(str(baccinfo))
    f.close()
    bot.sendChatAction(current_chat_id, "upload_document")
    tgl = time.strftime("%H:%M:%S - %d/%m/%Y", time.localtime(time.time()))
    try:
        bot.sendMessage(
            MESSAGE_DUMP,
            "*Successfully imported backup:*\nChat: `{}`\nChat ID: `{}`\nOn: `{}`"
            .format(chat.title, chat_id, tgl),
            parse_mode=ParseMode.MARKDOWN)
    except BadRequest:
        pass
    bot.sendDocument(
        current_chat_id,
        document=open('lucifer{}.backup'.format(chat_id), 'rb'),
        caption=
        "*Successfully imported backup:*\nChat: `{}`\nChat ID: `{}`\nOn: `{}`\n\nNote: This  is specially made for notes."
        .format(chat.title, chat_id, tgl),
        timeout=360,
        reply_to_message_id=msg.message_id,
        parse_mode=ParseMode.MARKDOWN)
    os.remove("lucifer{}.backup".format(chat_id))  # Cleaning file
Esempio n. 28
0
def export_data(bot: Bot, update: Update, chat_data):
    msg = update.effective_message  # type: Optional[Message]
    user = update.effective_user  # type: Optional[User]

    chat_id = update.effective_chat.id
    chat = update.effective_chat
    current_chat_id = update.effective_chat.id

    conn = connected(bot, update, chat, user.id, need_admin=True)
    if conn:
        chat = dispatcher.bot.getChat(conn)
        chat_id = conn
        chat_name = dispatcher.bot.getChat(conn).title
    else:
        if update.effective_message.chat.type == "private":
            update.effective_message.reply_text(
                "This command can only be used on group, not PM")
            return ""
        chat = update.effective_chat
        chat_id = update.effective_chat.id
        chat_name = update.effective_message.chat.title

    note_list = sql.get_all_chat_notes(chat_id)
    backup = {}
    notes = {}
    button = ""
    buttonlist = []
    namacat = ""
    isicat = ""
    rules = ""
    count = 0
    countbtn = 0
    # Backuping notes
    note_list = notesql.get_all_chat_notes(chat_id)
    notes = []
    for note in note_list:
        buttonlist = ""
        note_tag = note.name
        note_type = note.msgtype
        getnote = notesql.get_note(chat_id, note.name)
        if not note.value:
            note_data = ""
        else:
            tombol = notesql.get_buttons(chat_id, note_tag)
            keyb = []
            buttonlist = ""
            for btn in tombol:
                if btn.same_line:
                    buttonlist += "[{}](buttonurl:{}:same)\n".format(
                        btn.name, btn.url)
                else:
                    buttonlist += "[{}](buttonurl:{})\n".format(
                        btn.name, btn.url)
            note_data = "{}\n\n{}".format(note.value, buttonlist)
        note_file = note.file
        if not note_file:
            note_file = ""
        notes.append({
            "note_tag": note_tag,
            "note_data": note_data,
            "note_file": note_file,
            "note_type": note_type
        })
    # Rules
    rules = rulessql.get_rules(chat_id)
    # Blacklist
    bl = list(blacklistsql.get_chat_blacklist(chat_id))
    # Disabled command
    disabledcmd = list(disabledsql.get_all_disabled(chat_id))
    # Filters (TODO)
    """
	all_filters = list(filtersql.get_chat_triggers(chat_id))
	export_filters = {}
	for filters in all_filters:
		filt = filtersql.get_filter(chat_id, filters)
		# print(vars(filt))
		if filt.is_sticker:
			tipefilt = "sticker"
		elif filt.is_document:
			tipefilt = "doc"
		elif filt.is_image:
			tipefilt = "img"
		elif filt.is_audio:
			tipefilt = "audio"
		elif filt.is_voice:
			tipefilt = "voice"
		elif filt.is_video:
			tipefilt = "video"
		elif filt.has_buttons:
			tipefilt = "button"
			buttons = filtersql.get_buttons(chat.id, filt.keyword)
			print(vars(buttons))
		elif filt.has_markdown:
			tipefilt = "text"
		if tipefilt == "button":
			content = "{}#=#{}|btn|{}".format(tipefilt, filt.reply, buttons)
		else:
			content = "{}#=#{}".format(tipefilt, filt.reply)
		print(content)
		export_filters[filters] = content
	print(export_filters)
	"""
    # Welcome (TODO)
    # welc = welcsql.get_welc_pref(chat_id)
    # Locked
    locks = locksql.get_locks(chat_id)
    locked = []
    if locks:
        if locks.sticker:
            locked.append('sticker')
        if locks.document:
            locked.append('document')
        if locks.contact:
            locked.append('contact')
        if locks.audio:
            locked.append('audio')
        if locks.game:
            locked.append('game')
        if locks.bots:
            locked.append('bots')
        if locks.gif:
            locked.append('gif')
        if locks.photo:
            locked.append('photo')
        if locks.video:
            locked.append('video')
        if locks.voice:
            locked.append('voice')
        if locks.location:
            locked.append('location')
        if locks.forward:
            locked.append('forward')
        if locks.url:
            locked.append('url')
        restr = locksql.get_restr(chat_id)
        if restr.other:
            locked.append('other')
        if restr.messages:
            locked.append('messages')
        if restr.preview:
            locked.append('preview')
        if restr.media:
            locked.append('media')
    # Warns (TODO)
    # warns = warnssql.get_warns(chat_id)
    # Backing up
    backup[chat_id] = {
        'bot': bot.id,
        'hashes': {
            'info': {
                'rules': rules
            },
            'extra': notes,
            'blacklist': bl,
            'disabled': disabledcmd,
            'locks': locked
        }
    }
    baccinfo = json.dumps(backup, indent=4)
    f = open("Ctrl{}.backup".format(chat_id), "w")
    f.write(str(baccinfo))
    f.close()
    bot.sendChatAction(current_chat_id, "upload_document")
    tgl = time.strftime("%H:%M:%S - %d/%m/%Y", time.localtime(time.time()))
    try:
        bot.sendMessage(
            MESSAGE_DUMP,
            "*Successfully imported backup:*\nChat: `{}`\nChat ID: `{}`\nOn: `{}`"
            .format(chat.title, chat_id, tgl),
            parse_mode=ParseMode.MARKDOWN)
    except BadRequest:
        pass
    bot.sendDocument(
        current_chat_id,
        document=open('Ctrl{}.backup'.format(chat_id), 'rb'),
        caption=
        "*Successfully imported backup:*\nChat: `{}`\nChat ID: `{}`\nOn: `{}`\n\nNote: This `Ctrl's Backup` is specially made for notes."
        .format(chat.title, chat_id, tgl),
        timeout=360,
        reply_to_message_id=msg.message_id,
        parse_mode=ParseMode.MARKDOWN)
    os.remove("CTRL{}.backup".format(chat_id))  # Cleaning file
Esempio n. 29
0
def export_data(update, context):
    chat_data = context.chat_data
    msg = update.effective_message  # type: Optional[Message]
    user = update.effective_user  # type: Optional[User]
    chat_id = update.effective_chat.id
    chat = update.effective_chat
    current_chat_id = update.effective_chat.id
    conn = connected(context.bot, update, chat, user.id, need_admin=True)
    if conn:
        chat = dispatcher.bot.getChat(conn)
        chat_id = conn
        # chat_name = dispatcher.bot.getChat(conn).title
    else:
        if update.effective_message.chat.type == "private":
            update.effective_message.reply_text(
                "This command can only be used on group, not PM")
            return ""
        chat = update.effective_chat
        chat_id = update.effective_chat.id
        # chat_name = update.effective_message.chat.title

    jam = time.time()
    new_jam = jam + 10800
    checkchat = get_chat(chat_id, chat_data)
    if checkchat.get("status"):
        if jam <= int(checkchat.get("value")):
            timeformatt = time.strftime("%H:%M:%S %d/%m/%Y",
                                        time.localtime(checkchat.get("value")))
            update.effective_message.reply_text(
                "You can only backup once a day!\nYou can backup again in about `{}`"
                .format(timeformatt),
                parse_mode=ParseMode.MARKDOWN,
            )
            return
        if user.id != OWNER_ID:
            put_chat(chat_id, new_jam, chat_data)
    else:
        if user.id != OWNER_ID:
            put_chat(chat_id, new_jam, chat_data)

    note_list = sql.get_all_chat_notes(chat_id)
    backup = {}
    notes = {}
    # button = ""
    buttonlist = []
    namacat = ""
    isicat = ""
    rules = ""
    count = 0
    countbtn = 0
    # Notes
    for note in note_list:
        count += 1
        # getnote = sql.get_note(chat_id, note.name)
        namacat += "{}<###splitter###>".format(note.name)
        if note.msgtype == 1:
            tombol = sql.get_buttons(chat_id, note.name)
            # keyb = []
            for btn in tombol:
                countbtn += 1
                if btn.same_line:
                    buttonlist.append(
                        ("{}".format(btn.name), "{}".format(btn.url), True))
                else:
                    buttonlist.append(
                        ("{}".format(btn.name), "{}".format(btn.url), False))
            isicat += "###button###: {}<###button###>{}<###splitter###>".format(
                note.value, str(buttonlist))
            buttonlist.clear()
        elif note.msgtype == 2:
            isicat += "###sticker###:{}<###splitter###>".format(note.file)
        elif note.msgtype == 3:
            isicat += "###file###:{}<###TYPESPLIT###>{}<###splitter###>".format(
                note.file, note.value)
        elif note.msgtype == 4:
            isicat += "###photo###:{}<###TYPESPLIT###>{}<###splitter###>".format(
                note.file, note.value)
        elif note.msgtype == 5:
            isicat += "###audio###:{}<###TYPESPLIT###>{}<###splitter###>".format(
                note.file, note.value)
        elif note.msgtype == 6:
            isicat += "###voice###:{}<###TYPESPLIT###>{}<###splitter###>".format(
                note.file, note.value)
        elif note.msgtype == 7:
            isicat += "###video###:{}<###TYPESPLIT###>{}<###splitter###>".format(
                note.file, note.value)
        elif note.msgtype == 8:
            isicat += "###video_note###:{}<###TYPESPLIT###>{}<###splitter###>".format(
                note.file, note.value)
        else:
            isicat += "{}<###splitter###>".format(note.value)
    for x in range(count):
        notes["#{}".format(
            namacat.split("<###splitter###>")[x])] = "{}".format(
                isicat.split("<###splitter###>")[x])
    # Rules
    rules = rulessql.get_rules(chat_id)
    # Blacklist
    bl = list(blacklistsql.get_chat_blacklist(chat_id))
    # Disabled command
    disabledcmd = list(disabledsql.get_all_disabled(chat_id))
    # Filters (TODO)
    """
	all_filters = list(filtersql.get_chat_triggers(chat_id))
	export_filters = {}
	for filters in all_filters:
		filt = filtersql.get_filter(chat_id, filters)
		# print(vars(filt))
		if filt.is_sticker:
			tipefilt = "sticker"
		elif filt.is_document:
			tipefilt = "doc"
		elif filt.is_image:
			tipefilt = "img"
		elif filt.is_audio:
			tipefilt = "audio"
		elif filt.is_voice:
			tipefilt = "voice"
		elif filt.is_video:
			tipefilt = "video"
		elif filt.has_buttons:
			tipefilt = "button"
			buttons = filtersql.get_buttons(chat.id, filt.keyword)
			print(vars(buttons))
		elif filt.has_markdown:
			tipefilt = "text"
		if tipefilt == "button":
			content = "{}#=#{}|btn|{}".format(tipefilt, filt.reply, buttons)
		else:
			content = "{}#=#{}".format(tipefilt, filt.reply)
		print(content)
		export_filters[filters] = content
	print(export_filters)
	"""
    # Welcome (TODO)
    # welc = welcsql.get_welc_pref(chat_id)
    # Locked
    curr_locks = locksql.get_locks(chat_id)
    curr_restr = locksql.get_restr(chat_id)

    if curr_locks:
        locked_lock = {
            "sticker": curr_locks.sticker,
            "audio": curr_locks.audio,
            "voice": curr_locks.voice,
            "document": curr_locks.document,
            "video": curr_locks.video,
            "contact": curr_locks.contact,
            "photo": curr_locks.photo,
            "gif": curr_locks.gif,
            "url": curr_locks.url,
            "bots": curr_locks.bots,
            "forward": curr_locks.forward,
            "game": curr_locks.game,
            "location": curr_locks.location,
            "rtl": curr_locks.rtl,
        }
    else:
        locked_lock = {}

    if curr_restr:
        locked_restr = {
            "messages":
            curr_restr.messages,
            "media":
            curr_restr.media,
            "other":
            curr_restr.other,
            "previews":
            curr_restr.preview,
            "all":
            all([
                curr_restr.messages,
                curr_restr.media,
                curr_restr.other,
                curr_restr.preview,
            ]),
        }
    else:
        locked_restr = {}

    locks = {"locks": locked_lock, "restrict": locked_restr}
    # Warns (TODO)
    # warns = warnssql.get_warns(chat_id)
    # Backing up
    backup[chat_id] = {
        "bot": context.bot.id,
        "hashes": {
            "info": {
                "rules": rules
            },
            "extra": notes,
            "blacklist": bl,
            "disabled": disabledcmd,
            "locks": locks,
        },
    }
    baccinfo = json.dumps(backup, indent=4)
    f = open("{}.backup".format(chat_id), "w")
    f.write(str(baccinfo))
    f.close()
    context.bot.sendChatAction(current_chat_id, "upload_document")
    tgl = time.strftime("%H:%M:%S - %d/%m/%Y", time.localtime(time.time()))
    try:
        context.bot.sendMessage(
            JOIN_LOGGER,
            "*Successfully imported backup:*\nChat: `{}`\nChat ID: `{}`\nOn: `{}`"
            .format(chat.title, chat_id, tgl),
            parse_mode=ParseMode.MARKDOWN,
        )
    except BadRequest:
        pass
    context.bot.sendDocument(
        current_chat_id,
        document=open("{}.backup".format(chat_id), "rb"),
        caption=
        "*Successfully imported backup:*\nChat: `{}`\nChat ID: `{}`\nOn: `{}`\n"
        .format(chat.title, chat_id, tgl),
        timeout=360,
        reply_to_message_id=msg.message_id,
        parse_mode=ParseMode.MARKDOWN,
    )
    os.remove("{}.backup".format(chat_id))  # Cleaning file
Esempio n. 30
0
def __chat_settings__(chat_id, user_id):
    return "This chat has had it's rules set: `{}`".format(
        bool(sql.get_rules(chat_id)))