local function initialize(event, addonName)
    if addonName ~= "BestFriends" then return end

    ZO_ChatSystem_GetEventHandlers()[EVENT_FRIEND_PLAYER_STATUS_CHANGED] = function(displayName, oldStatus, newStatus)
        local wasOnline = oldStatus ~= PLAYER_STATUS_OFFLINE
        local isOnline = newStatus ~= PLAYER_STATUS_OFFLINE

        if not wasOnline and isOnline then
            local link = ZO_LinkHandler_CreateDisplayNameLink(displayName)
            ZO_Alert(UI_ALERT_CATEGORY_ALERT, nil, zo_strformat(SI_FRIENDS_LIST_FRIEND_LOGGED_ON, link))
        elseif wasOnline and not isOnline then
            local link = ZO_LinkHandler_CreateDisplayNameLink(displayName)
            ZO_Alert(UI_ALERT_CATEGORY_ALERT, nil, zo_strformat(SI_FRIENDS_LIST_FRIEND_LOGGED_OFF, link))
        end
    end
end

EVENT_MANAGER:RegisterForEvent("BestFriends", EVENT_ADD_ON_LOADED, initialize)