Example #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))
Example #2
0
def UpdateExchangeRates() -> dict:
    global exchangeRates
    Print("Updating of exchange rates has started.", "S")
    try:
        url = "http://data.fixer.io/api/latest?access_key=" + apiKey
        response = requests.get(url)
        exchangeRates = response.json()['rates']
        exchangeRates['TMT'] = exchangeRates['RUB'] / 2
        UpdateExchangeRatesDB(exchangeRates.copy())
        Print("Updating of exchange rates is successfull.", "S")
    except:
        Print("Updating ER failed.", "E")
        Print("Using exchange rates from DB.", "S")
        exchangeRates = GetExchangeRates()
    return exchangeRates.copy()
Example #3
0
def ReverseCurrencySetting(chatID: str, currency: str):
    chatID = int(chatID)
    con = sql.connect('DataBases/DataForBot.sqlite')
    cursor = con.cursor()
    try:
        cursor.execute("SELECT " + "_" + str(currency) +
                       " from SettingsExchangeRates WHERE chatID = " +
                       str(chatID))
        res = cursor.fetchone()
        cursor.execute("UPDATE OR ABORT SettingsExchangeRates SET " + "_" +
                       str(currency) + "= " + str(int(not res[0])) +
                       " WHERE chatID = " + str(chatID))
        con.commit()
    except:
        try:
            cursor.execute("SELECT " + str(currency) +
                           " from SettingsCryptoRates WHERE chatID = " +
                           str(chatID))
            res = cursor.fetchone()
            cursor.execute("UPDATE OR ABORT SettingsCryptoRates SET " +
                           str(currency) + "= " + str(int(not res[0])) +
                           " WHERE chatID = " + str(chatID))
            con.commit()
        except:
            Print(
                "No such column. Cannot find '" + str(currency) +
                "'. Error in 'ReverseCurrencySetting'.", "E")
Example #4
0
def LoadTexts():
    global AllBigTexts
    global ListOfNamesOfTextforBigTexts
    UAtexts = {}
    RUtexts = {}
    ENtexts = {}
    try:
        listFiles = os.listdir("Texts")
        for i in listFiles:
            fileWithText = open("Texts/" + i)
            fileText = fileWithText.read()
            fileWithText.close()
            nameOfText = i[2:-4]
            if nameOfText not in ListOfNamesOfTextforBigTexts:
                ListOfNamesOfTextforBigTexts.append(nameOfText)
            if i.find("UA") == 0:
                UAtexts[nameOfText] = fileText
            elif i.find("EN") == 0:
                ENtexts[nameOfText] = fileText
            elif i.find("RU") == 0:
                RUtexts[nameOfText] = fileText
        AllBigTexts['ua'] = UAtexts
        AllBigTexts['ru'] = RUtexts
        AllBigTexts['en'] = ENtexts
    except:
        Print("Problem with Texts. Redownload, pls.", "E")
Example #5
0
def UpdateCryptoRates() -> dict:
    global cryptoRates
    Print("Updating of crypto rates has started.", "S")
    try:
        url = "https://api.binance.com/api/v3/ticker/price"
        response = requests.get(url)
        cryptoRates = {}
        for pair in response.json():
            if pair['symbol'].find("USDT") != -1 and any(
                    pair['symbol'][:-4] == s for s in cryptoList):
                cryptoRates[pair['symbol'][:-4]] = float(pair['price'])
        UpdateCryptoRatesDB(cryptoRates.copy())
        Print("Updating of crypto rates is successfull.", "S")
    except:
        Print("Updating CR failed.", "E")
        Print("Using crypto rates from DB.", "S")
        cryptoRates = GetCryptoRates()
    return cryptoRates.copy()
Example #6
0
def CreateFileBackup(filePath: str):
    if os.path.exists("Backups"):
        pass
    else:
        Print("Folder 'Backups' not found.", "E")
        os.mkdir("Backups")
        Print("Folder 'Backups' is created", "S")
    today = datetime.datetime.today()
    dt = today.strftime("%Y-%m-%d-%H.%M.%S")
    nameOfDB = filePath.find("/")
    nameOfDB = filePath[filePath + 1:-7]
    nameOfArch = 'Backups/' + nameOfDB + '-' + dt + '.zip'
    zipArch = zipfile.ZipFile(nameOfArch, 'w')
    try:
        zipArch.write(filePath)
        zipArch.close()
        Print(filePath + " added to " + nameOfArch, "S")
    except:
        Print("Cannot add " + filePath + " to archive.", "E")
Example #7
0
def CreateAllBackups() -> str:
    if os.path.exists("Backups"):
        pass
    else:
        Print("Folder 'Backups' not found.", "E")
        os.mkdir("Backups")
        Print("Folder 'Backups' is created", "S")
    today = datetime.datetime.today()
    dt = today.strftime("%Y-%m-%d-%H.%M.%S")
    nameOfArch = 'Backups/backup-' + dt + '.zip'
    zipArch = zipfile.ZipFile(nameOfArch, 'w')
    try:
        zipArch.write("DataBases/DataForBot.sqlite")
        zipArch.write("DataBases/ServiceData.sqlite")
        zipArch.write("DataBases/StatsData.sqlite")
        zipArch.close()
        Print("Backup " + nameOfArch + " created.", "S")
    except:
        Print("Cannot create archive.", "E")
    return nameOfArch
Example #8
0
def CreateServiceDataBase():
    if os.path.exists("DataBases"):
        pass
    else:
        Print("Folder 'DataBases' not found", "E")
        sys.exit(1)
    Print("Creating service DB is starting...", "S")
    # Connect to DB
    con = sql.connect('DataBases/ServiceData.sqlite')
    cursor = con.cursor()

    with con:
        con.execute("""
            CREATE TABLE AdminsList (
                adminID INTEGER NOT NULL PRIMARY KEY 
            );
        """)

    with con:
        con.execute("""
            CREATE TABLE BlackList (
                userID INTEGER NOT NULL PRIMARY KEY ,
                banDate TEXT DEFAULT 0,
                chatID INTEGER DEFAULT 0,
                chatName TEXT DEFAULT 0
            );
        """)

    with con:
        con.execute("""
            CREATE TABLE Reports (
                date TEXT,
                chatID INTEGER DEFAULT 0,
                userID INTEGER DEFAULT 0,
                message TEXT,
                reply TEXT
            );
        """)

    con.close()
    Print("Service DB is created.", "S")
Example #9
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"))
Example #10
0
def SetCryptoSetting(chatID: str, crypto: str, val: str):
    chatID = int(chatID)
    con = sql.connect('DataBases/DataForBot.sqlite')
    cursor = con.cursor()
    try:
        cursor.execute("UPDATE OR ABORT SettingsCryptoRates SET " +
                       str(crypto) + "= " + str(val) + " WHERE chatID = " +
                       str(chatID))
        con.commit()
    except:
        Print(
            "No such column. Cannot find '" + str(crypto) +
            "'. Error in 'SetCryptoSetting'.", "E")
Example #11
0
def GetAllCrypto(chatID: str) -> list:
    chatID = int(chatID)
    con = sql.connect('DataBases/DataForBot.sqlite')
    con.row_factory = sql.Row
    cursor = con.cursor()
    try:
        cursor.execute("SELECT * FROM SettingsCryptoRates WHERE chatID = " +
                       str(chatID))
        res = dict(cursor.fetchone())
        return [k for k, v in res.items() if v == 1]
    except:
        Print(
            "No such column. Cannot find '" + str(chatID) +
            "'. Error in 'GetAllCrypto'.", "E")
        return None
Example #12
0
async def WrongMes(message: types.Message):
    fromUserId = message.from_user.id
    chatID = message.chat.id
    chatType = message.chat.type

    if IsUserInBlackList(fromUserId, chatID):
        return
    IsChatExist(chatID, chatType)
    try:
        MessageText = message.reply_to_message.text
    except:
        Print("Wrong mes error", "E")
        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)
Example #13
0
def SetSetting(chatID: str, key: str, val: str, chatType: str):
    chatID = int(chatID)
    con = sql.connect('DataBases/DataForBot.sqlite')
    cursor = con.cursor()
    try:
        if chatType == "group" or chatType == "supergroup":
            cursor.execute(
                "UPDATE OR ABORT SettingsGroups SET " + str(key) +
                " = ? WHERE chatID = ?", (val, chatID))
        else:
            cursor.execute(
                "UPDATE OR ABORT SettingsPrivateChats SET " + str(key) +
                " = ? WHERE chatID = ?", (val, chatID))
        con.commit()
    except:
        Print(
            "No such column. Cannot find '" + str(key) +
            "'. Error in 'SetSetting'.", "E")
Example #14
0
def ClearAdmins(adminID: str):
    adminID = int(adminID)
    con = sql.connect('DataBases/ServiceData.sqlite')
    cursor = con.cursor()
    if adminID == 0:
        cursor.execute("DELETE FROM AdminsList")
        con.commit()
        return 1
    else:
        try:
            cursor.execute("DELETE FROM AdminsList WHERE adminID = " +
                           str(adminID))
            con.commit()
            return 1
        except:
            Print(
                "No such adminID. Cannot find '" + str(adminID) +
                "'. Error in 'ClearAdmins'.", "E")
            return None
Example #15
0
def GetAllSettings(chatID: str, chatType: str) -> dict:
    chatID = int(chatID)
    con = sql.connect('DataBases/DataForBot.sqlite')
    con.row_factory = sql.Row
    cursor = con.cursor()
    try:
        if chatType == "group" or chatType == "supergroup":
            cursor.execute("SELECT * from SettingsGroups WHERE chatID = " +
                           str(chatID))
            res = cursor.fetchone()
        else:
            cursor.execute(
                "SELECT * from SettingsPrivateChats WHERE chatID = " +
                str(chatID))
            res = cursor.fetchone()
        return dict(res)
    except:
        Print(
            "No such column. Cannot find '" + str(chatID) +
            "'. Error in 'GetAllSettings'.", "E")
        return None
Example #16
0
def ClearBlacklist(userID: str):
    userID = int(userID)
    con = sql.connect('DataBases/ServiceData.sqlite')
    cursor = con.cursor()
    if userID == 0:
        cursor.execute("DELETE FROM BlackList")
        con.commit()
        cursor.execute("VACUUM")
        con.commit()
        return 1
    else:
        try:
            cursor.execute("DELETE FROM BlackList WHERE userID = " +
                           str(userID))
            con.commit()
            return 1
        except:
            Print(
                "No such column. Cannot find '" + str(userID) +
                "'. Error in 'ClearBlacklist'.", "E")
            return None
Example #17
0
def GetSetting(chatID: str, key: str, chatType: str) -> str:
    chatID = int(chatID)
    con = sql.connect('DataBases/DataForBot.sqlite')
    cursor = con.cursor()
    try:
        if chatType == "group" or chatType == "supergroup":
            cursor.execute("SELECT " + str(key) +
                           " from SettingsGroups WHERE chatID = " +
                           str(chatID))
            res = cursor.fetchone()
        else:
            cursor.execute("SELECT " + str(key) +
                           " from SettingsPrivateChats WHERE chatID = " +
                           str(chatID))
            res = cursor.fetchone()
        return res[0]
    except:
        Print(
            "No such column. Cannot find '" + str(key) +
            "'. Error in 'GetSetting'.", "E")
        return None
Example #18
0
def CreateStatsDataBase():
    Print("Creating stats DB is starting...", "S")
    # Connect to DB
    con = sql.connect('DataBases/StatsData.sqlite')
    cursor = con.cursor()

    with con:
        con.execute("""
            CREATE TABLE ChatsUsage (
                chatID INTEGER NOT NULL PRIMARY KEY,
                chatType TEXT,
                timeAdded TEXT,
                lastTimeUse TEXT
            );
        """)

    with con:
        con.execute("""
            CREATE TABLE ChatsTimeStats (
                date TEXT,
                privateChatsAmount INTEGER DEFAULT 0,
                groupChatsAmount INTEGER DEFAULT 0,
                activeWeekPrivateChats INTEGER DEFAULT 0,
                activeWeekGroupChats INTEGER DEFAULT 0,
                activeMonthPrivateChats INTEGER DEFAULT 0,
                activeMonthGroupChats INTEGER DEFAULT 0
            );
        """)

    with con:
        con.execute("""
            CREATE TABLE ProcessedCurrencies (
                date TEXT,
                chatID INTEGER,
                userID INTEGER,
                proccesedCurrency TEXT,
                message TEXT,
                _AED INTEGER DEFAULT 0,
                _AFN INTEGER DEFAULT 0,
                _ALL INTEGER DEFAULT 0,
                _AMD INTEGER DEFAULT 0,
                _ANG INTEGER DEFAULT 0,
                _AOA INTEGER DEFAULT 0,
                _ARS INTEGER DEFAULT 0,
                _AUD INTEGER DEFAULT 0,
                _AWG INTEGER DEFAULT 0,
                _AZN INTEGER DEFAULT 0,
                _BAM INTEGER DEFAULT 0,
                _BBD INTEGER DEFAULT 0,
                _BDT INTEGER DEFAULT 0,
                _BGN INTEGER DEFAULT 0,
                _BHD INTEGER DEFAULT 0,
                _BIF INTEGER DEFAULT 0,
                _BMD INTEGER DEFAULT 0,
                _BND INTEGER DEFAULT 0,
                _BOB INTEGER DEFAULT 0,
                _BRL INTEGER DEFAULT 0,
                _BSD INTEGER DEFAULT 0,
                _BTN INTEGER DEFAULT 0,
                _BWP INTEGER DEFAULT 0,
                _BYN INTEGER DEFAULT 0,
                _BZD INTEGER DEFAULT 0,
                _CAD INTEGER DEFAULT 0,
                _CDF INTEGER DEFAULT 0,
                _CHF INTEGER DEFAULT 0,
                _CLF INTEGER DEFAULT 0,
                _CLP INTEGER DEFAULT 0,
                _CNY INTEGER DEFAULT 0,
                _COP INTEGER DEFAULT 0,
                _CRC INTEGER DEFAULT 0,
                _CUC INTEGER DEFAULT 0,
                _CUP INTEGER DEFAULT 0,
                _CVE INTEGER DEFAULT 0,
                _CZK INTEGER DEFAULT 0,
                _DJF INTEGER DEFAULT 0,
                _DKK INTEGER DEFAULT 0,
                _DOP INTEGER DEFAULT 0,
                _DZD INTEGER DEFAULT 0,
                _EGP INTEGER DEFAULT 0,
                _ERN INTEGER DEFAULT 0,
                _ETB INTEGER DEFAULT 0,
                _EUR INTEGER DEFAULT 0,
                _FJD INTEGER DEFAULT 0,
                _FKP INTEGER DEFAULT 0,
                _GBP INTEGER DEFAULT 0,
                _GEL INTEGER DEFAULT 0,
                _GGP INTEGER DEFAULT 0,
                _GHS INTEGER DEFAULT 0,
                _GIP INTEGER DEFAULT 0,
                _GMD INTEGER DEFAULT 0,
                _GNF INTEGER DEFAULT 0,
                _GTQ INTEGER DEFAULT 0,
                _GYD INTEGER DEFAULT 0,
                _HKD INTEGER DEFAULT 0,
                _HNL INTEGER DEFAULT 0,
                _HRK INTEGER DEFAULT 0,
                _HTG INTEGER DEFAULT 0,
                _HUF INTEGER DEFAULT 0,
                _IDR INTEGER DEFAULT 0,
                _ILS INTEGER DEFAULT 0,
                _IMP INTEGER DEFAULT 0,
                _INR INTEGER DEFAULT 0,
                _IQD INTEGER DEFAULT 0,
                _IRR INTEGER DEFAULT 0,
                _ISK INTEGER DEFAULT 0,
                _JEP INTEGER DEFAULT 0,
                _JMD INTEGER DEFAULT 0,
                _JOD INTEGER DEFAULT 0,
                _JPY INTEGER DEFAULT 0,
                _KES INTEGER DEFAULT 0,
                _KGS INTEGER DEFAULT 0,
                _KHR INTEGER DEFAULT 0,
                _KMF INTEGER DEFAULT 0,
                _KPW INTEGER DEFAULT 0,
                _KRW INTEGER DEFAULT 0,
                _KWD INTEGER DEFAULT 0,
                _KYD INTEGER DEFAULT 0,
                _KZT INTEGER DEFAULT 0,
                _LAK INTEGER DEFAULT 0,
                _LBP INTEGER DEFAULT 0,
                _LKR INTEGER DEFAULT 0,
                _LRD INTEGER DEFAULT 0,
                _LSL INTEGER DEFAULT 0,
                _LTL INTEGER DEFAULT 0,
                _LVL INTEGER DEFAULT 0,
                _LYD INTEGER DEFAULT 0,
                _MAD INTEGER DEFAULT 0,
                _MDL INTEGER DEFAULT 0,
                _MGA INTEGER DEFAULT 0,
                _MKD INTEGER DEFAULT 0,
                _MMK INTEGER DEFAULT 0,
                _MNT INTEGER DEFAULT 0,
                _MOP INTEGER DEFAULT 0,
                _MRO INTEGER DEFAULT 0,
                _MUR INTEGER DEFAULT 0,
                _MVR INTEGER DEFAULT 0,
                _MWK INTEGER DEFAULT 0,
                _MXN INTEGER DEFAULT 0,
                _MYR INTEGER DEFAULT 0,
                _MZN INTEGER DEFAULT 0,
                _NAD INTEGER DEFAULT 0,
                _NGN INTEGER DEFAULT 0,
                _NIO INTEGER DEFAULT 0,
                _NOK INTEGER DEFAULT 0,
                _NPR INTEGER DEFAULT 0,
                _NZD INTEGER DEFAULT 0,
                _OMR INTEGER DEFAULT 0,
                _PAB INTEGER DEFAULT 0,
                _PEN INTEGER DEFAULT 0,
                _PGK INTEGER DEFAULT 0,
                _PHP INTEGER DEFAULT 0,
                _PKR INTEGER DEFAULT 0,
                _PLN INTEGER DEFAULT 0,
                _PYG INTEGER DEFAULT 0,
                _QAR INTEGER DEFAULT 0,
                _RON INTEGER DEFAULT 0,
                _RSD INTEGER DEFAULT 0,
                _RUB INTEGER DEFAULT 0,
                _RWF INTEGER DEFAULT 0,
                _SAR INTEGER DEFAULT 0,
                _SBD INTEGER DEFAULT 0,
                _SCR INTEGER DEFAULT 0,
                _SDG INTEGER DEFAULT 0,
                _SEK INTEGER DEFAULT 0,
                _SGD INTEGER DEFAULT 0,
                _SHP INTEGER DEFAULT 0,
                _SLL INTEGER DEFAULT 0,
                _SOS INTEGER DEFAULT 0,
                _SRD INTEGER DEFAULT 0,
                _SVC INTEGER DEFAULT 0,
                _SYP INTEGER DEFAULT 0,
                _SZL INTEGER DEFAULT 0,
                _THB INTEGER DEFAULT 0,
                _TJS INTEGER DEFAULT 0,
                _TMT INTEGER DEFAULT 0,
                _TND INTEGER DEFAULT 0,
                _TOP INTEGER DEFAULT 0,
                _TRY INTEGER DEFAULT 0,
                _TTD INTEGER DEFAULT 0,
                _TWD INTEGER DEFAULT 0,
                _TZS INTEGER DEFAULT 0,
                _UAH INTEGER DEFAULT 0,
                _UGX INTEGER DEFAULT 0,
                _USD INTEGER DEFAULT 0,
                _UYU INTEGER DEFAULT 0,
                _UZS INTEGER DEFAULT 0,
                _VEF INTEGER DEFAULT 0,
                _VND INTEGER DEFAULT 0,
                _VUV INTEGER DEFAULT 0,
                _WST INTEGER DEFAULT 0,
                _XAF INTEGER DEFAULT 0,
                _XAG INTEGER DEFAULT 0,
                _XAU INTEGER DEFAULT 0,
                _XCD INTEGER DEFAULT 0,
                _XOF INTEGER DEFAULT 0,
                _XPF INTEGER DEFAULT 0,
                _YER INTEGER DEFAULT 0,
                _ZAR INTEGER DEFAULT 0,
                _ZMW INTEGER DEFAULT 0,
                _ZWL INTEGER DEFAULT 0,
                _ADA INTEGER DEFAULT 0,
                _BCH INTEGER DEFAULT 0,
                _BNB INTEGER DEFAULT 0,
                _BTC INTEGER DEFAULT 0,
                _DASH INTEGER DEFAULT 0,
                _DOGE INTEGER DEFAULT 0,
                _ETC INTEGER DEFAULT 0,
                _ETH INTEGER DEFAULT 0,
                _LTC INTEGER DEFAULT 0,
                _RVN INTEGER DEFAULT 0,
                _TRX INTEGER DEFAULT 0,
                _XLM INTEGER DEFAULT 0,
                _XMR INTEGER DEFAULT 0,
                _XRP INTEGER DEFAULT 0
            );
        """)

    con.close()
    Print("Stats DB is created.", "S")
Example #19
0
def CreateDataBaseTemplate():
    if os.path.exists("DataBases"):
        pass
    else:
        Print("Folder 'DataBases' not found", "E")
        os.mkdir("DataBases")
        Print("Folder 'DataBases' is created", "S")
    Print("Creating main DB is starting...", "S")
    # Connect to DB
    con = sql.connect('DataBases/DataForBot.sqlite')
    cursor = con.cursor()

    with con:
        con.execute("""
            CREATE TABLE SettingsGroups (
                chatID INTEGER NOT NULL PRIMARY KEY ,
                deleteRules TEXT DEFAULT admins,
                deleteButton INTEGER DEFAULT 1,
                editSettings TEXT DEFAULT admins,
                flags INTEGER DEFAULT 1,
                lang TEXT DEFAULT en
            );
        """)
    with con:
        con.execute("""
            CREATE TABLE SettingsPrivateChats (
                chatID INTEGER NOT NULL PRIMARY KEY ,
                deleteButton INTEGER DEFAULT 1,
                flags INTEGER DEFAULT 1,
                lang TEXT DEFAULT en
            );
        """)
    with con:
        con.execute("""
            CREATE TABLE ExchangeRates (
                currency TEXT NOT NULL PRIMARY KEY,
                flag TEXT,
                exchangeRates FLOAT
            );
        """)
    with con:
        con.execute("""
            CREATE TABLE CryptoRates (
                currency TEXT NOT NULL PRIMARY KEY,
                flag TEXT,
                exchangeRates FLOAT
            );
        """)

    with con:
        con.execute("""
            CREATE TABLE SettingsCryptoRates (
                chatID INTEGER NOT NULL PRIMARY KEY,
                ADA INTEGER DEFAULT 0,
                BCH INTEGER DEFAULT 0,
                BNB INTEGER DEFAULT 0,
                BTC INTEGER DEFAULT 1,
                DASH INTEGER DEFAULT 0,
                DOGE INTEGER DEFAULT 0,
                ETC INTEGER DEFAULT 0,
                ETH INTEGER DEFAULT 1,
                LTC INTEGER DEFAULT 0,
                RVN INTEGER DEFAULT 0,
                TRX INTEGER DEFAULT 0,
                XLM INTEGER DEFAULT 0,
                XMR INTEGER DEFAULT 0,
                XRP INTEGER DEFAULT 0  
            );
        """)

    with con:
        con.execute("""
            CREATE TABLE SettingsExchangeRates (
                chatID INTEGER NOT NULL PRIMARY KEY ,
                _AED INTEGER DEFAULT 0,
                _AFN INTEGER DEFAULT 0,
                _ALL INTEGER DEFAULT 0,
                _AMD INTEGER DEFAULT 0,
                _ANG INTEGER DEFAULT 0,
                _AOA INTEGER DEFAULT 0,
                _ARS INTEGER DEFAULT 0,
                _AUD INTEGER DEFAULT 0,
                _AWG INTEGER DEFAULT 0,
                _AZN INTEGER DEFAULT 0,
                _BAM INTEGER DEFAULT 0,
                _BBD INTEGER DEFAULT 0,
                _BDT INTEGER DEFAULT 0,
                _BGN INTEGER DEFAULT 0,
                _BHD INTEGER DEFAULT 0,
                _BIF INTEGER DEFAULT 0,
                _BMD INTEGER DEFAULT 0,
                _BND INTEGER DEFAULT 0,
                _BOB INTEGER DEFAULT 0,
                _BRL INTEGER DEFAULT 0,
                _BSD INTEGER DEFAULT 0,
                _BTN INTEGER DEFAULT 0,
                _BWP INTEGER DEFAULT 0,
                _BYN INTEGER DEFAULT 0,
                _BZD INTEGER DEFAULT 0,
                _CAD INTEGER DEFAULT 0,
                _CDF INTEGER DEFAULT 0,
                _CHF INTEGER DEFAULT 0,
                _CLF INTEGER DEFAULT 0,
                _CLP INTEGER DEFAULT 0,
                _CNY INTEGER DEFAULT 0,
                _COP INTEGER DEFAULT 0,
                _CRC INTEGER DEFAULT 0,
                _CUC INTEGER DEFAULT 0,
                _CUP INTEGER DEFAULT 0,
                _CVE INTEGER DEFAULT 0,
                _CZK INTEGER DEFAULT 0,
                _DJF INTEGER DEFAULT 0,
                _DKK INTEGER DEFAULT 0,
                _DOP INTEGER DEFAULT 0,
                _DZD INTEGER DEFAULT 0,
                _EGP INTEGER DEFAULT 0,
                _ERN INTEGER DEFAULT 0,
                _ETB INTEGER DEFAULT 0,
                _EUR INTEGER DEFAULT 1,
                _FJD INTEGER DEFAULT 0,
                _FKP INTEGER DEFAULT 0,
                _GBP INTEGER DEFAULT 1,
                _GEL INTEGER DEFAULT 0,
                _GGP INTEGER DEFAULT 0,
                _GHS INTEGER DEFAULT 0,
                _GIP INTEGER DEFAULT 0,
                _GMD INTEGER DEFAULT 0,
                _GNF INTEGER DEFAULT 0,
                _GTQ INTEGER DEFAULT 0,
                _GYD INTEGER DEFAULT 0,
                _HKD INTEGER DEFAULT 0,
                _HNL INTEGER DEFAULT 0,
                _HRK INTEGER DEFAULT 0,
                _HTG INTEGER DEFAULT 0,
                _HUF INTEGER DEFAULT 0,
                _IDR INTEGER DEFAULT 0,
                _ILS INTEGER DEFAULT 0,
                _IMP INTEGER DEFAULT 0,
                _INR INTEGER DEFAULT 0,
                _IQD INTEGER DEFAULT 0,
                _IRR INTEGER DEFAULT 0,
                _ISK INTEGER DEFAULT 0,
                _JEP INTEGER DEFAULT 0,
                _JMD INTEGER DEFAULT 0,
                _JOD INTEGER DEFAULT 0,
                _JPY INTEGER DEFAULT 0,
                _KES INTEGER DEFAULT 0,
                _KGS INTEGER DEFAULT 0,
                _KHR INTEGER DEFAULT 0,
                _KMF INTEGER DEFAULT 0,
                _KPW INTEGER DEFAULT 0,
                _KRW INTEGER DEFAULT 0,
                _KWD INTEGER DEFAULT 0,
                _KYD INTEGER DEFAULT 0,
                _KZT INTEGER DEFAULT 0,
                _LAK INTEGER DEFAULT 0,
                _LBP INTEGER DEFAULT 0,
                _LKR INTEGER DEFAULT 0,
                _LRD INTEGER DEFAULT 0,
                _LSL INTEGER DEFAULT 0,
                _LTL INTEGER DEFAULT 0,
                _LVL INTEGER DEFAULT 0,
                _LYD INTEGER DEFAULT 0,
                _MAD INTEGER DEFAULT 0,
                _MDL INTEGER DEFAULT 0,
                _MGA INTEGER DEFAULT 0,
                _MKD INTEGER DEFAULT 0,
                _MMK INTEGER DEFAULT 0,
                _MNT INTEGER DEFAULT 0,
                _MOP INTEGER DEFAULT 0,
                _MRO INTEGER DEFAULT 0,
                _MUR INTEGER DEFAULT 0,
                _MVR INTEGER DEFAULT 0,
                _MWK INTEGER DEFAULT 0,
                _MXN INTEGER DEFAULT 0,
                _MYR INTEGER DEFAULT 0,
                _MZN INTEGER DEFAULT 0,
                _NAD INTEGER DEFAULT 0,
                _NGN INTEGER DEFAULT 0,
                _NIO INTEGER DEFAULT 0,
                _NOK INTEGER DEFAULT 0,
                _NPR INTEGER DEFAULT 0,
                _NZD INTEGER DEFAULT 0,
                _OMR INTEGER DEFAULT 0,
                _PAB INTEGER DEFAULT 0,
                _PEN INTEGER DEFAULT 0,
                _PGK INTEGER DEFAULT 0,
                _PHP INTEGER DEFAULT 0,
                _PKR INTEGER DEFAULT 0,
                _PLN INTEGER DEFAULT 0,
                _PYG INTEGER DEFAULT 0,
                _QAR INTEGER DEFAULT 0,
                _RON INTEGER DEFAULT 0,
                _RSD INTEGER DEFAULT 0,
                _RUB INTEGER DEFAULT 1,
                _RWF INTEGER DEFAULT 0,
                _SAR INTEGER DEFAULT 0,
                _SBD INTEGER DEFAULT 0,
                _SCR INTEGER DEFAULT 0,
                _SDG INTEGER DEFAULT 0,
                _SEK INTEGER DEFAULT 0,
                _SGD INTEGER DEFAULT 0,
                _SHP INTEGER DEFAULT 0,
                _SLL INTEGER DEFAULT 0,
                _SOS INTEGER DEFAULT 0,
                _SRD INTEGER DEFAULT 0,
                _SVC INTEGER DEFAULT 0,
                _SYP INTEGER DEFAULT 0,
                _SZL INTEGER DEFAULT 0,
                _THB INTEGER DEFAULT 0,
                _TJS INTEGER DEFAULT 0,
                _TMT INTEGER DEFAULT 0,
                _TND INTEGER DEFAULT 0,
                _TOP INTEGER DEFAULT 0,
                _TRY INTEGER DEFAULT 0,
                _TTD INTEGER DEFAULT 0,
                _TWD INTEGER DEFAULT 0,
                _TZS INTEGER DEFAULT 0,
                _UAH INTEGER DEFAULT 1,
                _UGX INTEGER DEFAULT 0,
                _USD INTEGER DEFAULT 1,
                _UYU INTEGER DEFAULT 0,
                _UZS INTEGER DEFAULT 0,
                _VEF INTEGER DEFAULT 0,
                _VND INTEGER DEFAULT 0,
                _VUV INTEGER DEFAULT 0,
                _WST INTEGER DEFAULT 0,
                _XAF INTEGER DEFAULT 0,
                _XAG INTEGER DEFAULT 0,
                _XAU INTEGER DEFAULT 0,
                _XCD INTEGER DEFAULT 0,
                _XOF INTEGER DEFAULT 0,
                _XPF INTEGER DEFAULT 0,
                _YER INTEGER DEFAULT 0,
                _ZAR INTEGER DEFAULT 0,
                _ZMW INTEGER DEFAULT 0,
                _ZWL INTEGER DEFAULT 0
            );
        """)

    con.close()
    Print("Main DB is created.", "S")
Example #20
0
def DBIntegrityCheck():
    if os.path.exists("DataBases/DataForBot.sqlite"):
        # Connect to DB
        con = sql.connect('DataBases/DataForBot.sqlite')
        cursor = con.cursor()
        Print("Connected to main DB successfully.", 'S')

        # Getting all names of tables
        cursor.execute("SELECT name FROM sqlite_master WHERE type='table';")
        listNames = cursor.fetchall()
        for i in range(len(listNames)):
            listNames[i] = listNames[i][0]

        for i in listOfTables:
            if not i in listNames:
                CreateFileBackup("DataBases/DataForBot.sqlite")
                os.remove('DataBases/DataForBot.sqlite')
                Print(
                    "Error. Main database is corrupted. 'DataForBot.sqlite' was backuped and deleted. New database will be create automatically.",
                    "E")

                CreateDataBaseTemplate()
                break
        Print("Main DB is OK.", "S")
    else:
        Print("Connected to main DB unsuccessfully.", "E")
        CreateDataBaseTemplate()

    if os.path.exists("DataBases/ServiceData.sqlite"):
        # Connect to DB
        con = sql.connect('DataBases/ServiceData.sqlite')
        cursor = con.cursor()
        Print("Connected to service DB successfully.", "S")

        # Getting all names of tables
        cursor.execute("SELECT name FROM sqlite_master WHERE type='table';")
        listNames = cursor.fetchall()
        for i in range(len(listNames)):
            listNames[i] = listNames[i][0]

        for i in listOfServiceTables:
            if not i in listNames:
                CreateFileBackup("DataBases/ServiceData.sqlite")
                os.remove('DataBases/ServiceData.sqlite')
                Print(
                    "Error. Service database is corrupted. 'ServiceData.sqlite' was backuped and deleted. New database will be create automatically.",
                    "E")

                CreateServiceDataBase()
                break
        Print("Service DB is OK.", "S")
    else:
        Print("Connected to service DB unsuccessfully.", "E")
        CreateServiceDataBase()

    if os.path.exists("DataBases/StatsData.sqlite"):
        con = sql.connect("DataBases/StatsData.sqlite")
        cursor = con.cursor()
        Print("Connected to stats DB successfully.", "S")

        cursor.execute("SELECT name FROM sqlite_master WHERE type='table';")
        listNames = cursor.fetchall()
        for i in range(len(listNames)):
            listNames[i] = listNames[i][0]

        for i in listOfStatsTables:
            if not i in listNames:
                CreateFileBackup("DataBases/StatsData.sqlite")
                os.remove("DataBases/StatsData.sqlite")
                Print(
                    "Error. Stats database is corrupted. 'StatsData.sqlite' was backuped and deleted. New database will be create automatically.",
                    "E")
                CreateStatsDataBase()
                break
        Print("Stats DB is OK.", "S")
    else:
        Print("Connected to stats DB unsuccessfully.", "E")
        CreateStatsDataBase()
Example #21
0
async def CallbackAnswer(call: types.CallbackQuery):
    fromUserId = call.from_user.id
    chatID = call.message.chat.id
    chatType = call.message.chat.type
    callData = call.data
    allAdmins = call.message.chat.all_members_are_administrators
    userName = call.from_user.username

    if IsUserInBlackList(call.message.from_user.id, chatID):
        return
    if callData == "delete":
        CanUserDeleteMes = False
        if chatType == "private":
            CanUserDeleteMes = True
        else:
            whoCanDeleteMes = DBH.GetSetting(chatID, "deleteRules", chatType)
            if whoCanDeleteMes == "everybody":
                CanUserDeleteMes = True
            elif chatType == "group":
                member = await call.message.chat.get_member(fromUserId)
                if allAdmins == True and whoCanDeleteMes == 'admins':
                    CanUserDeleteMes = True
                elif allAdmins == True and whoCanDeleteMes == 'creator':
                    if member.status == 'creator':
                        CanUserDeleteMes = True
                elif allAdmins == False:
                    if whoCanDeleteMes == 'admins' and (
                            member.status == "administrator"
                            or member.status == "creator"
                    ) or whoCanDeleteMes == 'creator' and member.status == "creator":
                        CanUserDeleteMes = True
            elif chatType == "supergroup":
                member = await call.message.chat.get_member(fromUserId)
                if whoCanDeleteMes == 'admins' and (
                        member.status == "administrator"
                        or member.status == "creator"
                ) or whoCanDeleteMes == 'creator' and member.status == "creator":
                    CanUserDeleteMes = True
        if CanUserDeleteMes:
            try:
                await bot.edit_message_text(
                    call.message.text + "\n\n@" +
                    str(call.from_user.username) + " (id: " + str(fromUserId) +
                    ")" + " delete it.", chatID, call.message.message_id)
                await call.message.delete()
            except:
                Print("Cannot delete message.", "E")
    elif str(callData).find("delbut_") == 0:
        member = await call.message.chat.get_member(fromUserId)
        if not CanUserEditSettings(chatID, chatType, member.status,
                                   call.from_user.id, userName, allAdmins):
            return
        Index = str(callData).find("_") + 1
        Value = str(callData)[Index:len(str(callData))]
        if Value == "menu":
            pass
        elif Value == "button":
            IsFlag = DBH.GetSetting(chatID, 'deleteButton', chatType)
            DBH.SetSetting(chatID, 'deleteButton', int(not IsFlag), chatType)
        else:
            DBH.SetSetting(chatID, 'deleteRules', Value, chatType)
        await bot.edit_message_text(
            GetText(chatID, 'delete_button_menu', chatType),
            chatID,
            call.message.message_id,
            reply_markup=CustomMarkup.DeleteButtonMenuMarkup(chatID, chatType))

    elif str(callData).find("lang_") == 0:
        member = await call.message.chat.get_member(fromUserId)
        if not CanUserEditSettings(chatID, chatType, member.status,
                                   call.from_user.id, userName, allAdmins):
            return
        Index = str(callData).find("_") + 1
        Value = str(callData)[Index:len(str(callData))]
        if Value == "menu":
            pass
        else:
            DBH.SetSetting(chatID, 'lang', Value, chatType)
        await bot.edit_message_text(
            GetText(chatID, 'lang_menu', chatType),
            chatID,
            call.message.message_id,
            reply_markup=CustomMarkup.LanguageMenuMarkup(chatID, chatType))

    elif str(callData).find("flags_") == 0:
        member = await call.message.chat.get_member(fromUserId)
        if not CanUserEditSettings(chatID, chatType, member.status,
                                   call.from_user.id, userName, allAdmins):
            return
        Index = str(callData).find("_") + 1
        Value = str(callData)[Index:len(str(callData))]
        if Value == "menu":
            pass
        elif Value == "button":
            IsFlag = DBH.GetSetting(chatID, 'flags', chatType)
            DBH.SetSetting(chatID, 'flags', int(not IsFlag), chatType)
        await bot.edit_message_text(GetText(chatID, 'flags_menu', chatType),
                                    chatID,
                                    call.message.message_id,
                                    reply_markup=CustomMarkup.FlagsMarkup(
                                        chatID, chatType))

    elif str(callData).find("edit_") == 0:
        member = await call.message.chat.get_member(fromUserId)
        memberStatus = member.status
        if not CanUserEditSettings(chatID, chatType, memberStatus,
                                   call.from_user.id, userName, allAdmins):
            return
        Index = str(callData).find("_") + 1
        Value = str(callData)[Index:len(str(callData))]
        if Value == "menu":
            pass
        else:
            if memberStatus == "member":
                pass
            elif memberStatus == "administrator" and (Value == "admins"
                                                      or Value == "everybody"):
                DBH.SetSetting(chatID, 'editSettings', Value, chatType)
            elif memberStatus == "creator":
                DBH.SetSetting(chatID, 'editSettings', Value, chatType)
        await bot.edit_message_text(GetText(chatID, 'edit_menu', chatType),
                                    chatID,
                                    call.message.message_id,
                                    reply_markup=CustomMarkup.EditMenuMarkup(
                                        chatID, chatType))

    elif str(callData).find("cur_") == 0:
        member = await call.message.chat.get_member(fromUserId)
        memberStatus = member.status
        if not CanUserEditSettings(chatID, chatType, memberStatus,
                                   call.from_user.id, userName, allAdmins):
            return
        Index = str(callData).find("_") + 1
        Value = str(callData)[Index:len(str(callData))]

        if Value == "menu":
            await bot.edit_message_text(
                GetText(chatID, "currencies_mainmenu", chatType),
                chatID,
                call.message.message_id,
                reply_markup=CustomMarkup.CurrenciesMainMenuMarkup(
                    chatID, chatType))
        elif Value == "cryptomenu":
            await bot.edit_message_text(
                GetText(chatID, "crypto_mainmenu", chatType),
                chatID,
                call.message.message_id,
                reply_markup=CustomMarkup.CryptoMenuMarkup(chatID, chatType))
        elif Value == "curmenu":
            await bot.edit_message_text(
                GetText(chatID, "currencies_menu", chatType),
                chatID,
                call.message.message_id,
                reply_markup=CustomMarkup.CurrenciesMenuMarkup(
                    chatID, chatType))
        elif len(Value) == 1 or len(Value) == 2:
            await bot.edit_message_text(
                GetText(chatID, "letter_menu", chatType),
                chatID,
                call.message.message_id,
                reply_markup=CustomMarkup.CurrenciesSetupMarkup(
                    chatID, chatType, Value))
        elif len(Value) == 3 or len(Value) == 4:
            DBH.ReverseCurrencySetting(chatID, Value)
            if Value in ListsCache.GetListOfCrypto():
                await bot.edit_message_text(
                    GetText(chatID, "crypto_mainmenu", chatType),
                    chatID,
                    call.message.message_id,
                    reply_markup=CustomMarkup.CryptoMenuMarkup(
                        chatID, chatType))
            else:
                dictForMU = {
                    'A': 'a',
                    'B': 'b',
                    'C': 'c',
                    'D': 'df',
                    'E': 'df',
                    'F': 'df',
                    'G': 'gh',
                    'H': 'gh',
                    'I': 'ij',
                    'J': 'ij',
                    'K': 'kl',
                    'L': 'kl',
                    'M': 'm',
                    'N': 'nq',
                    'O': 'nq',
                    'P': 'nq',
                    'Q': 'nq',
                    'R': 'rs',
                    'S': 'rs',
                    'T': 'tu',
                    'U': 'tu',
                    'V': 'vz',
                    'W': 'vz',
                    'X': 'vz',
                    'Y': 'vz',
                    'Z': 'vz'
                }
                await bot.edit_message_text(
                    GetText(chatID, "letter_menu", chatType),
                    chatID,
                    call.message.message_id,
                    reply_markup=CustomMarkup.CurrenciesSetupMarkup(
                        chatID, chatType, dictForMU[Value[0]]))

    elif callData == "settings":
        await bot.edit_message_text(GetText(chatID, "main_settings_menu",
                                            chatType),
                                    chatID,
                                    call.message.message_id,
                                    reply_markup=CustomMarkup.SettingsMarkup(
                                        chatID, chatType))
Example #22
0
async def MainVoid(message: types.Message):
    fromUserId = message.from_user.id
    chatID = message.chat.id
    chatType = message.chat.type

    def w2n(MesString: str, lang: str):
        if lang == "ua":
            return numberizerUA.replace_numerals(MesString)
        elif lang == "ru":
            return numberizerRU.replace_numerals(MesString)
        else:
            return numberizerEN.replace_numerals(MesString)

    try:
        if message.forward_from.username == botUsername:
            return
    except:
        pass

    # Checking if a user is on the blacklist
    if IsUserInBlackList(fromUserId, chatID):
        return

    # Get message text
    MessageText = message.text
    if message.photo or message.video is not None or message.document is not None:
        MessageText = message.caption
    if MessageText is None or MessageText == "":
        return

    # Logging basic information to terminal
    PrintMainInfo(message, MessageText)

    # Checking the chat in the database
    IsChatExist(chatID, chatType)

    # word to num
    OriginalMessageText = MessageText
    MessageText = MessageText.lower()
    MessageText = RemoveLinksAndWords(MessageText)
    MessageText = w2n(MessageText, 'ru')
    MessageText = w2n(MessageText, 'uk')
    MessageText = w2n(MessageText, 'en')
    Print(MessageText, "L")

    # Check digit
    if not any(map(str.isdigit, MessageText)):
        return

    # Preparing a message for searching currencies
    try:
        TextArray = SpecialSplit(MessageText)
    except:
        Print("Error split.", "E")
        return
    Print(str(TextArray), "L")

    # '5kk USD' to '5000000 USD'
    TextArray = TextToDigit(TextArray)
    Print(str(TextArray), "L")

    # Searching Currencies
    NumArray = SearchValuesAndCurrencies(TextArray)
    Print(str(NumArray), "L")

    # If there are no currencies, then work is interrupted
    if NumArray == [[], [], [], []]:
        return

    if StopDDoS.updateData(fromUserId, chatID,
                           len(NumArray[1]) + len(NumArray[3]),
                           message.chat.title):
        await message.reply(GetText(chatID, 'added_to_bl', chatType))
        ListAdmins = DBH.GetAdmins()
        for i in ListAdmins:
            await bot.send_message(
                i,
                "Пользователь " + str(fromUserId) +
                " заблокирован. Его возможное имя пользователя: @" +
                str(message.from_user.username),
                reply_markup=CustomMarkup.DeleteMarkup(i, "private"))
        return

    result = AnswerText(NumArray, chatID, chatType)
    try:
        await message.reply(result,
                            parse_mode="HTML",
                            reply_markup=CustomMarkup.DeleteMarkup(
                                chatID, chatType))
    except:
        Print("Cannot send message", "E")
        Print(
            "Username: "******" | User ID: " +
            str(message.from_user.id) + " | First name: " +
            str(message.from_user.first_name) + " | Last name: " +
            str(message.from_user.last_name), "E")
        Print(
            "Chat ID: " + str(message.chat.id) + " | Chat name: " +
            str(message.chat.title) + " | Chat username: "******" | Chat type: " +
            str(message.chat.type), "E")
        Print("Message: " + str(OriginalMessageText), "E")
    DBH.UpdateChatUsage(chatID)
    for i in NumArray[1]:
        DBH.ProcessedCurrency(chatID, fromUserId,
                              ListsCache.GetListOfCur()[i],
                              OriginalMessageText)
    for i in NumArray[3]:
        DBH.ProcessedCurrency(chatID, fromUserId,
                              ListsCache.GetListOfCrypto()[i],
                              OriginalMessageText)
Example #23
0
        nameOfArch = DBH.CreateAllBackups()
        time.sleep(86400)


def RegularStats():
    while True:
        Stats = DBH.GetSetTimeStats()
        time.sleep(86400)


if __name__ == '__main__':
    LoadDataForBot()

    if len(sys.argv) == 3:
        if not CheckArgument(sys.argv[1], sys.argv[2]):
            Print("Error arg.", "E")
            sys.exit()
    elif len(sys.argv) == 5 and sys.argv[1] != sys.argv[3]:
        if not CheckArgument(sys.argv[1], sys.argv[2]):
            Print("Error arg.", "E")
            sys.exit()
        elif not CheckArgument(sys.argv[3], sys.argv[4]):
            Print("Error arg.", "E")
            sys.exit()
    elif len(sys.argv) == 7 and sys.argv[1] != sys.argv[3] and sys.argv[
            1] != sys.argv[2] and sys.argv[2] != sys.argv[3]:
        if not CheckArgument(sys.argv[1], sys.argv[2]):
            Print("Error arg.", "E")
            sys.exit()
        elif not CheckArgument(sys.argv[3], sys.argv[4]):
            Print("Error arg.", "E")