Пример #1
0
def getLinkedAccountsList(discordID, currently_in_clan_required=False):
    cursor, conn = getCursorAndConnection()
    query = '''
		SELECT MEMBERS.member_name
		FROM 
			MEMBERS
		INNER JOIN DISCORD_NAMES
			ON DISCORD_NAMES.member_tag = MEMBERS.member_tag
		WHERE
			DISCORD_NAMES.discord_tag = ?		
		'''
    if currently_in_clan_required:
        query += " AND MEMBERS.in_clan_currently = 1"
    query += " ORDER BY DISCORD_NAMES.account_order"

    cursor.execute(query, (discordID,))
    accountResults = cursor.fetchall()

    query = '''
		UPDATE DISCORD_PROPERTIES SET time_last_checked_in = ?
		WHERE
			discord_tag = ?
		'''
    cursor.execute(query, (getDataFromServer.getUTCTimestamp(), discordID, ))

    for i in range(0, len(accountResults)):
        accountResults[i] = accountResults[i][0]

    conn.commit()
    conn.close()
    return accountResults
Пример #2
0
def getTimestampsForCurrentWar():
    currentWarID = None
    currentTimestamp = getDataFromServer.getUTCTimestamp()
    cursor, conn = getCursorAndConnection()
    query = '''
			SELECT war_day_end FROM WARS
			WHERE war_day_end > ?
			'''
    cursor.execute(query, (currentTimestamp,))
    warEndTime = cursor.fetchone()
    if warEndTime == None:
        return None
    else:
        print('make me sort descending please!')
        warEndTime = warEndTime[0]
        hoursRemainingReminder = [3, 1]
        results = []
        for hourReminder in hoursRemainingReminder:
            thisTimestamp = warEndTime - (hourReminder * 3600)
            if thisTimestamp > currentTimestamp:
                timeRemainingString = '{} hours remaining in war!'.format(
                    hourReminder)
                if hourReminder == 1:
                    timeRemainingString = '{} hour remaining in war!'.format(
                        hourReminder)
                results.append((thisTimestamp, timeRemainingString))
        if len(results) == 0:
            return None
        else:
            return results
Пример #3
0
def removeMemberFromWar(member_name):
    #	conn = sqlite3.connect(db_file)
    #	print(sqlite3.version)
    #	cursor = conn.cursor()
    member_name = member_name.upper()
    cursor, conn = getCursorAndConnection()
    query = '''
		INSERT OR REPLACE INTO 
			REMOVE_FROM_WAR (member_tag, time_requested, change_number)
		VALUES
			((SELECT member_tag from MEMBERS WHERE upper(member_name) = ?), ?, ?)
		'''
    timestamp = getDataFromServer.getUTCTimestamp()
    result = config_strings.success
    try:
        cursor.execute(query, (member_name, timestamp,
                               getMaxRosterChangeNumber(cursor, conn)+1))
    except sqlite3.IntegrityError as e:
        result = config_strings.failed
    conn.commit()
    conn.close()
    return result