示例#1
0
async def CountVoid(message: types.Message):
    fromUserId = message.from_user.id
    chatID = message.chat.id
    chatType = message.chat.type

    global IsStartedCount
    if IsUserInBlackList(fromUserId):
        return
    if DBH.IsAdmin(fromUserId):
        if not IsStartedCount:
            isShortVariant = False
            Variant = (message.text).replace("/count", "").replace(" ", "")
            if Variant == "short":
                isShortVariant = True
            adminList = DBH.GetAdmins()
            for i in adminList:
                if not isShortVariant:
                    await bot.send_message(
                        i,
                        "Начат подсчёт количества участников всех чатов.",
                        reply_markup=CustomMarkup.DeleteMarkup(i, "private"))
                else:
                    await bot.send_message(
                        i,
                        "Начат подсчёт количества участников групповых чатов.",
                        reply_markup=CustomMarkup.DeleteMarkup(i, "private"))
            IsStartedCount = True
            CountUsers = 0
            listGC = DBH.GetGroupChatIDs()
            for i in listGC:
                try:
                    CountUsers += await bot.get_chat_members_count(i)
                except:
                    Print("Chat " + str(i) + " not found.", "W")
                time.sleep(0.035)
            if not isShortVariant:
                listPC = DBH.GetPrivateChatIDs()
                for i in listPC:
                    try:
                        CountUsers += await bot.get_chat_members_count(i) - 1
                    except:
                        Print("Chat " + str(i) + " not found.", "W")
                    time.sleep(0.035)
                IsStartedCount = False
            for i in adminList:
                if not isShortVariant:
                    await bot.send_message(
                        i,
                        "Количество участников всех чатов: " + str(CountUsers),
                        reply_markup=CustomMarkup.DeleteMarkup(i, "private"))
                else:
                    await bot.send_message(
                        i,
                        "Количество участников групповых чатов: " +
                        str(CountUsers),
                        reply_markup=CustomMarkup.DeleteMarkup(i, "private"))
        else:
            await message.reply("Подсчёт уже начат.",
                                reply_markup=CustomMarkup.DeleteMarkup(
                                    chatID, chatType))
示例#2
0
def CheckArgument(key: str, value: str) -> bool:
    isAllOkArg = True
    if key == "--logs" or key == "-l":
        if value == "on":
            EnableLogging()
        elif value == "off":
            DisableLogging()
        else:
            isAllOkArg = False
    elif key == "--admin" or key == "-a":
        if value.isdigit():
            if not DBH.IsAdmin(value):
                DBH.AddAdmin(value)
        else:
            isAllOkArg = False
    elif key == "--updates" or key == "-u":
        if value == "on":
            EnableUpdates()
        elif value == "off":
            DisableUpdates()
        else:
            isAllOkArg = False
    else:
        print("Error. Unknow argument '{}'".format(key))
    return isAllOkArg
示例#3
0
async def UnbanVoid(message: types.Message):
    fromUserId = message.from_user.id
    chatID = message.chat.id
    chatType = message.chat.type

    if IsUserInBlackList(fromUserId, chatID):
        return
    if DBH.IsAdmin(fromUserId):
        banID = message.text
        banID = banID.replace("/ban ", "")
        if banID.isdigit() or (banID[1:].isdigit() and banID[0] == '-'):
            if not DBH.IsBlacklisted(banID):
                AddToBlackList(int(banID), chatID, chatID)
                if DBH.IsBlacklisted(banID):
                    await message.reply(
                        "Пользователь/чат успешно заблокирован.",
                        reply_markup=CustomMarkup.DeleteMarkup(
                            chatID, chatType))
                else:
                    await message.reply(
                        "Не удалось заблокировать пользователя/чат.",
                        reply_markup=CustomMarkup.DeleteMarkup(
                            chatID, chatType))
            else:
                await message.reply(
                    "Данный пользователь/чат находится в ЧС. Блокировка не возможна.",
                    reply_markup=CustomMarkup.DeleteMarkup(chatID, chatType))
        else:
            await message.reply("В ID должны быть только цифры и минус.",
                                reply_markup=CustomMarkup.DeleteMarkup(
                                    chatID, chatType))
示例#4
0
def EditMenuMarkup(chatID: str, chatType: str) -> InlineKeyboardMarkup:
    def RulesMark(role: str, answDict) -> str:
        if answDict['editSettings'] == role:
            return " ✅"
        else:
            return " ❌"

    lang = DBH.GetSetting(chatID, "lang", chatType)
    AllSettings = DBH.GetAllSettings(chatID, chatType)
    dictLang = ButtonTexts[lang]
    EditMenuMU = InlineKeyboardMarkup()
    EditMenuMU.add(
        InlineKeyboardButton(dictLang['creator'] +
                             RulesMark('creator', AllSettings),
                             callback_data="edit_creator"))
    EditMenuMU.add(
        InlineKeyboardButton(dictLang['admins'] +
                             RulesMark('admins', AllSettings),
                             callback_data="edit_admins"))
    EditMenuMU.add(
        InlineKeyboardButton(dictLang['everybody'] +
                             RulesMark('everybody', AllSettings),
                             callback_data="edit_everybody"))
    EditMenuMU.add(
        InlineKeyboardButton(dictLang['back'], callback_data="settings"))
    return EditMenuMU
示例#5
0
async def AddAdminVoid(message: types.Message):
    fromUserId = message.from_user.id
    chatID = message.chat.id
    chatType = message.chat.type

    if IsUserInBlackList(fromUserId, chatID):
        return
    if DBH.IsAdmin(fromUserId):
        newAdminID = message.text
        newAdminID = newAdminID.replace("/newadmin ", "")
        if newAdminID.isdigit():
            if not DBH.IsAdmin(newAdminID):
                DBH.AddAdmin(int(newAdminID))
                ListOfAdmins = DBH.GetAdmins()
                if newAdminID in ListOfAdmins:
                    await message.reply(
                        "Новый администратор успешно добавлен.",
                        reply_markup=CustomMarkup.DeleteMarkup(
                            chatID, chatType))
                else:
                    await message.reply(
                        "Не удалось добавить нового администратора.",
                        reply_markup=CustomMarkup.DeleteMarkup(
                            chatID, chatType))
            else:
                await message.reply(
                    "Данный ID уже есть в списке администраторов.",
                    reply_markup=CustomMarkup.DeleteMarkup(chatID, chatType))
        else:
            await message.reply(
                "В ID должны быть только цифры и возможно минус.",
                reply_markup=CustomMarkup.DeleteMarkup(chatID, chatType))
示例#6
0
async def UnbanVoid(message: types.Message):
    fromUserId = message.from_user.id
    chatID = message.chat.id
    chatType = message.chat.type

    if IsUserInBlackList(fromUserId, chatID):
        return
    if DBH.IsAdmin(fromUserId):
        unbanID = message.text
        unbanID = unbanID.replace("/unban ", "")
        if unbanID.isdigit():
            if DBH.IsBlacklisted(unbanID):
                RemoveFromBlackList(int(unbanID))
                if not DBH.IsBlacklisted(unbanID):
                    await message.reply("Пользователь успешно разблокирован.",
                                        reply_markup=CustomMarkup.DeleteMarkup(
                                            chatID, chatType))
                else:
                    await message.reply(
                        "Не удалось разблокировать пользователя.",
                        reply_markup=CustomMarkup.DeleteMarkup(
                            chatID, chatType))
            else:
                await message.reply(
                    "Данный пользователь не находится в ЧС. Разблокировка не возможна.",
                    reply_markup=CustomMarkup.DeleteMarkup(chatID, chatType))
        else:
            await message.reply("В ID должны быть только цифры и минус.",
                                reply_markup=CustomMarkup.DeleteMarkup(
                                    chatID, chatType))
示例#7
0
def DeleteButtonMenuMarkup(chatID: str, chatType: str) -> InlineKeyboardMarkup:
    def RulesMark(role: str, answDict) -> str:
        if answDict['deleteRules'] == role:
            return " ✅"
        else:
            return " ❌"

    lang = DBH.GetSetting(chatID, "lang", chatType)
    AllSettings = DBH.GetAllSettings(chatID, chatType)
    dictLang = ButtonTexts[lang]
    DeleteButtonMenuMU = InlineKeyboardMarkup()
    if AllSettings['deleteButton']:
        DeleteButtonMenuMU.add(
            InlineKeyboardButton(dictLang['delbutton'] + " ✅",
                                 callback_data="delbut_button"))
        if chatType != "private":
            DeleteButtonMenuMU.add(
                InlineKeyboardButton(dictLang['creator'] +
                                     RulesMark('creator', AllSettings),
                                     callback_data="delbut_creator"))
            DeleteButtonMenuMU.add(
                InlineKeyboardButton(dictLang['admins'] +
                                     RulesMark('admins', AllSettings),
                                     callback_data="delbut_admins"))
            DeleteButtonMenuMU.add(
                InlineKeyboardButton(dictLang['everybody'] +
                                     RulesMark('everybody', AllSettings),
                                     callback_data="delbut_everybody"))
    else:
        DeleteButtonMenuMU.add(
            InlineKeyboardButton(dictLang['delbutton'] + " ❌",
                                 callback_data="delbut_button"))
    DeleteButtonMenuMU.add(
        InlineKeyboardButton(dictLang['back'], callback_data="settings"))
    return DeleteButtonMenuMU
示例#8
0
def DeleteMarkup(chatID: str, chatType: str) -> InlineKeyboardMarkup:
    isDeleteButton = DBH.GetSetting(chatID, "deleteButton", chatType)
    DeleteMU = InlineKeyboardMarkup()
    if isDeleteButton:
        lang = DBH.GetSetting(chatID, "lang", chatType)
        dictLang = ButtonTexts[lang]
        DeleteMU.add(
            InlineKeyboardButton(dictLang['delete'], callback_data="delete"))
    return DeleteMU
示例#9
0
async def BackupVoid(message: types.Message):
    fromUserId = message.from_user.id
    chatID = message.chat.id
    chatType = message.chat.type

    if IsUserInBlackList(fromUserId):
        return
    if DBH.IsAdmin(fromUserId):
        nameOfBackup = DBH.CreateAllBackups()
        backupFile = open(nameOfBackup, 'rb')
        await bot.send_document(chatID, backupFile)
示例#10
0
async def StatsVoid(message: types.Message):
    fromUserId = message.from_user.id
    chatID = message.chat.id
    chatType = message.chat.type

    if IsUserInBlackList(fromUserId, chatID):
        return
    if DBH.IsAdmin(fromUserId):
        chatStats = DBH.GetChatsAmount()
        answerMes = "ЛС: " + str(chatStats['private']) + "\nГруппы: " + str(
            chatStats['groups'])
        await message.reply(answerMes,
                            reply_markup=CustomMarkup.DeleteMarkup(
                                chatID, chatType))
示例#11
0
def DonateMarkup(chatID: str, chatType: str) -> InlineKeyboardMarkup:
    lang = DBH.GetSetting(chatID, "lang", chatType)
    isDeleteButton = DBH.GetSetting(chatID, "deleteButton", chatType)
    dictLang = ButtonTexts[lang]
    DonateMU = InlineKeyboardMarkup()
    DonateMU.add(
        InlineKeyboardButton(
            dictLang['donate'],
            url="https://secure.wayforpay.com/payment/s3641f64becae",
            callback_data="donate"))
    if isDeleteButton:
        DonateMU.add(
            InlineKeyboardButton(dictLang['delete'], callback_data="delete"))
    return DonateMU
示例#12
0
def CryptoMenuMarkup(chatID: str, chatType: str) -> InlineKeyboardMarkup:
    lang = DBH.GetSetting(chatID, "lang", chatType)
    dictLang = ButtonTexts[lang]
    CryptoMenuMU = InlineKeyboardMarkup()
    AllCrypto = ListsCache.GetListOfCrypto()
    TurnedOnCrypto = DBH.GetAllCrypto(chatID)
    for i in AllCrypto:
        if i in TurnedOnCrypto:
            CryptoMenuMU.add(
                InlineKeyboardButton(i + " ✅", callback_data="cur_" + i))
        else:
            CryptoMenuMU.add(
                InlineKeyboardButton(i + " ❌", callback_data="cur_" + i))
    CryptoMenuMU.add(
        InlineKeyboardButton(dictLang['back'], callback_data="cur_menu"))
    return CryptoMenuMU
示例#13
0
def CanUserEditSettings(chatID: str,
                        chatType: str,
                        memberStatus: str,
                        AllMembersAreAdministrators: bool = False) -> bool:
    CanUserEditSettings = False
    AllChatSettings = DBH.GetAllSettings(chatID, chatType)
    if chatType == "private":
        CanUserEditSettings = True
    else:
        whoCanEditSettings = AllChatSettings['editSettings']
        if whoCanEditSettings == "everybody":
            CanUserEditSettings = True
        elif chatType == "group":

            if AllMembersAreAdministrators == True and whoCanEditSettings == 'admins':
                CanUserEditSettings = True
            elif AllMembersAreAdministrators == True and whoCanEditSettings == 'creator':
                if memberStatus == 'creator':
                    CanUserEditSettings = True
            elif AllMembersAreAdministrators == False:
                if whoCanEditSettings == 'admins' and (
                        memberStatus == "administrator"
                        or memberStatus == "creator"
                ) or whoCanEditSettings == 'creator' and memberStatus == "creator":
                    CanUserEditSettings = True
        elif chatType == "supergroup":
            if whoCanEditSettings == 'admins' and (
                    memberStatus == "administrator"
                    or memberStatus == "creator"
            ) or whoCanEditSettings == 'creator' and memberStatus == "creator":
                CanUserEditSettings = True
    return CanUserEditSettings
示例#14
0
def FlagsMarkup(chatID: str, chatType: str) -> InlineKeyboardMarkup:
    lang = DBH.GetSetting(chatID, "lang", chatType)
    AllSettings = DBH.GetAllSettings(chatID, chatType)
    dictLang = ButtonTexts[lang]
    FlagsMU = InlineKeyboardMarkup()
    if AllSettings['flags']:
        FlagsMU.add(
            InlineKeyboardButton(dictLang['flags_button'] + " ✅",
                                 callback_data="flags_button"))
    else:
        FlagsMU.add(
            InlineKeyboardButton(dictLang['flags_button'] + " ❌",
                                 callback_data="flags_button"))
    FlagsMU.add(
        InlineKeyboardButton(dictLang['back'], callback_data="settings"))
    return FlagsMU
示例#15
0
def LoadDataForBot():
    DBH.DBIntegrityCheck()
    LoadBlackList()
    LoadCurrencies()
    LoadCrypto()
    LoadFlags()
    LoadDictionaries()
    LoadTexts()
示例#16
0
async def FullStatsVoid(message: types.Message):
    fromUserId = message.from_user.id
    chatID = message.chat.id
    chatType = message.chat.type

    if IsUserInBlackList(fromUserId):
        return
    if DBH.IsAdmin(fromUserId):
        chatStats = DBH.GetTimeStats()
        answerMes = "За всё время:\nЛС: " + str(
            chatStats['private']) + "\nГруппы: " + str(
                chatStats['groups']) + "\n\nЗа неделю:\nЛС: " + str(
                    chatStats['activePrivateWeek']) + "\nГруппы: " + str(
                        chatStats['activeGroupsWeek']
                    ) + "\n\nЗа 30 дней:\nЛС: " + str(
                        chatStats['activePrivateMonth']) + "\nГруппы: " + str(
                            chatStats['activeGroupsMonth'])
        await message.reply(answerMes,
                            reply_markup=CustomMarkup.DeleteMarkup(
                                chatID, chatType))
示例#17
0
async def WrongMes(message: types.Message):
    fromUserId = message.from_user.id
    chatID = message.chat.id
    chatType = message.chat.type

    if IsUserInBlackList(fromUserId):
        return
    IsChatExist(chatID, chatType)
    MessageText = message.reply_to_message.text
    if message.photo or message.video is not None or message.document is not None:
        MessageText = message.reply_to_message.caption
    DBH.AddReport(chatID, fromUserId, MessageText)
示例#18
0
def CurrenciesSetupMarkup(chatID: str, chatType: str,
                          letter: str) -> InlineKeyboardMarkup:
    lang = DBH.GetSetting(chatID, "lang", chatType)
    dictLang = ButtonTexts[lang]
    AllCurrencies = ListsCache.GetListOfCur()
    TurnedOnCurrencies = DBH.GetAllCurrencies(chatID)
    AllFlags = ListsCache.GetDictOfFlags()
    CurrenciesSetupMU = InlineKeyboardMarkup()
    if len(letter) == 1:
        letter = letter.upper()
        for i in AllCurrencies:
            if i[0] == letter:
                if i in TurnedOnCurrencies:
                    CurrenciesSetupMU.add(
                        InlineKeyboardButton(AllFlags[i] + i + " ✅",
                                             callback_data="cur_" + i))
                else:
                    CurrenciesSetupMU.add(
                        InlineKeyboardButton(AllFlags[i] + i + " ❌",
                                             callback_data="cur_" + i))
    else:
        firstLetter = ord(letter[0].upper())
        lastLetter = ord(letter[1].upper())
        listOfLetters = []
        while firstLetter <= lastLetter:
            listOfLetters.append(chr(firstLetter))
            firstLetter += 1
        for i in AllCurrencies:
            if i[0] in listOfLetters:
                if i in TurnedOnCurrencies:
                    CurrenciesSetupMU.add(
                        InlineKeyboardButton(AllFlags[i] + i + " ✅",
                                             callback_data="cur_" + i))
                else:
                    CurrenciesSetupMU.add(
                        InlineKeyboardButton(AllFlags[i] + i + " ❌",
                                             callback_data="cur_" + i))
    CurrenciesSetupMU.add(
        InlineKeyboardButton(dictLang['back'], callback_data="cur_curmenu"))
    return CurrenciesSetupMU
示例#19
0
async def EchoVoid(message: types.Message):
    fromUserId = message.from_user.id
    chatID = message.chat.id

    if IsUserInBlackList(fromUserId, chatID):
        return
    if DBH.IsAdmin(fromUserId):
        MessageToUsers = (message.text).replace("/echo ", "")
        adminList = DBH.GetAdmins()
        for i in adminList:
            await bot.send_message(
                i,
                "Начата рассылка сообщения всем пользователям. Текст сообщения:\n\n"
                + MessageToUsers,
                reply_markup=CustomMarkup.DeleteMarkup(i, "private"))
        listGC = DBH.GetGroupChatIDs()
        for i in listGC:
            try:
                await bot.send_message(i,
                                       MessageToUsers,
                                       reply_markup=CustomMarkup.DonateMarkup(
                                           i, "group"))
            except:
                Print("Chat " + str(i) + " is not available.", "W")
            time.sleep(0.035)
        listPC = DBH.GetPrivateChatIDs()
        for i in listPC:
            try:
                await bot.send_message(i,
                                       MessageToUsers,
                                       reply_markup=CustomMarkup.DonateMarkup(
                                           i, "private"))
            except:
                Print("Chat " + str(i) + " is not available.", "W")
            time.sleep(0.035)
        for i in adminList:
            await bot.send_message(i,
                                   "Рассылка закончена.",
                                   reply_markup=CustomMarkup.DeleteMarkup(
                                       i, "private"))
示例#20
0
def SettingsMarkup(chatID: str, chatType: str) -> InlineKeyboardMarkup:
    lang = DBH.GetSetting(chatID, "lang", chatType)
    isDeleteButton = DBH.GetSetting(chatID, "deleteButton", chatType)
    dictLang = ButtonTexts[lang]
    SettingsMU = InlineKeyboardMarkup()
    SettingsMU.add(
        InlineKeyboardButton(dictLang['currencies'], callback_data="cur_menu"))
    SettingsMU.add(
        InlineKeyboardButton(dictLang['lang'], callback_data="lang_menu"))
    SettingsMU.add(
        InlineKeyboardButton(dictLang['delete_button'],
                             callback_data="delbut_menu"))
    SettingsMU.add(
        InlineKeyboardButton(dictLang['flags'], callback_data="flags_menu"))
    if chatType != "private":
        SettingsMU.add(
            InlineKeyboardButton(dictLang['permisssions'],
                                 callback_data="edit_menu"))
    if isDeleteButton:
        SettingsMU.add(
            InlineKeyboardButton(dictLang['delete'], callback_data="delete"))
    return SettingsMU
示例#21
0
def GetText(chatID: str, nameOfText: str, chatType: str) -> str:
    lang = DBH.GetSetting(chatID, "lang", chatType)
    answerText = ''
    if nameOfText in ListOfNamesOfTextforBigTexts:
        dictLang = AllBigTexts[lang]
        answerText = dictLang[nameOfText]
    elif nameOfText in ButtonTexts[lang]:
        dictLang = ButtonTexts[lang]
        answerText = dictLang[nameOfText]
    elif nameOfText in MessageTexts[lang]:
        dictLang = MessageTexts[lang]
        answerText = dictLang[nameOfText]
    return answerText
示例#22
0
async def BackupVoid(message: types.Message):
    fromUserId = message.from_user.id
    chatID = message.chat.id
    chatType = message.chat.type

    if IsUserInBlackList(fromUserId, chatID):
        return
    if DBH.IsAdmin(fromUserId):
        nameOfBackup = DBH.CreateAllBackups()
        fileSize = os.path.getsize(nameOfBackup)
        if fileSize <= 5242880:
            try:
                backupFile = open(nameOfBackup, 'rb')
                await bot.send_document(chatID, backupFile)
            except:
                await message.reply("Не удалось отправить файл.",
                                    reply_markup=CustomMarkup.DeleteMarkup(
                                        chatID, chatType))
        else:
            await message.reply(
                "Файл слишком велик. Его вес " + str(fileSize) + " Байт.",
                reply_markup=CustomMarkup.DeleteMarkup(chatID, chatType))
示例#23
0
def CanUserEditSettings(chatID: str,
                        chatType: str,
                        memberStatus: str,
                        userID: str,
                        userName: str,
                        AllMembersAreAdministrators: bool = False) -> bool:
    сanUserEditSettings = False
    AllChatSettings = DBH.GetAllSettings(chatID, chatType)
    if DBH.IsAdmin(userID):
        сanUserEditSettings = True
    elif chatType == "private":
        сanUserEditSettings = True
    else:
        whoCanEditSettings = AllChatSettings['editSettings']
        if whoCanEditSettings == "everybody":
            сanUserEditSettings = True
        elif chatType == "group":
            if AllMembersAreAdministrators == True and whoCanEditSettings == 'admins':
                сanUserEditSettings = True
            elif AllMembersAreAdministrators == True and whoCanEditSettings == 'creator':
                if memberStatus == 'creator' or userName == "GroupAnonymousBot":
                    сanUserEditSettings = True
            elif AllMembersAreAdministrators == False:
                if whoCanEditSettings == 'admins' and (
                        memberStatus == "administrator" or memberStatus
                        == "creator" or userName == "GroupAnonymousBot"
                ) or whoCanEditSettings == 'creator' and (
                        memberStatus == "creator"
                        or userName == "GroupAnonymousBot"):
                    сanUserEditSettings = True
        elif chatType == "supergroup":
            if whoCanEditSettings == 'admins' and (
                    memberStatus == "administrator" or memberStatus
                    == "creator" or userName == "GroupAnonymousBot"
            ) or whoCanEditSettings == 'creator' and (memberStatus == "creator"
                                                      or userName
                                                      == "GroupAnonymousBot"):
                сanUserEditSettings = True
    return сanUserEditSettings
示例#24
0
def CurrenciesMainMenuMarkup(chatID: str,
                             chatType: str) -> InlineKeyboardMarkup:
    lang = DBH.GetSetting(chatID, "lang", chatType)
    dictLang = ButtonTexts[lang]
    CurrenciesMainMenuMU = InlineKeyboardMarkup()
    CurrenciesMainMenuMU.add(
        InlineKeyboardButton(dictLang['cur_menu'],
                             callback_data="cur_curmenu"))
    CurrenciesMainMenuMU.add(
        InlineKeyboardButton(dictLang['crypto_menu'],
                             callback_data="cur_cryptomenu"))
    CurrenciesMainMenuMU.add(
        InlineKeyboardButton(dictLang['back'], callback_data="settings"))
    return CurrenciesMainMenuMU
示例#25
0
def LanguageMenuMarkup(chatID: str, chatType: str):
    def RulesMark(lang: str, answDict) -> str:
        if answDict['lang'] == lang:
            return " ✅"
        else:
            return " ❌"

    lang = DBH.GetSetting(chatID, "lang", chatType)
    AllSettings = DBH.GetAllSettings(chatID, chatType)
    dictLang = ButtonTexts[lang]
    LanguageMenuMU = InlineKeyboardMarkup()
    LanguageMenuMU.add(
        InlineKeyboardButton("🇬🇧EN" + RulesMark('en', AllSettings),
                             callback_data="lang_en"))
    LanguageMenuMU.add(
        InlineKeyboardButton("🇷🇺RU" + RulesMark('ru', AllSettings),
                             callback_data="lang_ru"))
    LanguageMenuMU.add(
        InlineKeyboardButton("🇺🇦UA" + RulesMark('ua', AllSettings),
                             callback_data="lang_ua"))
    LanguageMenuMU.add(
        InlineKeyboardButton(dictLang['back'], callback_data="settings"))
    return LanguageMenuMU
示例#26
0
async def EchoVoid(message: types.Message):
    fromUserId = message.from_user.id
    chatID = message.chat.id

    if IsUserInBlackList(fromUserId, chatID):
        return
    if DBH.IsAdmin(fromUserId):
        MessageToUsers = (message.text).replace("/write ", "")
        index = MessageToUsers.find(" ")
        toChatID = MessageToUsers[0:index]
        print(toChatID)
        MessageToUsers = MessageToUsers.replace(str(chatID) + " ", "")
        try:
            await bot.send_message(toChatID, MessageToUsers)
            await bot.send_message(fromUserId, "Сообщение отправлено.")
        except:
            await bot.send_message(fromUserId,
                                   "Не удалось отправить сообщение.")
示例#27
0
def CurrenciesMenuMarkup(chatID: str, chatType: str) -> InlineKeyboardMarkup:
    lang = DBH.GetSetting(chatID, "lang", chatType)
    dictLang = ButtonTexts[lang]
    CurrenciesMenuMU = InlineKeyboardMarkup()
    CurrenciesMenuMU.add(InlineKeyboardButton("A", callback_data="cur_a"))
    CurrenciesMenuMU.add(InlineKeyboardButton("B", callback_data="cur_b"))
    CurrenciesMenuMU.add(InlineKeyboardButton("C", callback_data="cur_c"))
    CurrenciesMenuMU.add(InlineKeyboardButton("D-F", callback_data="cur_df"))
    CurrenciesMenuMU.add(InlineKeyboardButton("G-H", callback_data="cur_gh"))
    CurrenciesMenuMU.add(InlineKeyboardButton("I-J", callback_data="cur_ij"))
    CurrenciesMenuMU.add(InlineKeyboardButton("K-L", callback_data="cur_kl"))
    CurrenciesMenuMU.add(InlineKeyboardButton("M", callback_data="cur_m"))
    CurrenciesMenuMU.add(InlineKeyboardButton("N-Q", callback_data="cur_nq"))
    CurrenciesMenuMU.add(InlineKeyboardButton("R-S", callback_data="cur_rs"))
    CurrenciesMenuMU.add(InlineKeyboardButton("T-U", callback_data="cur_tu"))
    CurrenciesMenuMU.add(InlineKeyboardButton("V-Y", callback_data="cur_vy"))
    CurrenciesMenuMU.add(
        InlineKeyboardButton(dictLang['back'], callback_data="cur_menu"))
    return CurrenciesMenuMU
def LoadBlackList():
    global BlackList
    BlackList = DBH.GetBlacklist()
def AddToBlackList(userID: str, chatID: str, chatName: str):
    if userID not in BlackList:
        BlackList.append(userID)
    DBH.AddBlacklist(userID, chatID, chatName)
def RemoveFromBlackList(userID: str):
    BlackList.remove(userID)
    DBH.ClearBlacklist(userID)